Skip to content
AdminKit

Is port 27017 (MongoDB) exposed to the internet without authentication?

Port 27017 is MongoDB's IANA-registered default port. Before version 3.6, MongoDB's binaries bound to all network interfaces by default with authentication off, so a database stood up with no extra configuration was immediately reachable and writable from the internet. 27017 isn't on AdminKit's port-check tool's nine-port list, so this guide explains how to confirm manually whether yours is exposed.

By AdminKit team, Netbase JSC · Updated

Key takeaways

  • MongoDB 3.6 and later bind to localhost by default, but access control is still off by default. A server bound to a public address with no extra settings answers every command from anyone.
  • That combination is what fed the 2017 ransom wave, in which tens of thousands of databases were wiped and replaced with a ransom note.
  • Turning on authentication is necessary, not sufficient: CVE-2025-14847 lets an unauthenticated client read server memory through zlib-compressed messages, and CISA lists it as exploited.
  • From outside, mongosh tells you more than nc: a database list means no authentication, a “requires authentication” error means the listener is still exposed.
  • Fix it in this order: enable authorization, bind to a private address, firewall 27017, require TLS, and run a fixed release.

Why was MongoDB reachable by default?

IANA registers port 27017 for the MongoDB wire protocol. MongoDB’s own IP binding documentation confirms that from version 3.6 onward, the mongod and mongos binaries bind to localhost only out of the box — but that fix came after years of the opposite default. Earlier versions bound to all network interfaces with no authentication required, so a database brought online with no extra configuration beyond the defaults was immediately reachable, and immediately both readable and writable, from any network that could route to it.

The 3.6 change fixed only the network half. MongoDB’s role-based access control documentation still states that MongoDB does not enable access control by default; it has to be switched on with --auth or security.authorization: enabled. A server that someone rebinds to 0.0.0.0 or --bind_ip_all so another machine can connect is therefore back to the pre-3.6 situation unless authorization was turned on at the same time.

SettingDefault since 3.6What exposure looks like
net.bindIplocalhost0.0.0.0, ::,0.0.0.0 or net.bindIpAll: true
security.authorizationdisabledStill disabled after the bind address was widened
net.tls.modeTLS off unless configuredCredentials and documents in clear text on the network
net.compression.compressorssnappy,zstd,zlibzlib left on while running a release affected by CVE-2025-14847

What happened when that default met the internet at scale?

Krebs on Security’s contemporaneous reporting documented what followed: starting in late December 2016 and escalating through January 2017, researchers including Victor Gevers of the GDI Foundation tracked a wave of automated attacks against internet-reachable, unauthenticated MongoDB instances. Attackers simply connected with no credentials, copied or deleted the data, and replaced it with a ransom note demanding Bitcoin. The count of compromised databases grew from roughly 200 to over 27,000 within about two weeks, driven by at least fifteen separate, uncoordinated attacker groups independently finding and re-ransoming the same exposed instances — meaning a given database could be wiped by multiple attackers before anyone in the organization noticed. A second wave hit again in September 2017. In both cases, most victims who paid the ransom never recovered their data, because many of the attackers had never kept a usable copy to begin with.

What can someone do with an open port 27017?

With authorization disabled, MongoDB has no notion of a guest. Every client that completes the connection handshake can run every command, including administrative ones:

What the attacker sendsWhat it does
listDatabases, then find on each collectionLists and reads every database and document
dropDatabase and insertDeletes the data and leaves a ransom note in a new collection, the 2017 pattern
createUser with the root roleAdds an account of their own, which survives if you later switch authorization on without reviewing users

Authentication closes those, but not everything that reaches the listener. CVE-2025-14847, published in December 2025, is a flaw in how the server handles zlib-compressed protocol messages: mismatched length fields let an unauthenticated client read uninitialized heap memory, which can hold fragments of other clients’ data. NVD lists affected releases from 3.6 through 8.2, and CISA added it to its Known Exploited Vulnerabilities Catalog on 29 December 2025. MongoDB’s tracker entry SERVER-115508 names the fixed releases (8.2.3, 8.0.17, 7.0.28, 6.0.27, 5.0.32 and 4.4.30) and, as a stopgap, starting the server with a compressor list that leaves out zlib, such as snappy,zstd. Releases 4.2 and older have no fixed build, so for them the compressor change and a closed port are the only defences. The default compressor list in the configuration file options includes zlib, so an unpatched server is affected unless someone removed it.

Why does this still happen years later?

The specific insecure default is fixed as of MongoDB 3.6, but the underlying mistake — binding a database to a public interface without enabling authentication — is still something an administrator can do manually, and cloud environments make it easy to stand up a new instance quickly without revisiting every setting. A few paths come up again and again:

  1. The official container image. The mongo image documentation says its default configuration requires no authentication for access, even for the administrative user. Authentication is switched on only when both MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD are set on first start, and those variables have no effect on a data directory that already holds a database. Publish that container with -p 27017:27017 and it is open on every host interface.
  2. A typo in the setting. The configuration reference warns that security.authorization is case-sensitive on current releases, and that earlier versions silently ignored values such as Enabled and left authorization off.
  3. Users created, enforcement forgotten. Creating users with the localhost exception is one step; restarting with authorization enabled is another. Accounts existing in the admin database does not mean anyone is asked for them.

How do you check your own exposure?

AdminKit’s open ports check checks a fixed nine-port list, and port 27017 isn’t on it — confirm your public IP with what is my IP, then test the port manually from a machine outside your network with nc -vz -w 3 203.0.113.5 27017, useful confirmation that a bind-address change or firewall rule actually took effect rather than assuming it did.

