COMP 6660 · Lesson 5.4 Database Security

Module 2 · Unit 5 · Lesson 5.4

COMP 6660 · Enterprise Cybersecurity Database Security

Applications process data; databases hold it. This lesson examines the discipline of protecting the enterprise's data stores — the controls through which access to data is governed, the data itself is protected, and activity is monitored.

Reading time: ~110 minutes Activities: 3 Unit 5 · Lesson 4 of 8

00 Introduction

Lesson 5.3 examined application security — the software that delivers enterprise services. This lesson examines database security — the discipline of protecting the data stores on which applications depend, and which hold the enterprise's most sensitive information.

Databases are the destination. Applications process data; users interact with data through applications; but the data itself resides in databases and data stores. When an adversary accesses a database, they gain access to the data — customer records, financial information, intellectual property, personal data, and everything else the enterprise holds. Many of the most consequential breaches have been, at their core, database breaches — unauthorized access to the enterprise's data.

Database security is a distinct discipline because databases present distinct security considerations. Databases have their own access-control models — separate from application and operating-system access control. Databases store data in specific ways that require specific encryption approaches. Databases generate specific logs and audit trails that support detection and investigation. Databases interact with applications, with users, with other systems, and with cloud services — through interfaces that each require protection. And databases frequently hold data that is subject to specific regulatory requirements, which shape the controls that must be applied.

This lesson examines database security in detail. It establishes why database security matters. It examines the database attack surface — the interfaces, components, and data that databases expose. It examines database access control — the models through which access to data is governed. It examines encryption — protecting data at rest, in transit, and in use. It examines auditing and monitoring — detecting what happens in databases. It examines data masking and privacy controls — protecting sensitive data within databases. It examines database hardening and configuration. It examines backup, recovery, and integrity. It examines the specific considerations of cloud databases and data services. And it closes with the pitfalls that recur across database security programmes.

The material here builds on the application security material from Lesson 5.3 — applications and databases are closely coupled, and the security of one affects the other. It connects to the data-protection material from Module 1 — encryption, access control, and classification. It prepares for the cloud security material in Lesson 5.5, where managed database services and cloud data stores are examined in the context of the shared responsibility model.

How to read this lesson

Sections 1–2 establish the framing and the attack surface. Sections 3–7 examine the principal database security controls. Section 8 examines backup and integrity. Section 9 examines cloud databases. Section 10 addresses the pitfalls. If you are short on time, read Sections 3, 4, and 5 carefully — access control, encryption, and auditing are the most consequential controls for enterprise practice and for the assessment.

01 Learning objectives

By the end of this lesson you should be able to:

Lesson objectives

  • Explain why database security matters and how it relates to application, platform, and infrastructure security.
  • Describe the database attack surface — the interfaces, components, and data through which databases can be attacked.
  • Apply database access control — database roles, privileges, and account management.
  • Explain database encryption — at rest, in transit, and in use — and the role of key management.
  • Describe database auditing and monitoring — what to log, how to protect logs, and how to monitor for anomalies.
  • Evaluate data masking, tokenisation, and other privacy controls.
  • Apply database hardening and configuration principles.
  • Explain database backup, recovery, and integrity controls.
  • Analyse the specific considerations of cloud databases and data services.
  • Identify common enterprise pitfalls in database security programmes.

These objectives contribute to Unit 5 outcome U5.1 (secure infrastructure), and to Module 2 outcome M2.8. See the Unit 5 learning outcomes page for the full mapping.

02 Why database security matters

Databases hold the enterprise's most valuable asset — its data. They are the destination that adversaries seek and the object that regulation protects. Understanding why database security matters clarifies the priorities that inform the rest of this lesson.

Databases hold enterprise data

  • Customer records, financial information, intellectual property, personal data, operational data — the enterprise's most valuable information resides in databases.
  • When an adversary accesses a database, they gain access to the data — the object of most enterprise attacks.
  • Database security is the last line of defence for enterprise data — the controls that protect the data itself, regardless of how the adversary reached the database.

Databases are targeted directly

  • Adversaries target databases directly — through database vulnerabilities, through compromised database credentials, through exposed database services.
  • Databases are frequently exposed — through misconfiguration, through internet-facing services, through cloud services with permissive access.
  • Many breaches have involved direct database compromise — through stolen credentials, through unpatched database software, through misconfigured cloud databases.

Databases are subject to regulation

  • Personal data, financial data, health data, and other regulated data are frequently held in databases.
  • Regulatory requirements — privacy, sectoral, breach notification — shape the controls that must be applied to databases holding regulated data.
  • Compliance obligations often drive database security investment — access controls, encryption, auditing.

Databases are complex and diverse

  • Enterprises operate multiple database platforms — relational, NoSQL, data warehouses, data lakes, and others — each with its own security model.
  • Databases are frequently coupled with applications — through application accounts — producing access paths that span both.
  • The diversity of database platforms multiplies the management burden — each requires its own tools, its own baselines, and its own expertise.

Databases are central to enterprise operations

  • Enterprise operations depend on databases — transactions, reporting, analytics, decision-making.
  • Compromise or unavailability of databases affects enterprise operations — sometimes catastrophically, as in ransomware incidents (Lesson 3.4).
  • Database security includes availability and integrity — not just confidentiality.

The consequence of database security failures

Database security failures appear across documented breaches:

  • Direct database compromise. Adversaries who access databases directly — through stolen credentials, through exploitation, through misconfiguration — extract the data they seek.
  • Application-mediated database access. Adversaries who compromise applications frequently use the application's database access to extract data — bypassing database access controls that permit the application.
  • Cloud database misconfiguration. Cloud databases misconfigured for public access have been the source of substantial data exposure — a recurring pattern in cloud incidents.
  • Excessive database privileges. Applications, users, and services with excessive database privileges — permitting access to data they do not need.
  • Unencrypted databases. Databases without encryption — permitting access to data if backups, storage, or snapshots are compromised.

The pattern is consistent: database security failures permit access to the enterprise's most valuable data. Database security is essential — infrastructure, platform, and application security alone are insufficient without controls that protect the data itself.

The most useful framing

