Database Security (Security Review Lens)
Purpose
Verify the data store's security posture actually holds against attack: least-privilege access, no network exposure, an injection-free data layer, encryption of sensitive data, real tenant isolation, and disciplined PII handling. The build-side design is ../../database/database-security; this security-pack skill is the review/audit lens on it, feeding ../../security-review.
When to Use
- Auditing database security, in
../../security-review or threat-modeling data-disclosure threats.
- Not for designing the data-layer hardening (
../../database/database-security) — this verifies it.
Inputs
- The database security design/implementation (
../../database/database-security).
- Data-sensitivity map, tenancy model, deployment topology.
Discovery Questions
- What privileges does the app's runtime account actually hold — CRUD-only, or DDL/superuser it doesn't need?
- Is the database network-reachable from anywhere beyond the app (public listener, exposed port)?
- Is the data layer parameterized-only, or are there raw/string-built queries (incl. Mongo operator injection)?
- What sensitive data exists, is it encrypted appropriately, and does account deletion truly remove PII?
Responsibilities
- Least privilege: confirm the runtime account is CRUD-scoped (no DDL/superuser); migrations use a separate account; human/analytics access is limited and audited (
../../database/database-security).
- Network exposure: confirm private-network-only, TLS-enforced, no public listener — an internet-reachable database is a critical finding.
- Injection surface: audit for parameterized-only access; flag string-built SQL and unvalidated object/operator injection in NoSQL (
../../backend/backend-validation blocks {$gt:''}-shaped input); overlaps with api-security.
- Encryption: sensitive data encrypted at rest, TLS in transit, and application-level field encryption for the truly sensitive (tokens, stored user secrets) with key management (
secrets-audit).
- Tenant isolation depth: confirm scoped queries are enforced (
authorization-security, ../../backend/ownership-authorization) and evaluate whether the risk profile warrants DB-enforced isolation (row-level security / per-tenant schemas).
- PII discipline: no PII in logs/backups/dev seeds (
privacy-review, ../../testing/test-data-management); retention + tested deletion paths exist.
- Route findings to fixes + regression tests (
security-regression-testing).
Required Workflow
- Review account privileges (runtime, migration, human, analytics).
- Verify network isolation + TLS.
- Audit the data layer for injection (SQL + NoSQL operator).
- Verify encryption per data class + key management.
- Assess tenant-isolation depth + PII handling/deletion.
- Record findings; route to fixes + regression tests.
Decision Rules
- Public-reachable database or app-account-with-DDL/superuser = confirmed high-severity findings.
- Any string-built query is an injection finding regardless of "trusted" input.
- Field-level encryption is for data whose leak survives a full dump — verify it's applied where the sensitivity demands, not encrypt-everything-into-mush.
- Real production data in any lower environment is a finding (
privacy-review).
Rules
- Never print secrets or real data during the audit — location + severity only.
- Findings separated Confirmed vs Potential; never declare "secure" (
../../security-review).
- Each finding maps to a fix + regression test; delegate build-side design to
../../database/database-security.
Anti-Patterns
- Passing a database on a public IP.
- App connecting as owner/superuser "temporarily forever."
- The one legacy raw query nobody re-checks for injection.
- "Encrypted at rest" (disk) presented as answering field-sensitivity.
- PII in logs, backups, and dev seeds; deletion that flips a boolean.
Validation Checklist
Definition of Done
A recorded database security audit — access privileges, network exposure, injection surface, encryption, tenant isolation, PII handling — with Confirmed/Potential findings routed to fixes and regression tests, delegating build-side design to the database pack, and no "secure" claim.
Related Skills
../../database/database-security, authorization-security, ../../backend/ownership-authorization, api-security, secrets-audit, privacy-review, ../../testing/test-data-management, security-regression-testing, ../../security-review, threat-modeling.
Related Knowledge
../../../knowledge/ (data classes, tenancy model, topology).
Related References
../../../references/security/ (database review checklists, when populated).
Context Loading Guidance
- Requires: the database security design/impl, sensitivity map, topology.
- Does not require: re-designing the hardening (delegate), app feature code.
- May load:
../../database/database-security, authorization-security.
- Stop when: findings + routed fixes/tests are recorded.
Token Efficiency Guidance
The finding table (area → issue → severity → fix) is the artifact; never echo real data or secrets. Delegate build design rather than restating it.
1---2name: database-security-23description: Use to review database security from an audit/threat lens — least-privilege access, network exposure, injection surface, encryption of sensitive data, tenant isolation depth, and PII handling — verifying the data-layer hardening holds. The security-review lens; the database pack owns the build-side design.4---56# Database Security (Security Review Lens)78## Purpose910Verify the data store's security posture actually holds against attack: least-privilege access, no network exposure, an injection-free data layer, encryption of sensitive data, real tenant isolation, and disciplined PII handling. The **build-side design** is `../../database/database-security`; this security-pack skill is the **review/audit lens** on it, feeding `../../security-review`.1112## When to Use1314- Auditing database security, in `../../security-review` or `threat-modeling` data-disclosure threats.15- **Not** for designing the data-layer hardening (`../../database/database-security`) — this verifies it.1617## Inputs1819- The database security design/implementation (`../../database/database-security`).20- Data-sensitivity map, tenancy model, deployment topology.2122## Discovery Questions2324- What privileges does the **app's runtime account** actually hold — CRUD-only, or DDL/superuser it doesn't need?25- Is the database **network-reachable** from anywhere beyond the app (public listener, exposed port)?26- Is the data layer **parameterized-only**, or are there raw/string-built queries (incl. Mongo operator injection)?27- What sensitive data exists, is it **encrypted** appropriately, and does account deletion truly remove PII?2829## Responsibilities3031- **Least privilege**: confirm the runtime account is CRUD-scoped (no DDL/superuser); migrations use a separate account; human/analytics access is limited and audited (`../../database/database-security`).32- **Network exposure**: confirm private-network-only, TLS-enforced, no public listener — an internet-reachable database is a critical finding.33- **Injection surface**: audit for parameterized-only access; flag string-built SQL and unvalidated object/operator injection in NoSQL (`../../backend/backend-validation` blocks `{$gt:''}`-shaped input); overlaps with `api-security`.34- **Encryption**: sensitive data encrypted at rest, TLS in transit, and application-level field encryption for the truly sensitive (tokens, stored user secrets) with key management (`secrets-audit`).35- **Tenant isolation depth**: confirm scoped queries are enforced (`authorization-security`, `../../backend/ownership-authorization`) and evaluate whether the risk profile warrants DB-enforced isolation (row-level security / per-tenant schemas).36- **PII discipline**: no PII in logs/backups/dev seeds (`privacy-review`, `../../testing/test-data-management`); retention + tested deletion paths exist.37- Route findings to fixes + regression tests (`security-regression-testing`).3839## Required Workflow40411. Review account privileges (runtime, migration, human, analytics).422. Verify network isolation + TLS.433. Audit the data layer for injection (SQL + NoSQL operator).444. Verify encryption per data class + key management.455. Assess tenant-isolation depth + PII handling/deletion.466. Record findings; route to fixes + regression tests.4748## Decision Rules4950- Public-reachable database or app-account-with-DDL/superuser = confirmed high-severity findings.51- Any string-built query is an injection finding regardless of "trusted" input.52- Field-level encryption is for data whose leak survives a full dump — verify it's applied where the sensitivity demands, not encrypt-everything-into-mush.53- Real production data in any lower environment is a finding (`privacy-review`).5455## Rules5657- Never print secrets or real data during the audit — location + severity only.58- Findings separated Confirmed vs Potential; never declare "secure" (`../../security-review`).59- Each finding maps to a fix + regression test; delegate build-side design to `../../database/database-security`.6061## Anti-Patterns6263- Passing a database on a public IP.64- App connecting as owner/superuser "temporarily forever."65- The one legacy raw query nobody re-checks for injection.66- "Encrypted at rest" (disk) presented as answering field-sensitivity.67- PII in logs, backups, and dev seeds; deletion that flips a boolean.6869## Validation Checklist7071- [ ] Least-privilege accounts verified (runtime/migration/human/analytics).72- [ ] Network private + TLS; no public listener.73- [ ] Parameterized-only data layer (SQL + NoSQL) verified.74- [ ] Encryption per class + key management confirmed.75- [ ] Tenant-isolation depth assessed; PII handling/deletion verified.76- [ ] Findings → fixes → regression tests.7778## Definition of Done7980A recorded database security audit — access privileges, network exposure, injection surface, encryption, tenant isolation, PII handling — with Confirmed/Potential findings routed to fixes and regression tests, delegating build-side design to the database pack, and no "secure" claim.8182## Related Skills8384`../../database/database-security`, `authorization-security`, `../../backend/ownership-authorization`, `api-security`, `secrets-audit`, `privacy-review`, `../../testing/test-data-management`, `security-regression-testing`, `../../security-review`, `threat-modeling`.8586## Related Knowledge8788`../../../knowledge/` (data classes, tenancy model, topology).8990## Related References9192`../../../references/security/` (database review checklists, when populated).9394## Context Loading Guidance9596- **Requires:** the database security design/impl, sensitivity map, topology.97- **Does not require:** re-designing the hardening (delegate), app feature code.98- **May load:** `../../database/database-security`, `authorization-security`.99- **Stop when:** findings + routed fixes/tests are recorded.100101## Token Efficiency Guidance102103The finding table (area → issue → severity → fix) is the artifact; never echo real data or secrets. Delegate build design rather than restating it.