CCyberwiki

Publicly exposed database

Publicly exposed database
ClassSecurity misconfiguration
Also known asOpen database, unsecured database
CWECWE-1327: Binding to an Unrestricted IP Address
OWASP Top 10A02:2025 Security Misconfiguration
Typical severityCritical
AffectsPostgres, MongoDB, Redis and Elasticsearch on self-managed servers and in Docker; managed databases with no address restrictions

A database server that accepts connections on its network port from any address on the internet is a publicly exposed database. Anyone who finds the address can try to sign in. Where the database has no password or a weak one, that person can read, change or delete what it holds.

Description

Three settings decide whether a database can be reached from outside. One is the address the database listens on. A server can listen on one network interface or on all of them; the address 0.0.0.0 means every IPv4 interface, which "might be much broader access than intended".1 A firewall between the server and the internet comes next, dropping traffic to ports that are not meant to be public. Last comes authentication: the database checks a user name and password, or another credential, before it runs any command.

A database is exposed when the first two settings let outside traffic through. The password then becomes the only barrier, and some database systems accept connections with no password at all. Postgres limits listening to the loopback address address by default (listen_addresses = 'localhost'), and so do MongoDB's mongod and mongos.23 On these systems, exposure follows a change from the defaults: a value of * or 0.0.0.0 set so that another machine could connect, a container port published without an address, or a cloud firewall rule opened to every address. The OWASP Top 10:2025 counts open ports and services of this kind as Security Misconfiguration (A02).4

Mechanism

One common path runs through Docker. A developer starts Postgres in a container and publishes its port so that a desktop database tool can connect:

docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres

Docker's documentation states that publishing container ports "is insecure by default": the port opens on every address of the host, including its public one.5 On Ubuntu, the server's own firewall, ufw, does not stop this. Docker rewrites the destination of container traffic in the nat table, before the packets reach the INPUT and OUTPUT chains where ufw applies its rules, so a ufw rule that denies port 5432 has no effect on the published port.6 Port 5432 is the Postgres default,2 and the container above has the password postgres.

A Postgres server also reads pg_hba.conf, a list of rules matched in order against each connection. A rule with the method trust lets anyone who can connect sign in as any database user with no password.7 Combined with a public listening address, such a rule gives the whole internet full access.

Table 1. Default network behaviour as stated in each project's documentation
SoftwareDefaultSetting that opens it
PostgresListens on localhost, port 5432listen_addresses = '*' or '0.0.0.0'
MongoDBBinds to localhostBind address 0.0.0.0, --bind_ip_all
Redis 3.2.0 and laterBinds all interfaces; with no password, protected mode answers only loopback clientsTurning protected mode off
Docker -pPublishes on every host addressAny port mapping without 127.0.0.1: in front
SupabaseAll addresses can connect to Postgres and the pooler until restrictions are appliedLeaving Network Restrictions empty

Impact

An attacker who signs in has the rights of the database account used. A trust rule lets the attacker pick any database user, including the most privileged one. On Redis, one FLUSHALL command from an outside client deletes the whole data set.8

Exposed databases are found by scanning, with no need to know the application. In July 2020 an attack known as Meow deleted more than 1,000 databases that accepted changes without credentials. At the time of the report, the Shodan search engine listed 987 Elasticsearch and 70 MongoDB instances wiped, with the word "meow" left in place of the data and no ransom demand.9 Other attacks on unsecured databases are run for money, as Ransomware and data destruction.9

Notable incidents

On 5 December 2019 a change to the network security group of an internal Microsoft customer support database introduced rules that exposed it to the internet. Microsoft restricted access again on 31 December, after a report from security researcher Bob Diachenko, and wrote that protections which would have prevented the error "were not enabled for this database".10 The data, about 250 million support records, sat on five Elasticsearch clusters. Most personal details had been removed by automated redaction, but records in non-standard formats still held customer email and IP addresses, locations and case descriptions.1110

Detection

On a self-managed server, read the listening address in each database's configuration: listen_addresses in postgresql.conf, the bind address of MongoDB, and whether Redis runs with protected mode. In Docker Compose files and docker run commands, any database port mapping that does not start with 127.0.0.1: is published on every address. Rules in pg_hba.conf with the method trust on a host line accept remote connections without a password.

