tadata
Back to home

Database Security: Defense in Depth for Your Most Valuable Asset

#security#databases#encryption#compliance#governance

Databases are where the crown jewels live -- customer data, financial records, health information, intellectual property. A breach at the database layer is the worst-case scenario for any organization. Database security requires defense in depth: multiple overlapping layers, each capable of stopping an attacker who has bypassed the layer above.

Security Layer Taxonomy

Database Security Layers
├── Network Layer
│   ├── Private subnets (no public IP)
│   ├── Security groups / firewall rules
│   ├── VPC peering / PrivateLink
│   ├── TLS for all connections
│   └── IP allowlisting for admin access
├── Authentication Layer
│   ├── IAM-based authentication (AWS RDS IAM, GCP IAM)
│   ├── Certificate-based (mTLS)
│   ├── LDAP / Active Directory integration
│   ├── Short-lived credentials (Vault dynamic secrets)
│   └── Multi-factor for admin access
├── Authorization Layer
│   ├── Role-based access control (RBAC)
│   ├── Row-level security (RLS)
│   ├── Column-level permissions
│   ├── Schema-level isolation
│   └── View-based data masking
├── Encryption Layer
│   ├── At-rest (TDE, volume encryption)
│   ├── In-transit (TLS 1.3)
│   ├── Field-level / column-level encryption
│   ├── Client-side encryption
│   └── Key management (KMS, Vault Transit)
├── Audit Layer
│   ├── Query logging (pgaudit, MySQL audit plugin)
│   ├── Connection logging
│   ├── Schema change tracking
│   ├── Data access monitoring (DAM)
│   └── Alerting on anomalous queries
└── Backup & Recovery Layer
    ├── Encrypted backups
    ├── Cross-region replication
    ├── Point-in-time recovery (PITR)
    ├── Backup access controls
    └── Regular restore testing

Encryption Comparison

AspectAt-Rest (TDE / Volume)In-Transit (TLS)Field-Level / ColumnClient-Side
Protects againstPhysical theft, disk accessNetwork sniffing, MITMDBA access, SQL injection exfiltrationAll server-side threats
Performance impactMinimal (hardware AES)Low (TLS 1.3 is fast)Moderate (per-field ops)High (app-level crypto)
Key managementCloud KMS / HSMCertificate managementApp-managed or KMSApp-managed
SearchableYes (transparent)Yes (transparent)No (unless using searchable encryption)No
ComplianceBaseline requirementBaseline requirementPCI DSS, HIPAA for sensitive fieldsMaximum data sovereignty
ImplementationToggle on managed DBEnforce sslmode=requireApplication code changesApplication code changes
Who can read dataAnyone with DB accessAnyone with DB accessOnly key holdersOnly key holders

Access Control Model Comparison

ModelDescriptionGranularityComplexityBest For
RBAC (Role-Based)Permissions assigned to roles, users assigned to rolesTable / schema levelLowMost applications, clear role hierarchies
ABAC (Attribute-Based)Policies evaluate attributes (user, resource, environment)Field / row levelHighComplex multi-tenant, dynamic policies
Row-Level SecurityDatabase enforces per-row visibilityRow levelMediumMulti-tenant SaaS, data isolation
Column-LevelPermissions on specific columnsColumn levelMediumPII protection, mixed sensitivity
View-Based MaskingViews expose masked/filtered dataFlexibleLowReporting, analytics access

Compliance Mapping

Control AreaSOC 2 (TSC)HIPAAPCI DSS 4.0GDPR
Encryption at restCC6.1164.312(a)(2)(iv)Req 3.5Art. 32
Encryption in transitCC6.1164.312(e)(1)Req 4.2Art. 32
Access controlCC6.1, CC6.3164.312(a)(1)Req 7, 8Art. 25, 32
Audit loggingCC7.1, CC7.2164.312(b)Req 10Art. 30
Backup/recoveryA1.2164.308(a)(7)Req 12.10Art. 32
Data classificationCC6.1164.312(a)(1)Req 3.2Art. 30, 35
Vulnerability mgmtCC7.1164.308(a)(5)Req 6, 11Art. 32
Incident responseCC7.3, CC7.4164.308(a)(6)Req 12.10Art. 33, 34

Database Security Maturity Model

LevelNameCharacteristics
1BasicDefault credentials changed, TLS enabled, backups exist.
2StandardRBAC implemented, audit logging enabled, encryption at rest.
3HardenedRLS/ABAC, field-level encryption for PII, dynamic credentials via Vault.
4ProactiveContinuous vulnerability scanning, query anomaly detection, automated rotation.
5AdvancedClient-side encryption, formal data classification, automated compliance reporting, chaos testing on recovery.

Strategic Recommendations

Network isolation is non-negotiable. Databases must never have public IPs. Use VPC PrivateLink or peering. Even within a VPC, use security groups to restrict access to specific application subnets.

Eliminate long-lived credentials. Use Vault dynamic secrets or IAM-based database authentication. Every credential should have a TTL measured in hours, not months.

Row-level security for multi-tenant. If you run a SaaS platform, implement RLS at the database layer -- not just in application code. Application bugs should not be able to expose one tenant's data to another.

Audit everything, alert on anomalies. Enable pgaudit (PostgreSQL) or the audit plugin (MySQL). Feed audit logs into your SIEM. Alert on unusual patterns: bulk exports, after-hours admin access, new query patterns.

Test your backups. An untested backup is not a backup. Schedule monthly restore tests. Verify that PITR works within your RTO/RPO targets.

Resources

:::