The AdminKit check probes only the public address your browser connects from, so it speaks for the office or home network you are on. A MongoDB server on a cloud host has its own public address, and has to be tested from outside against that address.

To see whether authorization is enforced, ask the server for its database list without credentials:

$ mongosh "mongodb://203.0.113.5:27017/" --quiet --eval "db.adminCommand({listDatabases: 1})"

Example replies (illustrative; documentation address, wording varies by version):

ReplyWhat it means
A list of database names and sizesAuthorization is off. Anyone can read and delete everything. Close the port now.
MongoServerError[Unauthorized]: command listDatabases requires authenticationAuthorization is on, but the listener is reachable and still exposed to pre-authentication flaws and password guessing.
A TLS or handshake errorThe server requires TLS. Better, but the port is still open.
ECONNREFUSED or a timeoutNothing reachable on 27017 from where you tested.

How do you confirm the listener on your own host?

On the server, check both what the socket is bound to and what the running process was started with:

$ ss -ltnp | grep 27017
LISTEN 0  4096  0.0.0.0:27017  0.0.0.0:*  users:(("mongod",pid=944,fd=11))

test> db.adminCommand({ getCmdLineOpts: 1 }).parsed
test> db.version()

The ss line above is an example; 0.0.0.0:27017 or [::]:27017 means all interfaces. getCmdLineOpts returns the options the running mongod was started with, including net.bindIp and security.authorization, which is more reliable than reading mongod.conf if the server was started by a script or container entrypoint. db.version() tells you whether you are on a release that fixes CVE-2025-14847.

How do you fix an exposed MongoDB?

  • Enable authentication using MongoDB’s SCRAM, x.509 certificate, or another supported mechanism — this alone defeats the no-credential attack pattern described above.
  • Confirm net.bindIp is set to a private or loopback address, not 0.0.0.0 or an unrestricted range, consistent with MongoDB’s own post-3.6 default.
  • Add a firewall rule restricting port 27017 to only the application servers that need it, rather than relying on the database’s own access controls alone.
  • Upgrade to a release that fixes CVE-2025-14847; until you can, remove zlib from the compressor list.
  • Require TLS for client connections with net.tls.mode: requireTLS, as described in MongoDB’s TLS configuration tutorial.
  • Review the users in the admin database for accounts you did not create, especially after any period of running without authorization.
  • Review MongoDB’s own Security Checklist for Self-Managed Deployments for the full set of hardening steps beyond authentication and binding.

A mongod.conf that puts those settings together for a server reached from one private application network might read:

net:
  port: 27017
  bindIp: 127.0.0.1,10.0.2.15
  tls:
    mode: requireTLS
    certificateKeyFile: /etc/ssl/mongodb.pem
  compression:
    compressors: snappy,zstd
security:
  authorization: enabled

The same reachable-database pattern appears in the search and relational engines too — compare Elasticsearch on port 9200, where security is on by default only from 8.0, and PostgreSQL on port 5432, where the network default is closed but pg_hba.conf decides the rest.

Which servers may you test with these checks?

Every check this page links to is for assets you own or are explicitly authorized to test. Never scan, probe, or attempt to connect to a network or device you don’t control — AdminKit’s active checks only ever run against the IP making the request or an asset you’ve verified ownership of. See our Disclaimer and Acceptable Use Policy for the full terms. MongoDB’s default-open history puts it in good (or rather, bad) company among the database and service exposure checks in AdminKit’s machine protocols cluster.

This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.

Frequently asked questions

Does AdminKit's port-check tool scan port 27017?

No. The tool checks a fixed list of nine specific TCP ports (23, 554, 1883, 8883, 502, 7547, 80, 443, 8080) chosen for how often they turn up misconfigured on home and small-office devices — see the port-check tool page for the current list. 27017 isn't on that list, so confirm your own exposure with the manual check below.

Did MongoDB actually fix the insecure-default problem?

Partly. MongoDB's own documentation confirms that starting with version 3.6, mongod and mongos bind to localhost only by default, so a fresh install no longer accepts remote connections until an administrator explicitly changes the bind address. Access control, however, is still off by default, so databases deployed before that change, or ones where an admin later set the bind address to all interfaces without adding authentication, remain exposed.

Is this a historical problem or does it still happen?

Both — the large-scale ransom wave happened in January and September 2017, but the same combination of a public bind address and no authentication is still easy to create by hand or with a container image. In December 2025 a further risk was added: CVE-2025-14847, a flaw that lets an unauthenticated client read server memory, which CISA lists as known to be exploited.

What actually happened in the 2017 attacks?

Security researchers, including Victor Gevers of the GDI Foundation, documented attackers scanning the internet for reachable, unauthenticated MongoDB instances, connecting with no credentials at all, deleting the data, and leaving a ransom note demanding Bitcoin — tens of thousands of databases were wiped, and most victims who paid never got their data back, since many attackers had never actually kept a copy.

What's the fastest fix if I find my own instance's port 27017 open?

Enable authentication (MongoDB supports SCRAM, x.509 and other mechanisms) before anything else, confirm net.bindIp is set to a private or loopback address rather than 0.0.0.0, add a firewall rule restricting port 27017 to only the application servers that need it, and upgrade to a release that fixes CVE-2025-14847.

Want AdminKit to watch this for you?

Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.

Huy Nguyen (David), Founder and CEO of Netbase JSC

Talk to an expert

Huy Nguyen (David), Founder & CEO, Netbase JSC

Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.