The most useful framing for database security is that the database is where the enterprise's data actually lives. Every other control — network, endpoint, application — is ultimately designed to protect the data that resides in databases and data stores. When those controls fail, database security is what remains — the controls that protect the data itself, regardless of how the adversary reached it.

03 The database attack surface

Databases present a specific attack surface — interfaces, components, and data through which databases can be attacked. Understanding the attack surface informs both the controls that databases require and the specific vulnerabilities that database security addresses.

Components of the database attack surface

Components of the database attack surface
Component Attack opportunities
Database network interface The network interface through which clients connect to the database — the database listener. Exposed listeners are a primary attack vector; unpatched database software and default credentials are frequently exploited.
Database accounts Accounts through which users, applications, and administrators access the database. Weak credentials, shared accounts, excessive privileges, and unmanaged accounts are frequently exploited.
Database privileges Privileges granted to database accounts — what each account can read, write, modify, or execute. Excessive privilege is a recurring source of exposure.
Stored procedures and functions Code that runs within the database — frequently with elevated privilege. Vulnerabilities in stored procedures — particularly SQL injection — permit privilege escalation and data access.
Database links and integrations Connections between databases, between databases and applications, and between databases and external services. Each integration is a potential attack path.
Data itself The data held in the database — customer records, financial information, and other sensitive data. The object of most database attacks.
Backups and snapshots Database backups and snapshots — copies of the data held elsewhere. Frequently less well-protected than the primary database; frequently the source of exposure.
Database software and configuration The database software itself — versions, patches, and configuration. Unpatched database software and insecure configuration are frequent attack vectors.
Database management interfaces Interfaces through which the database is administered — management consoles, APIs, command-line tools. Frequently less well-protected than the data interfaces; compromise provides broad access.
Logs and audit trails Database logs and audit trails — records of database activity. Frequently targeted by adversaries to cover their tracks; also a source of detection and investigation.

Categories of database attack

Attacks against databases fall into several categories:

Direct exploitation

Exploiting a vulnerability in the database software — through the network interface — to gain access, execute code, or extract data. Includes exploitation of unpatched databases, of default credentials, and of known database vulnerabilities.

Credential compromise

Obtaining database credentials — through phishing, through credential theft, through exposed configuration, through weak or default passwords — and using them to access the database.

SQL injection

Injecting SQL commands through application input — permitting the adversary to read, modify, or delete data, or to execute commands on the database server. Examined in Lesson 5.3.

Privilege escalation

Escalating from limited database privileges to higher privileges — through vulnerabilities in stored procedures, through excessive grants, through misconfiguration.

Data exfiltration

Extracting data from the database — through the interfaces the adversary has access to, through applications that access the database, through direct database access.

Ransomware and destruction

Encrypting or destroying database data — as part of a ransomware campaign (Lesson 3.4), as a destructive attack, or as a wiper. Frequently targets backups as well as primary databases.

Insider misuse

Legitimate users or administrators using their access to extract, modify, or delete data — exceeding their authorized access (Lesson 3.7).

Supply-chain compromise

Compromise of database software or dependencies — through malicious updates, through compromised components, through supply-chain attacks (Lesson 3.7).

Reducing the database attack surface

The foundational principle of database security is to reduce the attack surface to what the database requires:

  • Minimise exposure. Databases should not be exposed beyond what they require — network exposure should be limited to authorized clients; management interfaces should not be internet-facing.
  • Minimise accounts. Database accounts should be minimised — each account should exist for a specific purpose and be removed when no longer needed.
  • Minimise privileges. Each database account should have only the privileges it requires — least privilege applied to database access.
  • Minimise data. Databases should hold only the data they require — data minimisation reduces the consequence of compromise.
  • Minimise functionality. Unnecessary database features — stored procedures, integrations, extensions — should be disabled or removed.
  • Minimise integrations. Database integrations should be limited to what is required — each integration is a potential attack path.

The most useful question

A useful question for database security assessments is: what clients need to access this database, with what privileges, and for what purpose? The gap between what the database requires — the clients that genuinely need access, with the privileges they genuinely require — and what it currently permits is the excess attack surface the enterprise is carrying. Reducing that gap is the first priority.

04 Database access control

Database access control is the discipline of determining which accounts can access which data — and what they can do with it. It is the primary control protecting the data within the database.

Database access control models

Database access control models
Model Characteristics
Discretionary access control (DAC) Object owners grant access to other users. Common in most database platforms — the default model in relational databases.
Role-based access control (RBAC) Privileges assigned to roles; users assigned to roles. The dominant model in enterprise database access control.
Attribute-based access control (ABAC) Access decisions based on attributes — of the user, the data, the context. Increasingly supported by modern database platforms.
Mandatory access control (MAC) Access based on classification labels — used in high-security contexts; supported by some database platforms.
Row-level security (RLS) Access control at the row level — permitting users to access only specific rows based on policy. Supported by many modern database platforms.
Column-level security Access control at the column level — permitting users to access only specific columns. Supported by some database platforms.

Database accounts and privileges

Database access control centres on accounts and privileges:

Database accounts

  • Administrative accounts. Accounts with full control of the database — DBA, sysadmin, root. The most consequential accounts; warrant the strongest controls.
  • Application accounts. Accounts used by applications to access the database. Frequently over-privileged; frequently shared across applications; frequently with credentials that are hard-coded.
  • User accounts. Accounts used by individual users — where users access the database directly. Should be rare in modern applications — users should access data through applications, not directly.
  • Service accounts. Accounts used by services — backup, replication, monitoring, integration. Frequently over-privileged and rarely reviewed.
  • Default accounts. Accounts that come with the database platform — frequently well-known and frequently unmanaged. Should be disabled or removed.

Privilege categories

  • System privileges. Privileges that affect the database platform — creating databases, managing accounts, changing configuration.
  • Object privileges. Privileges that affect specific objects — tables, views, procedures. Includes SELECT, INSERT, UPDATE, DELETE, and EXECUTE.
  • Administrative privileges. Privileges that permit administrative operations — granting privileges, managing users, modifying configuration.
  • Role-based privileges. Privileges granted through roles — the recommended approach for most enterprise contexts.

