Databases reachable from the internet without authentication are found and emptied by automated scripts, often within hours, and the ransom note left behind rarely means the data can be bought back. This guide is for database and cloud operations teams who need to find any of their own instances that are open to the internet, close them using each engine's binding and authentication settings, and recover when a wiper or ransom note campaign has already hit. It covers how exposure happens, how to search your own estate, the engine settings that matter, what these campaigns do, and a response sequence built around backups. General database hardening (encryption, auditing, injection) is in the Database Security Guide; this page stays on exposure and recovery.
Key takeaways
- Exposure is configuration, not exploitation. The campaigns described in vendor research needed no vulnerability: the databases accepted reads and writes from anyone because they listened on a public interface with authentication off.
- Two settings close most of it. Bind the engine to loopback or a private interface, and turn authentication and access control on; then put a firewall or security group in front as a second gate.
- Find exposure from your own inventory. Cloud configuration, security group rules, listening sockets and your own attack surface monitoring tell you what is open; you do not need to scan anyone else's address space.
- Assume the data is gone, and possibly copied. Secureworks researchers judged that attackers who replaced Elasticsearch data with ransom notes probably had not kept a copy, so paying would likely not restore it, while the data may still have been read before deletion.
- Backups decide the outcome. Offline or immutable backups that are tested turn a wiper campaign into a restore and an investigation; without them it is permanent data loss and a possible breach notification.
How databases end up exposed
Most current engines start safely on a single host, then become exposed when someone widens the listener to make a second machine connect and never adds authentication or network limits. Typical routes:
- Bind address widened for convenience:
bindIp,listen_addresses,bindornetwork.hostchanged to all interfaces during a migration or test, on a host that has a public address. - Authentication never enabled: MongoDB's security checklist lists enabling access control as a separate step from installation, and Redis authentication is opt-in through ACLs or
requirepass. A widened listener without these steps is an open database. - Permissive cloud rules: a security group, network security group or firewall rule admitting 0.0.0.0/0 to a database port, or a managed database created with public access enabled.
- Containers publishing ports: a container image run with the database port published on all host interfaces, sometimes bypassing host firewall rules the team expected to apply.
- Forgotten instances: development copies, restored snapshots, analytics replicas and proof-of-concept clusters that sit outside the patching and review process.
- Client-side keys with no row rules: backend-as-a-service databases accessed directly from browsers rely on row-level policies. The Moltbook database exposure shows a public key with Row Level Security not configured giving unauthenticated read and write access to every table.
Finding your own exposure
Work only on assets you own or are authorised to assess. The aim is a complete list of database listeners and a yes or no answer for each: can an unauthenticated client on the internet reach it?
- Inventory the engines: combine the configuration management database, cloud asset inventories (every account, subscription and project), container orchestration manifests and software inventory from endpoint agents. Include managed database services and backend-as-a-service projects. The Cloud Database Services Mapped page helps translate service names across providers.
- Check public reachability in cloud configuration: list managed database instances with public access settings turned on, and every network rule that admits 0.0.0.0/0 or ::/0 to a database port. Your cloud security posture management tool should have built-in rules for both.
- Check listeners on hosts: list listening sockets on database hosts and container nodes and record which interface each database port is bound to. Anything on 0.0.0.0 or a public address needs a documented reason.
- Check authentication state: confirm in each engine's configuration that authentication and access control are on (the settings are in the engine table below), and that no anonymous or default account has rights.
- Use an external view of your own ranges: review results from your attack surface management service or internet exposure monitoring for your registered IP ranges and DNS names. Treat any database port finding as a priority ticket. See the Attack Surface Management Guide.
- Prevent new exposure: add policy-as-code checks that block infrastructure changes opening database ports to the internet or enabling public access on managed databases, and alert on drift.
Hardening defaults
Engines are listed alphabetically. The table records what each vendor's documentation states about network binding and authentication; confirm the behaviour of your exact version and packaging, because operating system packages and container images can ship different configuration files.
| Engine | Default port | Binding setting and documented default | Authentication and access control | Extra settings to review |
|---|---|---|---|---|
| Elasticsearch | 9200 (HTTP), 9300 (transport) | On first start with automatic security configuration, Elastic documents the HTTP layer bound to 0.0.0.0 and the transport layer bound to localhost | Automatic security configuration generates TLS certificates for HTTP and transport and sets a password for the elastic superuser; keep security enabled and create least-privilege users and API keys | Kibana exposure, anonymous access settings, snapshot repository credentials |
| MongoDB | 27017 | MongoDB documents that mongod and mongos bind to localhost by default; net.bindIp, net.bindIpAll or --bind_ip_all widen it | Enable access control (security.authorization) and an authentication mechanism (SCRAM by default, or X.509); enable internal membership authentication for replica sets and sharded clusters | security.clusterIpSourceAllowlist, per-user authenticationRestrictions, TLS for all connections |
| MySQL | 3306 | bind_address; check the value in your configuration file and package defaults | One account per application and person, no anonymous accounts, strong authentication plugin, require_secure_transport for TLS | Remote root login, skip-networking where only local access is needed |
| PostgreSQL | 5432 | The PostgreSQL documentation states that listen_addresses defaults to localhost, allowing only loopback connections | pg_hba.conf rules decide which hosts, users and databases may connect and how; avoid trust for network entries; password_encryption defaults to scram-sha-256 | Superuser accounts used by applications, hostssl entries to force TLS |
| Redis | 6379 | Redis documents protected mode (since 3.2.0): with the default configuration and no password, Redis answers only on loopback; bind 127.0.0.1 limits it to local access | ACL users (recommended, Redis 6 and later) or the legacy requirepass; Redis notes that AUTH is sent unencrypted, so use TLS on untrusted networks | Restrict commands such as CONFIG and FLUSHALL with ACL rules (the rename-command method is deprecated) |
Rules that apply to every engine
- Layer the controls: private interface binding, authentication, then a network rule admitting only application subnets and administration paths. Redis's documentation describes authentication as a redundancy layer for when firewalling fails, and the same logic applies to every engine.
- No direct internet administration: reach databases through a bastion, private endpoint or VPN with MFA. CISA's #StopRansomware Guide advises against exposing remote services on the web and calls for compensating controls where exposure cannot be avoided.
- Managed services: keep public access off, use private endpoints or VPC peering, and treat any public endpoint allow list as an exception with an owner and expiry.
- Credentials are machine identities: application database accounts and connection strings are non-human credentials; vault them, scope them per application and rotate them. See the Database Credential and Access Security Guide.
Wiper and ransom note campaigns
These campaigns are high-volume and automated. Public research describes a consistent pattern: find databases that accept unauthenticated connections, delete or replace the contents, and leave a note demanding payment for the data's return.
| Reported campaign | Source | What was reported | Lesson for defenders |
|---|---|---|---|
| Elasticsearch ransom notes | Secureworks Counter Threat Unit, published on the Sophos blog | Over 1,200 unsecured, internet-facing Elasticsearch databases had data replaced with a ransom note in an index named read_me_to_recover_database; the databases required no authentication to read or write; over 450 ransom requests totalling over USD 280,000 | Researchers judged the data was probably not copied, so payment would likely not restore it; the fix is authentication and backups, not negotiation |
| MongoDB mass deletion | Trend Micro, May 2019 | More than 12,000 publicly reachable, unprotected MongoDB databases deleted over about three weeks by automated scripts, with contact addresses left for recovery terms | Trend Micro called these mostly preventable and pointed to MongoDB's security checklist and basic reachability tests after deployment |
Three points matter for planning. First, a ransom note is evidence that an unauthenticated party had write access, so read access and copying must be assumed even when the note claims the data is held safely. Second, the scripts do not target organisations: any open instance is found, including test copies loaded with production data. Third, these are distinct from ransomware that encrypts files on the database host; a host-level encryption incident follows the Cloud Ransomware Response Playbook.
Response and recovery
When an instance is found open, or a ransom note appears, work in this order. The full breach process (legal, communications, regulators) is in the Database Breach Response Playbook.
- Contain without destroying evidence: remove the public network path (security group, firewall or public access setting) first. Do not delete the instance or the ransom note record; snapshot the volume or take a logical copy of what remains.
- Preserve logs: export engine logs (connection and authentication events, MongoDB and PostgreSQL logs, Elasticsearch audit logs where enabled), cloud flow logs and control plane logs for the instance before retention rolls them off.
- Scope the exposure window: establish when the listener or rule became public and when it was closed, from change history and infrastructure as code commits. The window, not the date of the note, defines what may have been read.
- Determine data sensitivity: identify which databases, collections or indices held personal, regulated or secret data (including credentials and API keys stored in tables). Rotate any secret that was stored in the database.
- Do not pay and do not contact the address: research on these campaigns found no reliable evidence that payment restores data. Record the note's indicators (index or collection name, contact details, wallet identifiers) for threat intelligence and law enforcement reporting.
- Rebuild, then restore: rebuild the instance from a hardened configuration rather than reopening the old one, then restore from the most recent clean backup taken before the exposure window. Validate row counts and application behaviour before reconnecting.
- Assess notification duties: if personal data was exposed, apply your regime's rules (for example the 72-hour regulator notification in GDPR Article 33 where a breach is likely to result in a risk to individuals) with legal advice.
- Close the class of issue: search the rest of the estate for the same pattern (same image, template or team) and add the preventive policy check that would have blocked it.
Backups that survive these campaigns
- Separate the blast radius: backups must not be writable with the database's own credentials or reachable from the same network path. CISA's #StopRansomware Guide recommends offline, encrypted backups because many ransomware variants try to find and delete or encrypt accessible backups.
- Immutability: use object lock or vault lock retention for backup copies. CISA notes that immutable storage is offered by some cloud vendors and cautions that it may not meet every compliance requirement, so check retention rules. See the Backup Security and Immutable Backup Guide.
- Test restores: CISA advises regularly testing the availability and integrity of backups in a disaster recovery scenario. Time a full restore of each critical database at least quarterly and record it.
- Cover the forgotten copies: development and analytics instances holding production data need the same backup and exposure rules, or production data should not be in them.
Detection and measurement
- Monitor: authentication failures and successful logins from unexpected source addresses, bulk drop or delete operations, new databases, indices or collections with names such as
read_me, configuration changes to bind addresses, and network rule changes on database ports. - Metric: internet-reachable database listeners: count from cloud configuration and external monitoring; target zero outside approved exceptions.
- Metric: authentication coverage: percentage of database instances with authentication and access control enabled; target 100 percent.
- Metric: time to close: hours from an exposure finding to verified closure.
- Metric: restore success: percentage of critical databases with a successful timed restore test in the last quarter.
- Metric: policy blocks: number of infrastructure changes blocked for opening database ports, a sign the preventive control is working.
Framework mapping
| Framework | Reference | How it applies |
|---|---|---|
| NIST CSF 2.0 | ID.AM-01, PR.IR-01, PR.PS-01 | Inventory of database assets, network protection, configuration baselines for binding and authentication |
| NIST CSF 2.0 | PR.DS-11, RC.RP-01 | Backups created, protected and tested; recovery executed |
| NIST SP 800-53 Rev 5 | SC-7, CM-6, CM-7, AC-3, CP-9, RA-5 | Boundary protection, configuration settings, least functionality, access enforcement, system backup, vulnerability monitoring and scanning of your own assets |
| MITRE ATT&CK | T1190 Exploit Public-Facing Application | Initial access to internet-facing services |
| MITRE ATT&CK | T1485 Data Destruction, T1486 Data Encrypted for Impact | Wiping data or holding it for ransom |
Common failure patterns
- "It is only test data": a test copy loaded from production is exposed and wiped, and the personal data in it creates a notifiable breach.
- Firewall assumed, not verified: container port publishing or a second network interface bypasses the rule the team relied on.
- Backups on the same credentials: the backup bucket or dump directory is writable with the same account, so the script deletes both.
- Restoring into the same hole: the instance is restored and reopened before the public rule is removed, and is wiped again.
- Trusting the note: the team negotiates for days instead of restoring and investigating what was read.
Practitioner checklist
- Inventory every database engine, managed service and backend-as-a-service project across all accounts.
- Confirm each engine binds to loopback or a private interface, with any public binding documented and approved.
- Turn on authentication and access control on every instance and remove anonymous and default accounts.
- Block 0.0.0.0/0 to database ports and public access on managed databases with policy as code.
- Monitor your own address ranges for database ports and treat findings as priority tickets.
- Keep offline or immutable, encrypted backups under separate credentials and test restores quarterly.
- Write the response sequence (contain, preserve, scope, rotate, rebuild, restore) into the database runbook.
- Rotate any secret stored in a database that was exposed.
Standards and references
- MongoDB: Security Checklist for Self-Managed Deployments
- MongoDB: IP Binding
- PostgreSQL: Connections and Authentication
- Redis: Redis security
- Elastic: Start the Elastic Stack with security enabled automatically
- CISA: #StopRansomware Guide
- Secureworks (Sophos): Unsecured Elasticsearch Data Replaced with Ransom Note
- Trend Micro: Cyberextortionists Wipe Over 12,000 MongoDB Databases
Related NHI Mgmt Group resources: Database Security Guide · Database Breach Response Playbook · Database Credential and Access Security Guide · Backup Security and Immutable Backup Guide