Principle of least privilege for database and service accounts
Why it matters
Applications running with database superuser or admin credentials mean any SQL injection, code execution, or insider query can drop tables, read all data, or modify any row without restriction. CWE-272 (Least Privilege Violation) and OWASP A01 (Broken Access Control) cover this. NIST 800-53 AC-6 mandates least-privilege for all system accounts. A postgres root connection string in DATABASE_URL means a single RCE or injection turns into a full database wipe. API keys scoped to all operations mean one leaked key — from logs, from a debug endpoint, from a shoulder-surf — gives an attacker full service access.
Severity rationale
Low because least-privilege violations don't introduce a vulnerability themselves, but they dramatically amplify the blast radius when any other control fails.
Remediation
Create a dedicated database user with only the permissions the application actually needs:
CREATE USER app_user WITH PASSWORD 'strong_password';
GRANT CONNECT ON DATABASE mydb TO app_user;
GRANT USAGE ON SCHEMA public TO app_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO app_user;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO app_user;
-- Do NOT grant: CREATE, DROP, ALTER, TRUNCATE, or pg_superuser
For Stripe, use the Stripe Dashboard to create restricted API keys scoped only to the operations your server performs (e.g., charges:write only, not customers:read_write). Store the restricted key in STRIPE_SECRET_KEY, not the full secret key.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Security Hardening Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-272 — Least Privilege Violation
- owasp:2021 · A01 — Broken Access Control
- nist:rev5 · AC-6 — Least Privilege
Taxons
History
- 2026-04-18·v1.0.0·Initial import from security-hardening·automated