Diploma in Cyber security
Database Security
•
Diploma
Database Security Foundations
Introduction
Databases are among the most valuable assets in modern organisations. They store customer identities, payment details, health records, intellectual property, employee information, operational transactions, and evidence used for business decisions. A database security failure can therefore cause financial loss, service interruption, legal penalties, reputational damage, and harm to individuals.
Database security is the discipline of protecting database systems, the data they contain, and the services that depend on them from unauthorised disclosure, alteration, destruction, misuse, and interruption. It includes technical controls such as authentication, authorisation, encryption, monitoring, backup, and secure configuration, but it also includes governance, privacy, accountability, risk management, and human behaviour.
This chapter establishes the conceptual foundation required for later study of access control, SQL security, encryption, auditing, vulnerability management, and incident response.
Learning Objectives
By the end of this chapter, you should be able to:
Describe common database architectures and their security implications.
Classify data according to sensitivity, value, and regulatory significance.
Explain fundamental database-security terminology.
Apply the confidentiality, integrity, and availability triad to database protection.
Distinguish privacy from security and explain accountability.
Identify database attack surfaces and common attack paths.
Explain shared security responsibilities in cloud and on-premises environments.
Recommend foundational controls for a realistic database-security scenario.
1. What Is a Database and Why Does It Require Security?
A database is an organised collection of data managed by software known as a database management system (DBMS). A DBMS provides facilities to create, read, update, delete, search, protect, and administer data. Examples include relational systems such as PostgreSQL, MySQL, Microsoft SQL Server, and Oracle Database, as well as non-relational systems such as MongoDB, Cassandra, Redis, and cloud-native data stores.
The database itself is only one component of a larger information system. A typical system includes users, applications, application programming interfaces (APIs), servers, networks, operating systems, storage, backups, administrators, and external service providers. Security weaknesses in any of these components may affect the database.
Database security has three closely related aims:
Protection: prevent unauthorised or harmful actions.
Detection: identify suspicious or improper activity.
Recovery: restore trustworthy operations after an incident.
Security is not equivalent to secrecy. A database may be confidential but unavailable, available but inaccurate, or accurate but exposed to unauthorised users. Effective protection must address all of these conditions.
2. Database Architectures and Their Security Implications
2.1 Centralised architecture
In a centralised architecture, the DBMS and its primary data are hosted in one central environment. Users or applications connect to that environment over a network.
Centralisation can simplify administration, patching, backup, and policy enforcement. However, it can also create a high-value target and a single point whose failure affects many users. Strong network segmentation, resilient infrastructure, privileged-access controls, and tested backups are especially important.
2.2 Client–server architecture
In a client–server model, client applications request database services from a database server. The client may contain presentation logic, while the server manages data processing and storage.
The model separates responsibilities but creates several security boundaries: the client device, network connection, database server, and database account. Risks include stolen client credentials, insecure network traffic, excessive database permissions, and direct exposure of the database server to user networks.
2.3 Three-tier architecture
A three-tier architecture separates the presentation layer, application layer, and data layer. Users interact with a web or mobile interface; the application server processes requests; and the database server stores and retrieves data.
This design generally improves security because users do not need direct database access. The application can validate input, enforce business rules, and use a restricted service account. Nevertheless, the application becomes a critical control point. SQL injection, insecure APIs, weak session management, and vulnerable dependencies may allow an attacker to reach the database indirectly.
2.4 Distributed and replicated databases
A distributed database stores or processes data across multiple nodes or locations. Replication may improve availability and performance, but it increases the number of systems, credentials, network links, logs, and configurations requiring protection.
Security questions include whether replicas contain the same sensitive data as the primary system, how replication traffic is encrypted, who can administer each node, and whether a deleted or corrected record is removed consistently from replicas and backups.
2.5 Cloud database architecture
Cloud databases may be delivered as infrastructure, managed database platforms, or software services. The provider usually operates the underlying facilities and much of the platform, while the customer remains responsible for data, identities, permissions, configurations, and legal obligations.
Cloud environments are highly programmable. A single incorrect storage policy, security-group rule, API permission, or identity assignment can expose large datasets. Cloud security therefore depends heavily on secure configuration, least privilege, logging, automated policy checks, and continuous review.
2.6 Database architectures and trust boundaries
A trust boundary is a point where information, authority, or control passes between components with different security assumptions. Examples include:
a user device connecting to an application;
an application connecting to a database;
a production database sending data to analytics;
a primary database replicating to another region;
an organisation sharing data with a supplier.
Every boundary should be examined for authentication, authorisation, encryption, validation, monitoring, and failure behaviour.
Three-tier database architecture and security controls
Figure: Three-tier database architecture and security controls
Figure: A three-tier architecture creates distinct security boundaries between users, applications, and database services.
3. Data Classification
Data classification is the process of assigning categories to information so that protection can be proportional to its sensitivity, value, and consequences of misuse. Classification should be based on the data itself and on the context in which it is used.
A practical four-level scheme is shown below.
Classification
Typical meaning
Examples
Typical controls
Public
Approved for unrestricted disclosure
Published product information
Integrity controls and change approval
Internal
Intended for authorised organisational use
Internal procedures, ordinary operational data
Authentication, access control, normal monitoring
Confidential
Disclosure could cause material harm
Customer records, contracts, employee data
Least privilege, encryption, audit logging
Restricted or highly sensitive
Disclosure or alteration could cause severe harm or legal breach
Payment data, credentials, health data, cryptographic keys
Classification is not the same as location. A field stored in a development database may remain confidential even if the system is non-production. Likewise, combining individually harmless fields can create sensitive information. A dataset containing dates, locations, and identifiers may enable re-identification when linked with another source.
Classification should be accompanied by handling rules covering collection, use, sharing, retention, backup, disposal, and incident reporting. It should also identify the data owner, who determines appropriate use and protection requirements. A custodian or administrator implements those requirements but does not necessarily own the data.
4. Essential Security Terminology
Asset: Something of value requiring protection, such as data, a database service, credentials, or a business process.
Threat: A potential cause of harm, such as a malicious insider, criminal group, software defect, or natural event.
Vulnerability: A weakness that can be exploited or can contribute to harm.
Exploit: A method or action that takes advantage of a vulnerability.
Risk: The possibility that a threat will exploit a vulnerability and produce an adverse consequence. Risk assessment commonly considers likelihood and impact, but these are qualitative or quantitative judgements rather than universal exact values.
Control: A safeguard that reduces likelihood, impact, or recovery time. Controls may be preventive, detective, corrective, or deterrent.
Exposure: The condition of being accessible or susceptible to a threat.
Authentication: Establishing who or what an entity is.
Authorisation: Determining what an authenticated entity may do.
Accounting or auditing: Recording and reviewing actions so that activity can be reconstructed.
Principal: An identity, such as a user, service, process, or device, that may request access.
Privilege: A permitted operation or level of authority.
Least privilege: Providing only the access necessary for an approved task and no more.
Separation of duties: Dividing sensitive responsibilities among people or systems to reduce abuse and error.
Attack surface: The collection of exposed interfaces, services, accounts, software, data paths, and physical or human entry points that could be attacked.
Data owner: The person or function accountable for decisions about a data asset.
Data custodian: The party responsible for implementing and operating controls.
Audit trail: A chronological record of relevant events, including identity, action, time, object, and result where feasible.
Pseudonymisation: Processing data so that direct identifiers are replaced, while re-identification may remain possible using additional information.
Anonymisation: Processing intended to prevent identification, subject to the strength of the technique and the possibility of linkage with other data.
5. The CIA Triad
The CIA triad is a foundational model for analysing information-security objectives.
Confidentiality
Confidentiality means that information is not disclosed to unauthorised people, processes, or systems. Database confidentiality controls include authentication, role-based access control, row- and column-level restrictions, network segmentation, encryption, masking, and careful management of backups and exports.
Confidentiality is not achieved merely by encrypting a database. An authorised application may still disclose excessive information, an administrator may misuse a legitimate account, or a backup may be copied to an insecure location.
Integrity
Integrity means maintaining the accuracy, completeness, consistency, and trustworthiness of data and processing. Integrity controls include constraints, transaction management, input validation, change approval, digital signatures where appropriate, separation of duties, and audit trails.
Integrity has at least two dimensions. Data integrity concerns whether stored values are correct and complete. System or process integrity concerns whether the system performs authorised operations without unauthorised modification. A database that contains accurate records but applies incorrect business logic still presents an integrity problem.
Availability
Availability means that authorised users can access data and services when required. Availability controls include redundancy, capacity management, fault tolerance, backups, disaster recovery, denial-of-service protection, maintenance planning, and tested restoration procedures.
Availability is not identical to continuous operation. An organisation may define an acceptable recovery time and recovery point rather than require zero interruption. A recovery point objective (RPO) specifies the maximum tolerable amount of data loss measured in time; a recovery time objective (RTO) specifies the target time for restoring service. Both are organisational requirements and vary by system.
Balancing the triad
Controls can improve one objective while affecting another. Extensive encryption may support confidentiality but increase operational complexity. Aggressive availability measures may replicate data into more locations, increasing the attack surface. Strict integrity checks may reject malformed transactions but require careful availability planning.
Security design therefore begins with business requirements and risk, not with a single favourite technology.
6. Privacy, Security, and Accountability
Privacy and security are different
Security concerns protection against unauthorised or harmful actions. Privacy concerns the appropriate collection, use, disclosure, retention, and disposal of information about identifiable people. Security is one means of supporting privacy, but privacy also requires lawful purpose, transparency, data minimisation, accuracy, retention limits, and respect for individual rights.
For example, an organisation may securely store more personal data than it genuinely needs. The storage may be well protected, yet the collection may still be excessive or unjustified. Conversely, a privacy policy may promise limited access, but weak authentication may prevent that promise from being fulfilled.
Important privacy principles commonly encountered in professional practice include:
collect only what is necessary for a defined purpose;
explain how personal data will be used;
use data consistently with the stated or lawful purpose;
maintain accuracy;
retain data only as long as justified;
protect data against unauthorised access and loss;
support lawful rights of individuals;
demonstrate compliance through records and governance.
Legal requirements differ by jurisdiction and sector. Examples include data-protection laws, health-information rules, financial regulations, breach-notification obligations, and contractual requirements. Security professionals must therefore work with legal, compliance, and data-protection specialists rather than assume that a technical control alone establishes compliance.
Accountability
Accountability means that an organisation and its responsible individuals can demonstrate who made decisions, who accessed data, what happened, and whether controls operated as intended. Accountability depends on:
unique identities rather than shared accounts;
reliable time synchronisation;
tamper-resistant logging;
documented ownership;
approval and change records;
periodic access reviews;
monitoring and investigation procedures;
retention of evidence for an appropriate period.
Logging every event is not automatically accountability. Logs must be relevant, protected from unauthorised alteration, available to investigators, and reviewed in proportion to risk. Logs may also contain personal or sensitive information and therefore require their own access and retention controls.
7. Database Attack Surfaces and Attack Paths
An attack surface is broader than the database listening port. It includes every route through which an attacker might obtain access, influence processing, extract information, or disrupt service.
Identity and access surface
Weak passwords, shared administrator accounts, excessive privileges, inactive accounts, stolen tokens, and poorly protected service credentials can provide direct or indirect access. Privileged accounts deserve particular attention because compromise can affect schemas, users, audit settings, backups, and stored data.
Application and API surface
Applications commonly connect to databases using service accounts. Vulnerable code may permit SQL injection, insecure direct object references, excessive data retrieval, or bypass of business rules. Parameterised queries, input validation, safe error handling, secure API authorisation, and restricted service accounts reduce these risks.
Network and protocol surface
Unnecessary network exposure, weak firewall rules, unencrypted connections, insecure administrative protocols, and poorly segmented environments allow interception or unauthorised connection attempts. Database services should generally be reachable only from authorised application, administration, or recovery networks.
Configuration and software surface
Default credentials, unpatched DBMS software, unnecessary extensions, insecure encryption settings, excessive privileges, and publicly exposed management interfaces are common weaknesses. Configuration management and vulnerability remediation are therefore database-security activities, not merely infrastructure tasks.
Data movement surface
Exports, reports, replication, data warehouses, test environments, logs, temporary files, snapshots, and backups may contain the same sensitive information as production. Data often escapes the primary database through legitimate operational processes, so these pathways require classification and control.
Human and physical surface
Phishing, social engineering, accidental disclosure, insider misuse, lost devices, and unauthorised physical access can defeat technical controls. Training, clear procedures, background checks where lawful, visitor controls, secure media disposal, and separation of duties complement technology.
A useful assessment method is to map a complete data flow: source, collection, transmission, processing, storage, replication, use, sharing, backup, archival, and disposal. At every stage ask what could be exposed, altered, interrupted, or falsely attributed.
8. Shared Security Responsibilities
Security responsibility is distributed among data owners, database administrators, developers, infrastructure teams, users, suppliers, and cloud providers. “Someone else manages it” is not a security control.
On-premises environments
An organisation usually controls the physical facility, hardware, operating system, DBMS, network, applications, identities, data, backups, and monitoring. Responsibility must still be allocated internally. For example, a database administrator may configure the DBMS, while a data owner approves access and a security team reviews logs.
Cloud environments
Cloud providers normally secure the physical facilities and the underlying service infrastructure. Customers remain responsible for what they place in the service and how they configure and use it. The precise division depends on the service model and contract.
Responsibility area
Common provider responsibility
Common customer responsibility
Physical facilities
Buildings, power, physical access
Usually none, subject to assurance requirements
Managed DBMS platform
Platform maintenance and core service operation
Schema, users, permissions, configuration choices
Data
Service durability mechanisms
Classification, lawful use, retention, deletion
Identity
Some platform identity features
User lifecycle, MFA, least privilege, privileged access
The table describes common patterns, not a universal contract. Organisations must read service documentation, security addenda, and contracts carefully. They should also verify provider claims through independent assurance reports, configuration reviews, and operational tests.
A useful responsibility matrix assigns each control an accountable owner, an implementing party, a reviewer, and evidence of operation. This prevents gaps such as a backup being configured but never restored, or access being granted without a business owner’s approval.
9. Foundational Security Controls
A diploma-level practitioner should understand the following baseline controls:
Inventory: identify databases, data stores, replicas, accounts, interfaces, and owners.
Classification: label data and define handling rules.
Strong identity: use unique accounts, multi-factor authentication where appropriate, managed service identities, and secure credential storage.
Least privilege: grant minimum permissions, separate administrative roles, and review access regularly.
Secure development: use parameterised queries, validated inputs, safe error handling, dependency management, and security testing.
Network restriction: limit database connectivity and separate production, development, administration, and recovery networks.
Encryption: protect data in transit and at rest, and manage keys separately with controlled access.
Patching and hardening: remove defaults, disable unnecessary services, apply updates, and use secure configuration baselines.
Logging and monitoring: record authentication, privilege changes, data-access events of significance, configuration changes, and failures; alert on suspicious patterns.
Backup and recovery: protect backups from alteration and unauthorised access, define RPO and RTO, and test restoration.
Data lifecycle management: securely retain, archive, and dispose of data and copies.
These controls are mutually reinforcing. Encryption cannot compensate for an exposed key; logging cannot compensate for no response capability; and a backup cannot guarantee recovery unless restoration has been tested.
10. Illustrative Case: The Exposed Customer Analytics Database
Background
A fictional online retailer maintains a production customer database containing names, contact details, order histories, and hashed passwords. An analytics team copies selected production tables into a cloud database for reporting. The analytics database is intended for internal use.
Problem
A security review discovers that the analytics database is reachable from the public internet. It uses a broadly privileged service account, contains data that was copied without current classification labels, and has logging enabled but no alerting. A developer’s test script also stores a connection string in a code repository.
Analysis
The immediate attack surface includes the public network endpoint, the exposed credential, the privileged account, the copied dataset, and the repository. The CIA analysis is as follows:
Confidentiality: customer information and credentials may be disclosed.
Integrity: an attacker with write access could alter reports or insert malicious data.
Availability: deletion or resource exhaustion could disrupt analytics and possibly connected services.
Accountability: logs exist, but without alerting and review, suspicious access may not be detected promptly.
Privacy: copying more personal data than required creates additional processing and retention obligations.
Approach and solution
The organisation first isolates the database endpoint and rotates the exposed credential. It reviews access logs and preserves relevant evidence. The database is moved to private network connectivity, and access is restricted to approved analytics services and administrators using multi-factor authentication.
The team replaces the broadly privileged account with separate roles: a read-only extraction identity, a restricted analytics identity, and a separately controlled administrative identity. Only required columns are copied, direct identifiers are masked where possible, and the dataset receives a formal retention period. Secrets are moved to a managed secret store, and repository scanning is enabled.
Encryption is enabled for connections and storage, while keys and key-access permissions are managed separately. Logging is centralised, protected from alteration, and connected to alerts for unusual downloads, privilege changes, failed logins, and access from unexpected locations. A restoration test verifies that protected backups can meet the analytics service’s recovery requirements.
Outcome
The organisation reduces unnecessary exposure, limits the consequences of credential compromise, improves detection, and aligns the analytics process with data-minimisation and retention requirements. The review also identifies a governance improvement: the data owner must approve future copies of production data into non-production environments.
Learning points
A secondary copy may be as sensitive as the primary database.
Public exposure and excessive privilege multiply risk.
Security and privacy require controlling data movement, not merely securing storage.
Logs are valuable only when protected, reviewed, and connected to response.
Shared responsibility must be assigned explicitly.
11. Challenges and Contemporary Developments
Database environments are increasingly hybrid, automated, and distributed. Containers, serverless applications, data lakes, real-time analytics, and artificial-intelligence systems create additional copies, APIs, identities, and processing paths. AI systems may also expose sensitive information through training data, prompts, logs, embeddings, or generated outputs. Security teams should therefore classify AI-related data flows and prevent models or tools from receiving information beyond their authorised purpose.
Automation can improve security by enforcing configuration policies, detecting anomalies, rotating credentials, and identifying excessive permissions. It can also amplify mistakes: an incorrect deployment rule may expose thousands of objects within minutes. Automated decisions therefore require testing, approval controls, monitoring, and rollback capability.
Other persistent challenges include legacy systems that cannot support modern authentication, unclear ownership of shared data, alert fatigue, shortage of skilled personnel, supply-chain risk, and tension between rapid access to data and strict minimisation. Good security is consequently a continuous process of assessment, design, implementation, verification, and improvement.
Chapter Summary
Database security protects data and database services against unauthorised disclosure, alteration, destruction, misuse, and interruption. The database must be considered as part of a wider system containing users, applications, APIs, networks, operating systems, storage, backups, and suppliers.
Centralised, client–server, three-tier, distributed, replicated, and cloud architectures create different trust boundaries and attack surfaces. Data classification enables proportionate protection and should govern collection, use, sharing, retention, backup, and disposal. Core terminology includes assets, threats, vulnerabilities, controls, authentication, authorisation, least privilege, accountability, and attack surface.
The CIA triad expresses the objectives of confidentiality, integrity, and availability. These objectives must be balanced according to business and risk requirements. Privacy is broader than security: it addresses appropriate and lawful handling of personal information, while accountability requires demonstrable responsibility, reliable identities, protected logs, ownership, and review.
Attack surfaces include identities, applications, APIs, networks, configurations, data copies, backups, human processes, and physical environments. Security responsibilities are shared among organisations, cloud providers, data owners, administrators, developers, users, and suppliers. Foundational controls include inventory, classification, strong identity, least privilege, secure development, network restriction, encryption, hardening, monitoring, backup testing, lifecycle management, and incident readiness.
Key Terms
Asset: Something valuable that requires protection.
Attack surface: All exposed interfaces, services, identities, data paths, and other points that may be attacked.
Authentication: Establishing the identity of a user, process, device, or service.
Authorisation: Determining which actions an authenticated entity may perform.
Availability: The property that authorised users can access systems and data when required.
Confidentiality: Protection against unauthorised disclosure.
Control: A safeguard that reduces risk or supports detection and recovery.
Data classification: Assigning sensitivity and handling requirements to data.
Data custodian: The party responsible for implementing and operating data controls.
Data owner: The person or function accountable for decisions about data use and protection.
Integrity: The accuracy, completeness, consistency, and trustworthiness of data and processing.
Least privilege: Providing only the access necessary for an authorised task.
Privacy: Appropriate and lawful collection, use, disclosure, retention, and disposal of personal information.
Risk: The possibility of harm arising from threats, vulnerabilities, and consequences.
Security boundary: A point where information or authority crosses between different trust assumptions.
Threat: A potential cause of harm.
Vulnerability: A weakness that may be exploited or contribute to harm.
Shared responsibility: The allocation of security duties among relevant providers, organisations, users, and specialists.
Review Questions
Short Answer Questions
What is the purpose of a database management system?
Define authentication and authorisation, and distinguish between them.
What are the three elements of the CIA triad?
Why should database backups be included in security assessments?
State one important difference between privacy and security.
Long Answer Questions
Explain the security advantages and limitations of a three-tier database architecture.
Describe how data classification should influence database access, storage, sharing, and disposal.
Discuss confidentiality, integrity, and availability using database-specific examples.
Explain the shared responsibility model in a managed cloud database service.
Describe a foundational database-security programme for a medium-sized organisation.
Analytical / Application Questions
A reporting database contains customer addresses and purchase histories but is accessible from the internet using a shared administrator account. Identify at least five risks and propose prioritised corrective actions.
An organisation encrypts its production database but stores unencrypted exports in a shared folder. Analyse the confidentiality and privacy implications and recommend controls.
A developer requests direct production database access because an application defect must be investigated urgently. Apply least privilege, separation of duties, accountability, and incident-risk principles to design an appropriate response.
Multiple Choice Questions with Answers
Question 1
Which security objective is primarily concerned with preventing unauthorised disclosure of database records?
A. Availability
B. Confidentiality
C. Integrity
D. Accountability
Correct Answer: B. Confidentiality
Question 2
In a three-tier architecture, which component normally enforces business logic before requesting data from the database?
A. Presentation client
B. Application layer
C. Storage medium
D. Backup archive
Correct Answer: B. Application layer
Question 3
Which statement best distinguishes authentication from authorisation?
A. Authentication determines identity; authorisation determines permitted actions.
B. Authentication encrypts data; authorisation backs up data.
C. Authentication records events; authorisation restores systems.
D. Authentication classifies data; authorisation deletes data.
Correct Answer: A. Authentication determines identity; authorisation determines permitted actions.
Question 4
Which classification normally requires the strongest protection because compromise could cause severe harm or legal breach?
A. Public
B. Internal
C. Confidential
D. Restricted or highly sensitive
Correct Answer: D. Restricted or highly sensitive
Question 5
Which control most directly supports the principle of least privilege?
A. Giving every developer database administrator rights
B. Using one shared account for all analysts
C. Granting an application only the database operations it requires
D. Allowing all internal network addresses to connect
Correct Answer: C. Granting an application only the database operations it requires
Question 6
Why is a backup part of the database attack surface?
A. Backups never contain sensitive information
B. Backups may contain sensitive data and can be stolen, altered, or destroyed
C. Backups automatically prevent SQL injection
D. Backups replace the need for access controls
Correct Answer: B. Backups may contain sensitive data and can be stolen, altered, or destroyed
Question 7
Which statement about privacy is most accurate?
A. Privacy is identical to encryption.
B. Privacy concerns only physical access to servers.
C. Privacy includes appropriate collection, use, disclosure, retention, and disposal of personal data.
D. Privacy applies only when data is stored in the cloud.
Correct Answer: C. Privacy includes appropriate collection, use, disclosure, retention, and disposal of personal data.
Question 8
A log records database events but is freely editable by the administrators whose actions it records. Which accountability weakness is most evident?
A. Insufficient data classification
B. Lack of protection against log alteration
C. Excessive network redundancy
D. Overuse of data minimisation
Correct Answer: B. Lack of protection against log alteration
Question 9
In a typical managed cloud database service, which responsibility usually remains with the customer?
A. Operating the provider’s physical power systems
B. Constructing the provider’s data centre
C. Managing customer identities, permissions, and data configuration
D. Maintaining the provider’s cooling equipment
Correct Answer: C. Managing customer identities, permissions, and data configuration
Question 10
An analytics team copies an entire production table when it needs only three non-identifying fields. Which principle most directly suggests reducing the copy?