The database holds the value: every record, every credential hash, every transaction. It is routinely the least-hardened tier in the stack. Perimeter security gets budget and headlines; the datastore gets stood up during a sprint, wired to the app with a single all-access account, and never revisited. Attackers know this. By the time they reach the database, most of the defensive spend is already behind them.
Database hardening means closing a familiar set of gaps that accumulate because the database "just works." The account the app uses is over-privileged. Network access is broader than anyone documented. Nobody is logging who ran which query. Backups are less protected than the live data. And credentials sit in a config file that half the team can read. None of these is exotic. All of them show up in breach reports.
Least privilege, applied to the app account
The most consequential database control is also the most neglected: the application does not need to connect as an owner or admin. It needs to read and write specific tables. Yet the common default is one account with full DDL rights, shared by every service, with a password that is never rotated. When that account leaks (from a compromised app server, a logged connection string or an SSRF into the metadata service), the attacker inherits the entire database, including the ability to drop tables and disable logging.
- Separate accounts by job. The app reads and writes through a least-privilege role; migrations run under a separate, tightly-controlled identity; analytics gets read-only replicas. One account for everything is one credential to lose.
- Pull credentials from a secrets manager, not a config file. Static passwords in environment files and repos are the most common way database access leaks. Short-lived, brokered credentials remove the standing secret entirely.
- Constrain the network. The database should accept connections only from the app tier, never from the open internet or a flat internal network. ‘Reachable from anywhere inside’ is how a single foothold becomes a data breach.
- Encrypt at rest and in transit. TLS on every connection, storage encryption tied to a managed key, and no plaintext replication links between regions.
- Log access to sensitive tables. You cannot investigate data theft you never recorded. Query-level auditing on the tables that matter turns 'we think' into 'we know'.
The parts that get skipped
Two areas hide the ugliest surprises. Backups are often stored with weaker access controls than the live database. An unencrypted dump in a loosely permissioned bucket is a full copy of your data with none of the runtime protections. And audit logging is usually off or minimal, because teams see it as a performance cost, so when you need to know what an attacker read, there is no answer. Both are cheap to fix and expensive to miss.
Databases fail quietly. No alert fires when an app account has too many rights or a backup sits unencrypted; the first sign is the breach, months later. Hardening the datastore is unglamorous maintenance that pays off on the day someone attacks it. You also cannot harden databases you forgot you were running: the shadow instance a team spun up for a project is the one still on defaults.