Access control principles

  • Least privilege. Each account should have only the privileges it requires — applied to application accounts, service accounts, and administrative accounts.
  • Separation of duties. No single account should have unrestricted access to all data — critical operations should require multiple parties.
  • Deny by default. Access should be granted explicitly, not assumed. Default accounts should be locked or removed.
  • Regular review. Database accounts and privileges should be reviewed periodically — removing accounts and privileges that are no longer needed.

Application account security

Application accounts — the accounts applications use to access databases — are particularly important. They are frequently over-privileged and frequently the source of database compromise:

  • Least privilege. Application accounts should have only the privileges the application requires — not administrative privileges, not access to tables the application does not use.
  • Separate accounts per application. Each application should have its own database account — not shared accounts across applications. Separate accounts limit the consequence of compromise.
  • Credential management. Application account credentials should be managed securely — vaulted, rotated, and not hard-coded in application code or configuration.
  • Network restrictions. Application accounts should be restricted to the specific hosts or networks from which the application connects — limiting the exposure if credentials are compromised.
  • Monitoring. Application account activity should be monitored — detecting anomalies that may indicate compromise of the application or the account.

Database access control in practice

Implementing database access control involves several activities:

  • Inventory accounts. Identify every database account — administrative, application, service, user, and default. This is the foundation — without an accurate inventory, access control is not possible.
  • Reduce privileges. Remove excessive privileges — from application accounts, from service accounts, from administrative accounts. Apply least privilege systematically.
  • Eliminate shared accounts. Replace shared accounts with dedicated accounts — for each application, each service, and each administrator. Shared accounts eliminate accountability.
  • Disable default accounts. Disable or remove default database accounts — the accounts that come with the database platform and are frequently the source of compromise.
  • Restrict network access. Restrict database network access — through firewalls, through listener configuration, through network policy — so that only authorized clients can reach the database.
  • Manage credentials. Manage database credentials — through password management, through vaulting, through rotation. Avoid hard-coded credentials.
  • Review access. Review database accounts and privileges periodically — removing accounts and privileges that are no longer needed.

The most consequential access control failure

The most consequential database access control failure is the over-privileged application account — an application account with administrative privileges, or with access to tables the application does not use. Because application accounts are frequently the target of application compromise, an over-privileged application account turns a compromise of the application into a compromise of the database. Least privilege for application accounts is one of the highest-value controls in database security.

05 Encryption

Database encryption is the use of cryptography to protect data in the database — protecting it from unauthorized access if the database, its storage, or its backups are compromised. Encryption is one of the strongest controls in database security — providing protection that persists even when other controls fail.

Encryption states

Encryption at rest

  • Storage-level encryption. Encryption of the storage on which the database resides — through full-disk encryption, through storage-array encryption, through cloud storage encryption.
  • Transparent data encryption (TDE). Encryption of the database files at the database level — transparent to applications. Supported by most enterprise database platforms.
  • Column-level encryption. Encryption of specific columns within the database — providing more granular protection for the most sensitive data.
  • Benefits and limits. Encryption at rest protects data if storage is compromised — through stolen media, through compromised backups, through misconfigured cloud storage. It does not protect data from users with legitimate database access.

Encryption in transit

  • Client-to-database encryption. Encryption of the connection between database clients and the database — through TLS. Protects data as it travels over the network.
  • Database-to-database encryption. Encryption of connections between databases — for replication, for integration. Protects data in transit between systems.
  • Application-to-database encryption. Encryption of the connection between applications and the database — through TLS. Frequently overlooked — internal connections are assumed to be safe.
  • Benefits and limits. Encryption in transit protects data as it moves — from interception, from modification. It does not protect data at rest.

Encryption in use

  • Confidential computing. Emerging technology that protects data during processing — through secure enclaves, through encrypted memory.
  • Application-level encryption. Encryption of data before it reaches the database — by the application — so that the database holds encrypted data only.
  • Homomorphic encryption. Emerging technology that permits computation on encrypted data without decryption. Still emerging; not widely practical.
  • Benefits and limits. Encryption in use protects data during processing — the state in which data is most exposed. Still emerging; requires substantial implementation investment.

Key management for database encryption

Encryption is only as strong as its key management. Database encryption requires specific key management considerations:

  • Key generation. Encryption keys should be generated using cryptographically secure random number generators — not derived from passwords or other predictable sources.
  • Key storage. Keys should be stored securely — in hardware security modules (HSMs), in key management services, or in database-native key management. Keys stored in files, in configuration, or in application code are vulnerable.
  • Key access. Access to encryption keys should be restricted — limited to the systems and processes that require them. Access should be logged and audited.
  • Key rotation. Encryption keys should be rotated periodically — limiting the consequence of key compromise. Rotation requires re-encryption of the protected data — a substantial operational effort for large databases.
  • Key separation. Different encryption purposes should use different keys — separate keys for encryption at rest, for encryption in transit, and for other cryptographic purposes.
  • Key backup and recovery. Keys should be backed up — but the backup itself must be protected. Loss of encryption keys means loss of the encrypted data.
  • Key destruction. Keys should be destroyed when no longer needed — cryptographic erasure of the data they protected.

Cloud key management

Cloud databases introduce specific key management considerations:

  • Provider-managed keys. The cloud provider manages the encryption keys — simplest to use, but the enterprise has limited control and limited visibility.
  • Customer-managed keys. The enterprise manages the encryption keys — typically through the provider's key management service. Provides greater control and auditability.
  • Customer-provided keys. The enterprise provides the encryption keys — through hardware security modules or through the provider's key import mechanisms. Provides the greatest control but requires the most operational effort.
  • BYOK (Bring Your Own Key). The enterprise brings its own keys to the cloud provider's key management service — providing control over key lifecycle while leveraging the provider's infrastructure.
  • HYOK (Hold Your Own Key). The enterprise holds its own keys outside the cloud provider — providing the strongest control but the most operational complexity.

The most useful framing

The most useful framing for database encryption is that it protects data where other controls cannot — if storage is compromised, if backups are stolen, if cloud storage is misconfigured, if media is lost. Encryption does not protect data from users with legitimate database access — that requires access control, auditing, and monitoring. The combination of encryption and access control provides protection across the states in which data exists.

06 Auditing and monitoring

