Database Service Exposed to Untrusted Networks
A database server accepts connections from networks that have no need to reach it, so anyone there can attempt to log in or exploit flaws in the database service.
| Severity | Medium |
| CVSS 3.1 | 5.6 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L Open in the calculator |
| CVSS 4.0 | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-1327: Binding to an Unrestricted IP Address |
| MITRE ATT&CK | T1110.001 Password Guessing, T1190 Exploit Public-Facing Application, T1210 Exploitation of Remote Services |
| Category | Security Misconfiguration |
Description
The database service listens on a network interface that can be reached from networks with no need to connect to it, such as the internet, user or guest networks, or a third-party connection. Database servers are meant to be reached only by the application servers and administrators that use them, but they are often configured to accept connections on every interface, and the firewall rules in front of them do not narrow this down.
An attacker who can reach the service can try to guess or reuse passwords for database accounts, including built-in administrative accounts such as sa, root or postgres, and can target any unpatched vulnerability in the database's network listener without first compromising another system. A successful login gives direct access to the data the account can reach, and administrative database accounts can often read files or run operating system commands on the server.
This finding covers the network exposure of a service that still requires authentication. Missing or weak credentials and missing security updates are reported separately where found, but each is far easier to exploit when the service can be reached directly, so the risk is higher where the service is reachable from the internet or where weak credentials or missing patches are present, and lower where strong authentication, encrypted connections and current security updates are in place.
The exposure is identified by port scanning from the untrusted network and confirming the service with a protocol handshake, for example Microsoft SQL Server on TCP 1433, MySQL and MariaDB on TCP 3306, PostgreSQL on TCP 5432 or an Oracle Database listener on TCP 1521. Scanners usually report the service with its version, and several database protocols disclose the version or instance names before any login takes place.
Remediation
Make the database reachable only from the systems that need it:
- Bind the service to the specific internal interface it needs, or to the loopback interface where the application runs on the same host, rather than to every interface. Examples are
listen_addressesin PostgreSQL'spostgresql.confandbind_addressin the MySQL or MariaDB server configuration. - Restrict the database port with network and host firewall rules so that only the application servers and named administration hosts can connect, and place database servers in a dedicated network segment.
- Use the database's own client access rules as a second layer, for example host-based entries in PostgreSQL's
pg_hba.conf, and require encrypted connections. - Administer databases from a management network or jump host rather than widening access, and use strong, unique passwords for every database account.
As an interim measure, block the port at the perimeter and on internal firewalls for every network without a business need. Confirm the fix by repeating the port scan from each untrusted network and checking that the service no longer responds.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.