On Supabase, supabase network-restrictions get --remote={ref} --experimental prints the allowed ranges. Empty lists with Restrictions applied successfully: false mean every address can connect.12

Prevention

Self-managed Postgres

Keep the default listening address when the application runs on the same machine. Where another machine must connect, allow only its address in pg_hba.conf and require an encrypted connection and a SCRAM password:7

# postgresql.conf
listen_addresses = 'localhost'

# pg_hba.conf: TYPE  DATABASE  USER  ADDRESS  METHOD
hostssl  appdb  appuser  203.0.113.10/32  scram-sha-256

Docker

Publish a database port to the loopback address only, so that the host can reach it and the internet cannot:5

docker run -d -p 127.0.0.1:5432:5432 postgres

Docker versions before 28.0.0 let machines on the same local network segment reach ports published to localhost.5

Redis and MongoDB

On a cloud server, firewall the Redis port from outside access. Redis also enters protected mode when it is bound to all interfaces with no password.8 Keep MongoDB reachable only on trusted networks, and on a machine with more than one interface, bind it to the private one.3

Supabase

Under Database Settings, the Network Restrictions section limits which CIDR ranges may connect to Postgres and its pooler. The rules are enforced before traffic reaches the database, and each update replaces the previous list. They do not cover the HTTPS APIs (PostgREST, Storage, Auth) or supabase-js, which row level security protects instead.12

supabase network-restrictions update --remote={ref} \
  --db-allow-cidr 203.0.113.10/32 --experimental

Prompt for a coding agent

Find every place in this project that starts or configures a database: docker-compose files, Dockerfiles, docker run commands, postgresql.conf, pg_hba.conf, mongod.conf, redis.conf and deployment scripts. For each database port, report whether it is published or listens on all addresses (0.0.0.0, *, ::, or a Docker port mapping with no address in front). Change Docker port mappings to 127.0.0.1:PORT:PORT, or remove them where only other containers connect. Replace any trust method in pg_hba.conf with scram-sha-256 and hostssl. Do not change passwords or delete data. List each file and line you changed and each database that still accepts outside connections.

In SecFlash

The Server page reports a risky service open to the internet (SF-SRV-101), a port that listens on every address and answers from outside (SF-SRV-102) and a port open on IPv6 only (SF-SRV-104); the Security page reports risky ports open (SF-SEC-302). On the Cloud page, SecFlash reports a Hetzner server or DigitalOcean Droplet with no firewall (SF-CLD-101, SF-CLD-201), a firewall rule that opens a risky port to everyone (SF-CLD-102, SF-CLD-203), a database that accepts any address on Supabase (SF-CLD-527), Render (SF-CLD-021, SF-CLD-804) and DigitalOcean (SF-CLD-207), a Railway database behind a TCP proxy (SF-CLD-041) and a Compose file that publishes a database port to every address (SF-CLD-908).

See also

References

  1. back MITRE. "CWE-1327: Binding to an Unrestricted IP Address". Common Weakness Enumeration.
  2. a b "Connections and Authentication". PostgreSQL Documentation. PostgreSQL Global Development Group.
  3. a b "IP Binding in Self-Managed Deployments". MongoDB Database Manual. MongoDB.
  4. back "A02:2025 Security Misconfiguration". OWASP Top 10:2025. OWASP Foundation.
  5. a b c "Port publishing and mapping". Docker Docs. Docker.
  6. back "Packet filtering and firewalls". Docker Docs. Docker.
  7. a b "The pg_hba.conf File". PostgreSQL Documentation. PostgreSQL Global Development Group.
  8. a b "Redis security". Redis Docs. Redis.
  9. a b Goodin, Dan (22 July 2020). "Ongoing Meow attack has nuked >1,000 databases without telling anyone why". Ars Technica.
  10. a b MSRC Team (22 January 2020). "Access Misconfiguration for Customer Support Database". Microsoft Security Response Center. Read from the Internet Archive copy.
  11. back Gatlan, Sergiu (22 January 2020). "Microsoft Exposes 250M Customer Support Records on Leaky Servers". BleepingComputer.
  12. a b Supabase (updated 16 November 2026). "Network Restrictions". Supabase Docs.