Database auditing and monitoring is the discipline of recording and analysing database activity — detecting misuse, supporting investigation, and demonstrating compliance. It is the detection counterpart of database access control and encryption.

What database auditing provides

  • Activity records. Records of what happened in the database — who accessed what data, what they did with it, and when.
  • Compliance evidence. Evidence that the enterprise's controls are operating — supporting compliance with regulatory requirements (PCI DSS, HIPAA, GDPR, and others).
  • Detection capability. Detection of suspicious database activity — unauthorized access, privilege escalation, data exfiltration, and other indicators of compromise.
  • Investigation support. Records that support investigation of incidents — reconstructing what happened and identifying affected data.
  • Accountability. The record through which database activity can be attributed to specific accounts — supporting accountability and deterrence.

What to audit

Database audit events
Category Events
Authentication events Successful and failed logins — including unusual authentication patterns that may indicate credential compromise.
Privilege changes Grants, revokes, and role assignments — including the privilege changes that adversaries make to expand access.
Administrative operations Database configuration changes, account changes, and other administrative operations — including the operations adversaries use to disable controls.
Data access Access to sensitive data — particularly access that is unusual or that exceeds the user's normal patterns.
Data modification Inserts, updates, and deletes — including the modifications that adversaries make to data or to audit trails.
Schema changes Creation, modification, and deletion of database objects — including the changes adversaries make to establish persistence.
Failed operations Failed access attempts, failed authentication, failed operations — including the attempts that indicate adversarial activity.
Bulk operations Bulk data operations — exports, imports, mass updates — which may indicate data exfiltration or misuse.

Database auditing approaches

Native database auditing

  • Auditing built into the database platform — configured through database-native mechanisms.
  • Examples: Oracle Unified Auditing, SQL Server Audit, PostgreSQL pgaudit, MySQL Audit Plugin.
  • Provides detailed auditing at the database level — but requires configuration and produces substantial log volume.

Database Activity Monitoring (DAM)

  • Specialised tools that monitor database activity — through network capture, through database-native interfaces, or through agents on the database server.
  • Provide detection of suspicious activity — through policy, through behavioural analysis, through threat intelligence.
  • Can monitor activity that native auditing does not capture — including activity by privileged users.
  • Frequently provide real-time blocking — in addition to detection.

Log aggregation and SIEM integration

  • Database logs fed into a central SIEM — for correlation, for retention, for investigation.
  • Integration with other logs — application, network, identity — provides correlated detection.
  • Centralised logs are protected from tampering — overcoming a limitation of local database logs.

Privileged user monitoring

  • Monitoring of privileged database users — whose activity is frequently not captured by normal auditing (they can disable auditing).
  • Requires separate monitoring — through DAM, through session recording, through independent audit mechanisms.
  • Particularly important — privileged users have the access and capability to cause the most harm.

Audit log protection

Audit logs are targeted by adversaries — to cover their tracks, to disable monitoring, to conceal their activity. Protecting audit logs is essential:

  • Centralise logs. Send audit logs to a central location — through a SIEM, through a dedicated log platform — so that they are not lost if the database is compromised.
  • Protect log integrity. Use mechanisms that detect tampering — through hashing, through blockchain-based logging, through write-once storage.
  • Separate log access. Access to audit logs should be restricted — not available to database administrators whose activity is being audited.
  • Retain logs. Audit logs should be retained for sufficient periods — to support investigation and compliance. Retention requirements vary by regulation.
  • Monitor logs. Audit logs should be monitored — not just collected. Monitoring detects the activity the auditing is intended to capture.

Database activity monitoring in practice

Effective database monitoring involves several activities:

  • Define what to monitor. Not everything needs to be monitored — focusing on sensitive data, privileged activity, and anomalous patterns.
  • Configure auditing appropriately. Configure native auditing to capture the events that matter — without producing overwhelming log volume.
  • Deploy DAM where needed. Deploy database activity monitoring for the most sensitive databases — providing the visibility that native auditing cannot.
  • Integrate with SIEM. Feed database logs into the enterprise's SIEM — providing correlation and centralised monitoring.
  • Monitor for anomalies. Monitor for behavioural anomalies — unusual access, unusual volumes, unusual times — that may indicate compromise or misuse.
  • Investigate alerts. Investigate suspicious activity — through the investigation tools and processes of the SOC.
  • Review regularly. Review database activity periodically — identifying patterns, identifying anomalies, refining monitoring.

The most consequential auditing failure

The most consequential database auditing failure is auditing that captures activity but does not detect it. Many enterprises enable database auditing — producing substantial log volume — but do not integrate those logs into monitoring, do not analyse them for anomalies, and do not investigate what they reveal. Auditing without monitoring produces records that are examined only after an incident, if at all. Effective auditing requires both collection and monitoring.

07 Data masking and privacy controls

Data masking and related privacy controls reduce the exposure of sensitive data within databases — by replacing sensitive values with substitutes that preserve the data's usefulness for specific purposes while protecting its confidentiality.

Privacy control approaches

Data privacy control approaches
Approach Characteristics
Static data masking Sensitive data is replaced with substitutes in a copy of the database — for development, testing, or analytics. The original data is not affected; the masked copy can be used safely without exposing the original data.
Dynamic data masking Sensitive data is masked at query time — based on the requesting user's privileges. Users without the required privileges see masked data; users with the required privileges see the actual data.
Tokenisation Sensitive data is replaced with a token — a non-sensitive substitute that references the original data held in a separate, protected system. The token can be used in applications without exposing the original data.
Pseudonymisation Sensitive identifiers are replaced with pseudonyms — consistent substitutes that permit linking without identifying the subject. Widely used for analytics and research.
Anonymisation Sensitive data is modified so that individuals cannot be identified — through suppression, generalisation, or perturbation. Provides the strongest privacy protection but may reduce data usefulness.
Redaction Specific data elements are removed — through deletion or replacement. Simple but reduces data usefulness.
Encryption with selective access Sensitive data is encrypted — accessible only to those with the decryption keys. Provides protection at the data level.

