Database security assessment
When it applies
An authorized engagement has a reachable database instance — surfaced by network-service-attacks,
handed over as a review target, or via app credentials recovered from a config dump. Covers
PostgreSQL, MySQL/MariaDB, MSSQL, MongoDB, and Redis. Before touching anything, confirm in
scope.txt (see tradecraft-scope-roe): which instances, which accounts, and whether
write/delete/exec is permitted. On production systems, default to read-only proofs — no
destructive statements unless explicitly allowed.
Why it works
Databases concentrate the crown jewels yet are routinely deployed as "internal-only": bound to
0.0.0.0, default or weak accounts, grants far wider than the app needs, and dangerous features
left enabled. Features like xp_cmdshell, COPY ... FROM PROGRAM, UDFs, and Redis's writable
config turn a mere database login into OS command execution — so an over-privileged app account
is often a quiet path to DBA and then to the host.
Method
- Exposure & transport —
nmap -sV -p 3306,5432,1433,6379,27017 <range>; check bind address,
security groups / firewall rules, and whether TLS is required or enforced. Probe unauthenticated
access: redis-cli -h <ip> ping (PONG = unauth — a finding by itself),
mongosh --host <ip> --eval 'db.runCommand({listDatabases:1})', mysql -h <ip> -u root,
psql -h <ip> -U postgres. nuclei has templates for known exposures.
- Authentication — default/test accounts and weak passwords; for broad guessing use
network-password-spraying discipline (lockouts apply to MSSQL/MySQL too). Record from which
hosts each credential works — host-restricted grants matter for pivoting.
- Authorization & roles — enumerate who can do what:
- MySQL:
SELECT user,host FROM mysql.user; SHOW GRANTS; — flag host '%', FILE, SUPER,
GRANT OPTION.
- Postgres:
\du, SELECT * FROM pg_roles; — flag superuser, pg_read/write_server_files,
pg_execute_server_program.
- MSSQL:
SELECT * FROM sys.server_principals; — flag sysadmin membership for app logins.
Check access control on the sensitive tables, not just server-level roles.
- Dangerous configuration — the login→OS-command bridges:
- MSSQL:
EXEC sp_configure 'xp_cmdshell'; (also Ole Automation / sp_OACreate, CLR).
- MySQL:
secure_file_priv empty, FILE priv, SELECT * FROM mysql.func; for existing UDFs.
- Postgres:
COPY ... FROM PROGRAM, LOAD, untrusted PL languages.
- Redis:
CONFIG GET dir / CONFIG GET dbfilename — writable dir enables the classic
webshell / SSH-key write.
- Audit & resilience — is logging on (MySQL
general_log, pgaudit, SQL Server Audit, MongoDB
--auditDestination)? Who can read backups and snapshots?
- Verify exploit chains safely — where scope allows writes/exec, prove command execution with
a benign command (
id, whoami) and stop. Where it doesn't, report the chain as a configuration
risk with the exact grant/feature that enables it. Use sqlmap only against an in-scope
injection point (→ web-sqli) — never against the DB blindly.
Gotchas
- Distinguish misconfiguration from proven exploitable chain — report both, but only claim
what you demonstrated.
- Redis reachable only through a web SSRF is a different path — use
web-ssrf-gopher-redis-rce.
- Cloud-managed RDS/Azure SQL/Cloud SQL: most issues live in the control plane (public
accessibility, security groups, snapshot sharing, IAM) — review via the provider console and the
cloud-* skills instead of hammering the endpoint.
- MSSQL
xp_cmdshell "disabled" is not safe if the login is sysadmin — enabling it is one command
(and is logged; note the noise in ROE).
- Hashes pulled from
mysql.user or captured in transit feed network-credential-cracking;
app-account → DBA privilege growth often comes from reused passwords, not missing patches.
- Dumping customer data to "prove impact" is over-collection — a version string or one
non-sensitive row proves access.
Verify success
The report states, per instance: network exposure, which credentials work and at what privilege
level, which dangerous features are reachable from the app account, and for every claimed chain a
benign proof (version string, whoami output). Every write/exec step maps to something scope.txt
allowed, and each recommended fix cites the exact grant or setting to change.
References
PayloadsAllTheThings (PostgreSQL/MySQL/MSSQL injection & RCE sections); Redis unauthorized-access
write-ups; vendor hardening guides (CIS benchmarks).
Portions adapted from reverse-skill by zhaoxuya520, MIT License.
1---2name: network-database-security3description: >4 Assess reachable database services — PostgreSQL/MySQL/MSSQL/MongoDB/Redis — for unauthenticated5 access, weak/default accounts, over-broad grants, and dangerous features (xp_cmdshell,6 COPY FROM PROGRAM, UDF, Redis file write) that turn a DB login into OS code execution. Load when7 recon shows 3306/5432/1433/6379/27017, leaked app config yields DB creds, or a database review is8 in scope. Signals: 0.0.0.0 bind, unauth Redis PONG, mysql.user host '%', FILE priv,9 secure_file_priv empty, xp_cmdshell.10domain: network11type: methodology12stability: learning13modes: [pentest]14severity: high15mitre: [T1190, T1078]16cwe: [CWE-306, CWE-284]17tools: [nmap, psql, mysql, sqlcmd, redis-cli, mongosh, sqlmap, nuclei]18schema_version: 119metadata:20 source: https://skillmd.com/skills/noorqureshi/network-database-security21---2223# Database security assessment2425## When it applies26An authorized engagement has a reachable database instance — surfaced by `network-service-attacks`,27handed over as a review target, or via app credentials recovered from a config dump. Covers28PostgreSQL, MySQL/MariaDB, MSSQL, MongoDB, and Redis. Before touching anything, confirm in29`scope.txt` (see `tradecraft-scope-roe`): which instances, which accounts, and **whether30write/delete/exec is permitted**. On production systems, default to read-only proofs — no31destructive statements unless explicitly allowed.3233## Why it works34Databases concentrate the crown jewels yet are routinely deployed as "internal-only": bound to35`0.0.0.0`, default or weak accounts, grants far wider than the app needs, and dangerous features36left enabled. Features like `xp_cmdshell`, `COPY ... FROM PROGRAM`, UDFs, and Redis's writable37config turn a mere database login into OS command execution — so an over-privileged *app* account38is often a quiet path to DBA and then to the host.3940## Method411. **Exposure & transport** — `nmap -sV -p 3306,5432,1433,6379,27017 <range>`; check bind address,42 security groups / firewall rules, and whether TLS is required or enforced. Probe unauthenticated43 access: `redis-cli -h <ip> ping` (`PONG` = unauth — a finding by itself),44 `mongosh --host <ip> --eval 'db.runCommand({listDatabases:1})'`, `mysql -h <ip> -u root`,45 `psql -h <ip> -U postgres`. `nuclei` has templates for known exposures.462. **Authentication** — default/test accounts and weak passwords; for broad guessing use47 `network-password-spraying` discipline (lockouts apply to MSSQL/MySQL too). Record *from which48 hosts* each credential works — host-restricted grants matter for pivoting.493. **Authorization & roles** — enumerate who can do what:50 - MySQL: `SELECT user,host FROM mysql.user;` `SHOW GRANTS;` — flag host `'%'`, `FILE`, `SUPER`,51 `GRANT OPTION`.52 - Postgres: `\du`, `SELECT * FROM pg_roles;` — flag superuser, `pg_read/write_server_files`,53 `pg_execute_server_program`.54 - MSSQL: `SELECT * FROM sys.server_principals;` — flag sysadmin membership for app logins.55 Check access control on the sensitive tables, not just server-level roles.564. **Dangerous configuration** — the login→OS-command bridges:57 - MSSQL: `EXEC sp_configure 'xp_cmdshell';` (also Ole Automation / `sp_OACreate`, CLR).58 - MySQL: `secure_file_priv` empty, `FILE` priv, `SELECT * FROM mysql.func;` for existing UDFs.59 - Postgres: `COPY ... FROM PROGRAM`, `LOAD`, untrusted PL languages.60 - Redis: `CONFIG GET dir` / `CONFIG GET dbfilename` — writable dir enables the classic61 webshell / SSH-key write.625. **Audit & resilience** — is logging on (MySQL `general_log`, `pgaudit`, SQL Server Audit, MongoDB63 `--auditDestination`)? Who can read backups and snapshots?646. **Verify exploit chains safely** — where scope allows writes/exec, prove command execution with65 a benign command (`id`, `whoami`) and stop. Where it doesn't, report the chain as a configuration66 risk with the exact grant/feature that enables it. Use `sqlmap` only against an in-scope67 injection point (→ `web-sqli`) — never against the DB blindly.6869## Gotchas70- Distinguish **misconfiguration** from **proven exploitable chain** — report both, but only claim71 what you demonstrated.72- Redis reachable only through a web SSRF is a different path — use `web-ssrf-gopher-redis-rce`.73- Cloud-managed RDS/Azure SQL/Cloud SQL: most issues live in the *control plane* (public74 accessibility, security groups, snapshot sharing, IAM) — review via the provider console and the75 `cloud-*` skills instead of hammering the endpoint.76- MSSQL `xp_cmdshell` "disabled" is not safe if the login is sysadmin — enabling it is one command77 (and is logged; note the noise in ROE).78- Hashes pulled from `mysql.user` or captured in transit feed `network-credential-cracking`;79 app-account → DBA privilege growth often comes from reused passwords, not missing patches.80- Dumping customer data to "prove impact" is over-collection — a version string or one81 non-sensitive row proves access.8283## Verify success84The report states, per instance: network exposure, which credentials work and at what privilege85level, which dangerous features are reachable from the *app* account, and for every claimed chain a86benign proof (version string, `whoami` output). Every write/exec step maps to something `scope.txt`87allowed, and each recommended fix cites the exact grant or setting to change.8889## References90PayloadsAllTheThings (PostgreSQL/MySQL/MSSQL injection & RCE sections); Redis unauthorized-access91write-ups; vendor hardening guides (CIS benchmarks).9293---94_Portions adapted from [reverse-skill](https://github.com/zhaoxuya520/reverse-skill) by zhaoxuya520, MIT License._