Data masking use cases

  • Development and testing. Developers and testers need realistic data — but not the actual sensitive data. Masked copies provide realistic data without exposing sensitive information.
  • Analytics and reporting. Analysts need data for analytics — but may not need (or be authorized to see) the specific identities involved. Masked or pseudonymised data supports analytics without exposing identities.
  • Third-party data sharing. Sharing data with third parties — partners, vendors, researchers — may require masking to protect sensitive information while providing useful data.
  • Regulatory compliance. Privacy regulation frequently requires that data be minimised, pseudonymised, or anonymised in specific contexts.
  • Production data access. Some users may need access to production data but not to the most sensitive elements. Dynamic masking provides access with protection.

Data minimisation

Beyond masking, data minimisation is a fundamental privacy principle — reducing the volume of sensitive data the enterprise holds:

  • Collect only what is needed. Data collection should be limited to what is genuinely required for the stated purpose.
  • Retain only as long as needed. Data retention should be limited — data should be disposed of when it is no longer needed for its purpose.
  • Aggregate where possible. Aggregate data — summary statistics, grouped data — is less sensitive than the underlying individual records.
  • Separate sensitive data. Separating sensitive data from other data reduces the scope of protection required and the consequence of compromise.
  • Dispose of data securely. Data disposal should be secure — through cryptographic erasure, through secure deletion, through verified media destruction.

The most useful framing

The most useful framing for data masking and privacy controls is that the best way to protect sensitive data is not to hold it — or to hold as little as possible, for as short as possible. Where sensitive data must be held, masking, tokenisation, and other controls reduce the exposure of that data — protecting it while preserving its usefulness for legitimate purposes. Data minimisation is the first principle; masking and related controls apply where minimisation is not sufficient.

08 Database hardening and configuration

Database hardening applies the OS and application hardening principles from Lessons 5.1 and 5.3 to the database platform. The principles are the same — reduce the attack surface, apply secure configuration, reduce privilege, patch promptly — but the implementation adapts to the specific characteristics of database platforms.

Database hardening dimensions

Network and exposure hardening

  • Restrict network access. Databases should not be exposed to the internet unless specifically required — and even then, only through controlled interfaces.
  • Restrict listener configuration. Database listeners should be configured to accept connections only from authorized networks.
  • Restrict management access. Database management interfaces should not be exposed — administrative access should be through controlled channels.
  • Use encrypted connections. Client connections should be encrypted — through TLS — protecting credentials and data in transit.

Account and privilege hardening

  • Remove default accounts. Default database accounts — many of which have well-known credentials — should be disabled or removed.
  • Enforce strong authentication. Database accounts should have strong credentials — with password policies, with rotation, with multi-factor authentication where supported.
  • Apply least privilege. Database accounts should have only the privileges they require — including application, service, and administrative accounts.
  • Eliminate shared accounts. Each account should be dedicated to a specific purpose — no shared accounts.
  • Review privileges regularly. Database privileges should be reviewed periodically — removing privileges that are no longer needed.

Software and configuration hardening

  • Patch promptly. Database software — and its dependencies — should be patched promptly for security vulnerabilities.
  • Remove unnecessary features. Database features that are not required — extensions, options, sample schemas — should be removed or disabled.
  • Configure securely. Database configuration should be hardened — disabling insecure defaults, enabling security features, configuring logging appropriately.
  • Restrict administrative functions. Administrative functions — database creation, account management, configuration changes — should be restricted to authorized accounts.

Data hardening

  • Classify data. Data within databases should be classified — so that controls can be applied proportionate to classification.
  • Encrypt sensitive data. Sensitive data should be encrypted — through column-level encryption, through TDE, or through application-level encryption.
  • Apply data masking. Sensitive data should be masked where full access is not required — through dynamic masking, through static masking in copies.
  • Minimise data. Databases should hold only the data they require — reducing the consequence of compromise.

Database hardening benchmarks

Database hardening is informed by published benchmarks and guidance:

  • CIS Benchmarks for databases. CIS publishes detailed hardening guidance for Oracle, SQL Server, MySQL, PostgreSQL, MongoDB, and other database platforms.
  • Vendor hardening guides. Database vendors publish their own hardening guidance — tailored to their platforms.
  • STIGs. DISA publishes Security Technical Implementation Guides for database platforms — strict and prescriptive.
  • NIST guidance. NIST publishes database security guidance and checklists.
  • Sector-specific benchmarks. PCI DSS, HIPAA, and other sector-specific frameworks include database security requirements.

Database hardening implementation

  • Role-based baselines. Different databases serve different functions — production, development, analytics, data warehouse. Each requires a baseline appropriate to its role.
  • Automated deployment. Baselines should be deployed automatically — through configuration management, through database automation, through cloud-native mechanisms.
  • Continuous compliance. Compliance with the baseline should be monitored continuously — drift should be detected and remediated.
  • Change management. Changes to database configuration should follow change control processes — evaluated for impact, tested, approved, and documented.
  • Exception management. Some databases require deviations from baseline — for application compatibility, for specific business requirements. Exceptions should be documented, time-bounded, and reviewed.

The most useful framing

The most useful framing for database hardening is that databases are frequently the enterprise's most exposed systems — because they hold the most valuable data, because they are frequently accessed by many clients, and because their security is frequently assumed rather than verified. Hardening the database platform reduces the attack surface that the enterprise's most valuable data presents. Database hardening should receive investment commensurate with the value of the data the database holds.

09 Backup, recovery, and integrity

Database security is not only about protecting data from unauthorised access. It is also about ensuring that data remains available, that it can be recovered if lost or corrupted, and that its integrity can be verified.

Database backup

Database backup is the practice of creating copies of the database — protecting against data loss from various causes:

  • Ransomware. Ransomware frequently targets databases and their backups (Lesson 3.4). Backups isolated from production — offline, immutable — are essential.
  • Accidental deletion. Users or administrators may accidentally delete data — backups provide recovery.
  • Corruption. Data may become corrupted — through storage failure, through software bugs, through malicious modification — backups provide recovery.
  • Disaster. Natural disasters, facility failures, and other events may destroy databases — backups provide recovery.
  • Compliance. Many regulations require database backups — both for availability and for retention.

Database backup security

Backups are frequently less well-protected than the primary databases — producing a recurring source of exposure. Securing database backups requires:

  • Encryption. Backups should be encrypted — protecting the data if the backup media or storage is compromised.
  • Access control. Access to backups should be restricted — limited to the systems and administrators that require it.
  • Isolation. Backups should be isolated from production — offline, immutable, or in a separate security domain — reducing the risk of ransomware or other attacks affecting them.
  • Integrity verification. Backups should be verified — confirming that they are complete, uncorrupted, and restorable.
  • Retention. Backups should be retained according to policy — meeting regulatory requirements while minimising exposure.
  • Key management. Encryption keys for backups should be managed securely — separate from the backup itself.

Database recovery

Recovery is the process of restoring the database from backup — and it is only as effective as the backup and the recovery process:

  • Documented recovery procedures. Recovery procedures should be documented — with clear steps, defined responsibilities, and realistic timeframes.
  • Tested recovery. Recovery should be tested regularly — backups that have never been restored may not be restorable.
  • Recovery objectives. Recovery objectives — RTO and RPO (Recovery Time Objective and Recovery Point Objective) — should be defined based on the database's criticality.
  • Recovery capability. The ability to recover within the stated objectives should be verified — including through exercises and through actual recovery operations.
  • Recovery security. Recovery operations should be secure — through controlled access, through verification, through auditing.

Database integrity

Database integrity ensures that the data in the database is accurate and that it has not been modified without authorisation:

  • Database integrity mechanisms. Constraints, referential integrity, and other database-level mechanisms that ensure data consistency.
  • Transaction integrity. ACID (Atomicity, Consistency, Isolation, Durability) properties that ensure transactions are processed reliably.
  • Integrity monitoring. Detection of unauthorised modification — through audit logs, through comparison against known state, through cryptographic verification.
  • Integrity verification. Periodic verification that the database's data is accurate — through reconciliation, through comparison with source data.
  • Integrity in recovery. Recovery procedures should preserve integrity — recovering to a consistent state, not to a corrupt or partially-restored state.

The most useful framing

The most useful framing for database backup and recovery is that backups are the enterprise's last line of defence against data loss — and they must be protected as rigorously as the primary databases they protect. Backups that are unencrypted, accessible, or connected to production are vulnerable; backups that are encrypted, isolated, and tested provide the recovery capability the enterprise requires.

10 Cloud databases and data services

Cloud databases and data services introduce specific security considerations. The principles — access control, encryption, auditing, hardening, backup — remain the same, but the implementation adapts to the cloud environment and the shared responsibility model.

Cloud database models

Cloud database models
Model Characteristics
IaaS databases Databases running on cloud infrastructure — the enterprise manages the database platform, the data, and the configuration. The provider manages the underlying infrastructure.
DBaaS / managed databases Databases managed by the cloud provider — the provider manages the database platform (patching, backup, scaling), and the enterprise manages the data and access.
Serverless databases Databases that scale automatically based on demand — the provider manages all infrastructure and platform concerns; the enterprise manages only the data.
Data warehouse services Managed data warehouse services — Redshift, BigQuery, Snowflake — designed for analytics. The provider manages the platform; the enterprise manages the data and access.
Data lake services Managed storage and processing services for large-scale data — S3, Azure Data Lake, GCS. The provider manages the storage infrastructure; the enterprise manages the data, access, and governance.
NoSQL cloud databases Managed NoSQL databases — DynamoDB, Cosmos DB, Firestore — providing scale and flexibility. The provider manages the platform; the enterprise manages the data and access.

Cloud database security considerations

Shared responsibility

  • The cloud provider manages the database platform — patching, backup, availability — but the enterprise remains responsible for the data and the access to it.
  • The enterprise remains responsible for access control, for data classification, for compliance, and for the configuration of security features.
  • Misunderstanding the shared responsibility model is a frequent source of cloud database exposure.

Cloud identity and access

  • Cloud databases are frequently accessed through cloud identity — IAM roles, service accounts, federation.
  • Cloud identity controls who can access the database and what they can do — the primary access control for cloud databases.
  • Cloud identity misconfiguration — permissive IAM policies, over-privileged service accounts — is a frequent source of cloud database exposure.

Network exposure and configuration

  • Cloud databases are frequently exposed through network configuration — public endpoints, permissive security groups.
  • Misconfigured cloud databases — public access, missing encryption, missing authentication — have been the source of substantial data exposure.
  • Cloud security posture management (CSPM) tools support detection of misconfiguration.

Encryption and key management

  • Cloud databases provide encryption options — at rest, in transit, and (emerging) in use.
  • Key management options — provider-managed, customer-managed, customer-provided — provide different levels of control.
  • The enterprise should select key management appropriate to its requirements — with consideration of compliance obligations.

Monitoring and auditing

  • Cloud providers offer native monitoring and auditing for their database services — frequently integrated with cloud logging services.
  • Native auditing should be configured appropriately — capturing the events that matter.
  • Logs should be integrated with the enterprise's SIEM — for correlation and centralised monitoring.

Data residency and sovereignty

  • Cloud databases may store data in specific regions — with implications for data residency and sovereignty requirements.
  • Regulatory requirements may mandate that data remain within specific jurisdictions.
  • Cloud database deployment should consider data residency requirements.

Cloud database security in practice

Effective cloud database security involves:

  • Understand the shared responsibility model for each cloud database service — what the provider manages and what the enterprise must manage.
  • Configure cloud identity carefully. Use least privilege for cloud identity — IAM roles, service accounts, and federation — with the minimum permissions required.
  • Prevent public exposure. Ensure cloud databases are not publicly accessible unless specifically required — and even then, only through controlled interfaces.
  • Enable encryption. Enable encryption at rest and in transit for all cloud databases — with key management appropriate to the enterprise's requirements.
  • Configure auditing. Enable cloud-native auditing — capturing the events that matter and integrating with the enterprise's SIEM.
  • Implement CSPM. Use cloud security posture management to detect misconfiguration continuously.
  • Protect backups. Cloud database backups should be encrypted, isolated, and access-restricted — as with on-premises backups.
  • Monitor activity. Monitor cloud database activity — detecting anomalies that may indicate compromise or misuse.

The most consequential cloud database risk

The most consequential cloud database risk is misconfiguration — public access, missing encryption, permissive IAM policies, missing authentication. Cloud databases are easy to deploy, and the defaults or common configurations are frequently insecure. The result is that substantial data exposure frequently originates from cloud databases that were deployed without adequate security configuration. CSPM, careful configuration, and continuous monitoring are the countermeasures.

11 Common pitfalls

Enterprise database security programmes fail in predictable ways. Recognising the pitfalls accelerates improvement.

Pitfall 1 — Over-privileged application accounts

Application accounts with administrative privileges or with access to tables the application does not use — turning a compromise of the application into a compromise of the database.

Mitigation: Apply least privilege to application accounts. Grant only the privileges the application requires.

Pitfall 2 — Unencrypted databases

Databases and backups without encryption — permitting data exposure if storage, backups, or snapshots are compromised.

Mitigation: Enable encryption at rest — through TDE, through storage encryption, through column-level encryption for the most sensitive data.

Pitfall 3 — Weak key management

Encryption keys stored in files, in configuration, or in application code — permitting data exposure if keys are compromised.

Mitigation: Store encryption keys in HSMs, in key management services, or in database-native secure key management. Rotate keys periodically.

Pitfall 4 — Insufficient auditing

Databases without auditing — producing no record of database activity and limiting detection, investigation, and compliance.

Mitigation: Enable database auditing. Configure it to capture the events that matter. Integrate logs with SIEM.

Pitfall 5 — Audit logs not monitored

Auditing enabled but logs not monitored — producing records that are examined only after an incident, if at all.

Mitigation: Integrate database logs with SIEM. Monitor for anomalies. Investigate alerts.

Pitfall 6 — Backup exposure

Backups that are less well-protected than primary databases — unencrypted, accessible, or connected to production.

Mitigation: Protect backups as rigorously as primary databases — encrypted, isolated, access-restricted.

Pitfall 7 — Cloud database misconfiguration

Cloud databases deployed with insecure defaults — public access, missing encryption, permissive IAM policies.

Mitigation: Configure cloud databases securely. Implement CSPM. Monitor for misconfiguration.

Pitfall 8 — Unmanaged database accounts

Database accounts accumulated over time — service accounts, application accounts, user accounts — without inventory or review.

Mitigation: Inventory database accounts. Review accounts and privileges periodically. Remove accounts that are no longer needed.

Pitfall 9 — Default accounts and credentials

Default database accounts with well-known credentials — providing well-known entry points for adversaries.

Mitigation: Disable or remove default accounts. Enforce strong credentials on all remaining accounts.

Pitfall 10 — No integration with application security

Database security treated as separate from application security — missing the interaction between the two.

Mitigation: Integrate database security with application security. Consider how application compromise affects database security and vice versa.

Database security pitfalls and mitigations
Pitfall Primary mitigation
Over-privileged application accountsApply least privilege to application accounts.
Unencrypted databasesEnable encryption at rest.
Weak key managementUse secure key management; rotate keys.
Insufficient auditingEnable database auditing; configure appropriately.
Audit logs not monitoredIntegrate with SIEM; monitor for anomalies.
Backup exposureProtect backups as rigorously as primary databases.
Cloud database misconfigurationConfigure securely; implement CSPM.
Unmanaged database accountsInventory and review accounts periodically.
Default accounts and credentialsDisable or remove default accounts.
No integration with application securityIntegrate database and application security.

The most consequential pitfall

The most consequential pitfall in database security is treating database security as an infrastructure problem rather than as a data-protection problem. Databases are frequently secured as systems — through patching, through network controls, through OS hardening — while the data they hold is left accessible to anyone with database access. Effective database security requires protecting the data — through access control, encryption, masking, auditing — not just the database platform.

12 Key concepts

The terms below are used throughout Unit 5. Capture them in your own words as you work through the lesson.

Database security
The discipline of protecting databases and the data they hold — through access control, encryption, auditing, masking, hardening, and backup and recovery.
Database attack surface
The interfaces, components, and data through which databases can be attacked — network interface, accounts, privileges, stored procedures, integrations, data, backups, software, management interfaces, and logs.
Database access control
The discipline of determining which accounts can access which data — through database roles, privileges, and account management.
Database account
An account through which users, applications, services, or administrators access the database. Categories include administrative, application, user, service, and default accounts.
Application account
A database account used by an application to access the database. Frequently over-privileged and frequently the source of database compromise.
Database privilege
The permissions granted to a database account — system privileges, object privileges, administrative privileges.
Row-level security (RLS)
Access control at the row level — permitting users to access only specific rows based on policy. Supported by many modern database platforms.
Transparent Data Encryption (TDE)
Encryption of the database files at the database level — transparent to applications. Supported by most enterprise database platforms.
Column-level encryption
Encryption of specific columns within the database — providing more granular protection for the most sensitive data.
Key management
The set of practices for generating, distributing, storing, using, rotating, and destroying cryptographic keys. Examined in Lesson 2.1.
Hardware Security Module (HSM)
A dedicated hardware device for generating, storing, and using cryptographic keys — with strong protection against extraction or misuse.
BYOK (Bring Your Own Key)
The practice of bringing the enterprise's own keys to a cloud provider's key management service — providing control over key lifecycle.
HYOK (Hold Your Own Key)
The practice of holding the enterprise's own keys outside the cloud provider — providing the strongest control but the most operational complexity.
Database auditing
The recording of database activity — authentication, privilege changes, administrative operations, data access, and other events.
Database Activity Monitoring (DAM)
Specialised tools that monitor database activity — providing detection of suspicious activity, frequently with real-time blocking capabilities.
Data masking
The practice of replacing sensitive data with substitutes that preserve the data's usefulness for specific purposes while protecting its confidentiality. Includes static and dynamic masking.
Static data masking
Sensitive data replaced with substitutes in a copy of the database — for development, testing, or analytics.
Dynamic data masking
Sensitive data masked at query time — based on the requesting user's privileges.
Tokenisation
Sensitive data replaced with a token — a non-sensitive substitute that references the original data held in a separate, protected system.
Pseudonymisation
Sensitive identifiers replaced with pseudonyms — consistent substitutes that permit linking without identifying the subject.
Anonymisation
Sensitive data modified so that individuals cannot be identified — through suppression, generalisation, or perturbation.
Data minimisation
The principle of reducing the volume of sensitive data the enterprise holds — collecting only what is needed, retaining only as long as needed, disposing securely.
Database hardening
Reducing the attack surface of the database platform to the minimum required — network hardening, account hardening, configuration hardening, and data hardening.
Recovery Time Objective (RTO)
The maximum acceptable time to restore a system or data after disruption. A business decision, not a technical one.
Recovery Point Objective (RPO)
The maximum acceptable data loss measured in time. A business decision, not a technical one.
Cryptographic erasure
The destruction of data by destroying the encryption keys that protected it — making the data unrecoverable without the keys.

13 Activities

The activities below help you test your understanding and prepare for the unit discussion and Assignment 2. They are not graded, but completing them will substantially improve your preparation.

Activity 1 — Database security assessment

For an enterprise context you know well, assess its database security posture:

  • what databases exist — relational, NoSQL, data warehouse, data lake, cloud-managed?
  • what accounts access each database — administrative, application, service, user?
  • what privileges do those accounts have — are they least privilege?
  • is encryption in place — at rest, in transit, for sensitive data?
  • is auditing configured? Are logs monitored?
  • are backups encrypted, isolated, and access-restricted?
  • for cloud databases, is configuration secure — no public access, appropriate IAM?

Write up your assessment (400–500 words). Identify the most significant gap and describe how it would be closed.

Activity 2 — Database security programme design

For an enterprise context of your choice, outline a database security programme (500–600 words) covering:

  • the scope — which databases are covered, and how they are prioritised;
  • the access control approach — accounts, roles, privileges, review;
  • the encryption approach — at rest, in transit, key management;
  • the auditing and monitoring approach — what is audited, how logs are protected, how activity is monitored;
  • the data protection approach — masking, tokenisation, minimisation, classification;
  • the hardening approach — baselines, deployment, compliance;
  • the backup and recovery approach — protection, testing, objectives;
  • the metrics that would demonstrate the programme is working;
  • the principal challenges and how they would be addressed.

Support your design with reference to the lesson material and to published guidance (CIS, NIST, or equivalent).

Activity 3 — Preparing for Forum 5 and Assignment 2

Forum 5 includes discussion of cloud security governance and container security. Assignment 2 includes a defence-in-depth strategy for a financial institution and a secure cloud-migration architecture — both of which depend on the database security reasoning developed in this lesson.

Review the Forum 5 prompts and the Assignment 2 brief, and note where the material from this lesson — particularly access control, encryption, auditing, and cloud database security — will strengthen your analysis.

14 Self-check

Answer the questions below before moving to Lesson 5.5. If you cannot answer a question confidently, revisit the corresponding section.

Question 1
Which of the following best explains why database security matters?
Reveal answer

B. Database security matters because databases hold the enterprise's most valuable data, are targeted directly, are subject to regulation, and are central to operations. A, C, and D misstate the reason.

Question 2
Which of the following best describes the most consequential database access control failure?
Reveal answer

B. Over-privileged application accounts are the most consequential access control failure — because they turn a compromise of the application into a compromise of the database. A, C, and D are not failures — the first is occasionally unavoidable, and the second and third are best practice.

Question 3
Which of the following best describes Transparent Data Encryption (TDE)?
Reveal answer

B. TDE encrypts the database files at the database level, transparent to applications. It protects data if storage is compromised. A describes TLS encryption; C describes column-level encryption; D describes encryption in use.

Question 4
Which of the following best describes the most consequential database auditing failure?
Reveal answer

B. The most consequential auditing failure is auditing without monitoring — collecting records that are examined only after an incident, if at all. A, C, and D are not failures — the first is a tuning issue, and the third and fourth are best practice.

Question 5
Which of the following best describes the most consequential cloud database risk?
Reveal answer

B. The most consequential cloud database risk is misconfiguration — public access, missing encryption, permissive IAM policies, missing authentication — resulting from cloud databases being easy to deploy with insecure defaults. A, C, and D misstate the risk.

15 Summary

This lesson has examined database security — the discipline of protecting the data stores on which applications depend and which hold the enterprise's most sensitive information. The essential points are:

  • Database security matters because databases hold the enterprise's most valuable data. They are targeted directly, subject to regulation, and central to enterprise operations.
  • The database attack surface is broad. Network interface, accounts, privileges, stored procedures, integrations, data, backups, software, management interfaces, and logs.
  • Database access control governs who can access what. Accounts, privileges, roles, and row-level and column-level security — with least privilege for application accounts.
  • Database encryption protects data at rest, in transit, and in use. TDE, column-level encryption, TLS, and emerging confidential computing — with key management as the foundation.
  • Database auditing records activity. Authentication, privilege changes, administrative operations, data access, and other events — with protection of logs and integration into SIEM.
  • Data masking and privacy controls reduce the exposure of sensitive data. Static masking, dynamic masking, tokenisation, pseudonymisation, anonymisation — with data minimisation as the first principle.
  • Database hardening reduces the attack surface. Network hardening, account hardening, configuration hardening, and data hardening — informed by benchmarks.
  • Backup, recovery, and integrity ensure availability. Protecting backups, testing recovery, and verifying data integrity — with backups protected as rigorously as primary databases.
  • Cloud databases introduce specific considerations. Shared responsibility, cloud identity, network exposure, encryption, monitoring, data residency — with misconfiguration as the most consequential risk.
  • Common pitfalls recur. Over-privileged application accounts; unencrypted databases; weak key management; insufficient auditing; audit logs not monitored; backup exposure; cloud database misconfiguration; unmanaged accounts; default accounts; no integration with application security.

These ideas prepare for Lesson 5.5, which examines cloud security — the discipline of protecting workloads, data, and identities in cloud environments, and which integrates the material from Lessons 5.1–5.4 within the shared responsibility model.

Before moving on

Make sure you can describe the database attack surface, explain database access control and the importance of least privilege for application accounts, describe encryption states and key management, explain database auditing and monitoring, and identify the specific considerations of cloud databases. If you cannot yet do all five, revisit Sections 2, 3, 4, 5, and 9.

Next lesson

Lesson 5.5 — Cloud Security examines the shared responsibility model, cloud identity, misconfiguration, and cloud-native controls — the platform on which most enterprise workloads now run.

👤