Cybersecurity threats are increasing in volume, complexity and impact. Yet, organisations struggle to counter these growing threats. Cyber attacks often intend to steal, damage, hijack or alter value-generating data. In this article around database security, we use the NIST framework to lay out the common controls that you can implement to secure your databases. Let’s start by discussing the potential impact of unsecured databases.
The cost of a single data breach reached an average of $4.35 million in 2022, according to IBM’s Cost of a Data Breach report. At the same time, the number of organisations that are ready to efficiently meet today’s security risks is as low as 15%, according to Cisco’s Cybersecurity Readiness Index. Given the previous numbers, it should not surprise you that the World Economic Forum placed cybersecurity failures as the most concerning technological risk in its Global Risks Report for 2022.
Before digging into the typical controls we can implement around a database management system (i.e. DBMS), we will go over the typical threat mediums.
When a malicious person is trying to attack a database, they might leverage one of the following mediums.
An attacker with physical access to the hardware hosting the target database can be tempted to steal, for example, the storage devices and try to reverse engineer the data stored in the concerned piece of hardware.
We might be tempted to think that this type of attack is unlikely to happen. Yet, a study conducted by Blancco in 2019 revealed that 42% of purchased second hand drives contained personal data.
According to IBM’s Cost of a Data Breach report, physical security compromises accounted for around 9% of the data breaches’ initial vectors.
Let’s now move to the next medium in cyber attacks, software.
In our digital world, most attacks involve a form of software. This can be malicious software that is injected into the targeted victim’s environment (e.g. a virus, a malware), a software vulnerability (i.e. a bug that can be exploited by a cyber attacker) or misconfigured software that could leave security holes for the malicious actor to exploit.
According to IBM’s Cost of a Data Breach report, vulnerabilities in third party software and misconfigurations account for nearly 28% of the initial attack vectors. Unfortunately, the number of software vulnerabilities keeps rising, so such attacks might become even more popular among malicious actors.
It is important to understand that an attacker might use vulnerabilities affecting the DBMS directly but also any software component that can be used by a legit user (application or human) to interact with the database either locally (e.g. the Operating System) or remotely via network calls.
Let’s now cover the most used attack medium in cyberattacks, human factors.
According to IBM’s 2023 Threat Intelligence Index, 41% of the reported incidents involve phishing for initial access. Phishing is a form of social engineering aiming at tricking its victims into revealing sensitive information that will be used later to conduct a cyberattack. Even more worrying, The World Economic Forum’s Global Risks Report for 2022 found that 95% of cybersecurity issues are traced to human error.
Human errors can consist of falling into a social engineering trap or failing to define and follow proper security processes to protect the sensitive data. Let’s go over some of the most common attack types, including the ones targeting human factors.
The following table lists some of the common cyber attacks and techniques:
Attack step* | Category* | Attack | Description | Main medium |
Initial access | Phishing | Malicious attachment and/or link | Uses social engineering to trick the victim into downloading malicious agents (virus, malware…). | Human |
Initial access | Vishing | Fraudulent calls, sms … | Uses social engineering to trick the victim into providing sensitive information over interactive channels. | Human |
Initial access | Exploit Public Facing Application | SQL injection | Uses vulnerabilities in a public-facing application to run queries that are not legitimately authorised. | Software |
Initial access | Hardware addition | Uses illegitimate hardware to connect to the victim’s network. | Hardware | |
Initial access | Supply chain compromise | DevOps tools, software repositories and hardware parts | Alters software or hardware dependencies to alter the behaviour of the resulting application to gain illegitimate access. | Software and Hardware |
Credential access Collection | Man in the middle | Sniffing | Corrupts a network device to steal or deviate exchanged information from its intended targets. | Software |
Credential access | Brute force | Password guessing, cracking … | Gets a valid credential by trying common or leaked secrets or by using an artefact of the secret (e.g. its hash). | Human (usually due to poor training and processes) |
Impact | Denial of Service | Flooding/ Exhausting | Renders a targeted service inoperable by overloading it with illegitimate traffic. | Software |
(*) As per MITRE ATT&CK®
Now that we are familiar with some of the common cyber attacks, let’s dive into the different controls you need to implement to secure your database.
In its cybersecurity framework, NIST defines 5 pillars or functions to cover all the activities and measures around securing your digital assets: Identify, Protect, Detect, Respond and Recover.
We will use these pillars in the NIST framework to classify the typical controls we need to implement to secure your data stores.
The first step in any effort to secure your data is to know its content, where it is stored, which systems can consume it and what the applicable regulations and standards are. In order to achieve the above, you need to consider the following:
After understanding your data and its legitimate consumers, the next step would be to start implementing all the measures to proactively prevent its theft, alteration or deterioration.
Let’s go over the typical measures you need to implement to protect your data.
As we discussed earlier, most cybersecurity issues involve a human factor. Therefore, it is important to regularly train your teams so that they understand:
All database products come with built-in database authentication. You should opt for one that supports password-based authentication, at least, and has built-in LDAP/Kerberos integration. Our recommended approach is to use:
Most database products are shipped with a decent role management functionality. Roles are a set of predefined permissions that are used to ease the management burden. We recommend to have the following roles:
Role | Granted permissions | Typical users |
STATS | Read specific statistics-related tables (e.g. v$tables in oracle, performance schema in MySQL). | Monitoring agents. |
READ | Read the applicative tables’ content. | Developers working on the application populating or using the concerned tables. |
DML | The Data Manipulation Language role grants the permissions to read, insert/add, update and delete the content of existing tables. | Applications using and populating the tables’ content. |
DDL | The Data Definition Language role grants the permissions needed to modify the structure of the database (e.g. adding a column/table). | Automation users for managing database structure. For example, it can be assigned to versioning tools such as Liquibase and Flyway. |
REPLICA | Set up replication for the database. | Automation users for managing replication. |
BACKUP | Backup or export data. | Automation users for managing backups. |
DBA | Full administration rights to the database. | Should be restricted to a very small group of people (e.g. the administrators in charge of the concerned database). |
Once you implement the database’s built-in authentication and authorisation mechanisms, you can start implementing more layers of defence. Let’s focus on a few best practices related to the networking layer:
When colocating several workloads in the same host, sandboxing your database instances can mitigate some vulnerabilities affecting your databases at the cost of additional components (and therefore attack surfaces).
For example, you can use LXD to run and manage your databases within LXC containers. You can also deploy your database in a confined snap (e.g. PostgreSQL, MySQL) to limit the permissions granted to your database processes.
Encryption is another important layer of defence. We already detailed the various levels of encryption and their benefits in this guide. In this blog, we summarise the main ideas:
Successfully configuring your database to follow best practices in regards to authentication, authorisation, networking, sandboxing and encryption is a major step towards securing your database. Yet, it is equally important to secure the software dependencies of your chosen database solution.
It is important to secure the packages that you use in your software stack. You can secure those packages by using “private” mirrors that are placed behind your own firewalls. The idea is to ensure that any used package was certified centrally before being exposed to the consuming applications (typically using a proxy). For example, an air-gapped snap store is a solution to manage and expose snaps without the need for a permanent internet connection for all the hosts where you need to deploy snaps.
Before making a package available to the rest of your network, we recommend to:
Any software package is subject to security bugs. You need to have a process in place to regularly update your software to fix any security issue that affects your software stack.
With zero-day exploits nearly doubling in 2021 and with 80% of public exploits being published before their CVEs, it is no longer enough to regularly apply security fixes – you need to do so as fast as you can.
If you’re an Ubuntu user looking for secure software, you can rely on Ubuntu Pro to get up to 10 years patching for more than 25,000 packages including PostgreSQL, MySQL and several other databases. Ubuntu Pro also comes with Livepatch, which ensures a timely roll-out of critical patches without needing an immediate reboot of your hosts. It also provides tools to harden your OS following the most stringent compliance regimes and security standards like CIS, DISA-STIG and FedRAMP.
Hardening your OS is the first step in hardening your environment. The next one should be hardening your databases.
Hardening a software component is mainly about reducing its attack surface as much as possible. Typically, we would remove any unneeded service, close unused ports and change default settings (e.g. passwords, accounts).
In our upcoming whitepapers, we will detail the changes you need to apply to your databases to meet the CIS security benchmark. Stay tuned by subscribing to our newsletter.
Now that we covered the main actions we need to undertake to protect our software stack, we will next cover the measures to put in place to promptly detect security issues in your databases.
In order to promptly fix any security issue concerning your data, you need to monitor your environment to detect:
In order to monitor suspicious activities, you need to implement:
Auditing is a requirement within many security frameworks including PCI-DSS.Most popular database products have an auditing functionality that is either built-in or provided by an extension. The functionality consists of writing specific database actions into a specified destination (e.g. file). For example, the pgAudit extension provides extensive auditing capabilities for PostgreSQL databases. Similarly, MySQL’s query_log can be used to have a database audit.
You also need to monitor the actions of the user on the host containing the database. Once a user gains root privileges to the OS, it is only a matter of time before gaining privileged access to the hosted databases. Therefore, it is important to monitor the actions of the user at the OS level. This can be achieved, for example, by:
Once we automate the collection of audit data for the OS and the database, we need to send them to a centralised security information and event management (a.k.a. SIEM) solution to detect suspicious patterns. For example, you can centralise your logs into a Spark cluster and run your own custom rules to detect specific suspicious behaviours (e.g. A sudden surge of human induced deletes of data, a lot of failed login attempts, suspicious changes in user’s connection timestamps).
Once your monitoring of suspicious activities is in place, you need also to monitor the vulnerabilities in your deployed software.
Software vulnerabilities are published daily and a software version that was believed to be safe one day can become a security threat the day after. Therefore, it is important to keep track of new vulnerabilities. Once again, Ubuntu Pro helps you detect which packages need an update (check this tutorial for an example) and allows you to seamlessly update the covered software packages.
Ubuntu also publishes Open Vulnerability and Assessment Language (OVAL) data that can help you programmatically assess your security posture. You can also use our CVE reports to search for specific CVEs.
Now that you are ready to detect security issues, you need to have the processes to respond to them. Let’s dig into some details.
There is no generic way to respond to a security incident as the response depends highly on the nature and the impact of the incident. Yet, you can have a process that can guide you and your organisation in these, often, chaotic situations:
It is also important to document and rehearse your planned responses to a security incident.
After detecting a security incident, your initial focus should be to “stop the bleeding” and prevent the propagation of the issue to other systems. Your next focus should be recovering any damaged data or degraded services.
We cannot state it enough but a backup is often the ultimate (and sometimes the only) recovery solution for data-related incidents. This detailed guide can help you in setting up a comprehensive backup strategy or improve your existing one. It is also important to have a post-mortem session where the lessons learned are documented, the security gaps are identified and timely addressed. It is also important to notify any end user that might have been affected by the security incident.
In this article, we covered the probable consequences of improperly secured data. We provided an overview of the common security attacks and mediums. We detailed some of the activities and measures you can implement to secure your databases, following the NIST framework.
At Canonical, we can assist you in securing your data and your business. Please contact us to learn more.
Microsoft Edge is now available for Ubuntu. In this guide, I’ll walk you through the…
Our latest Canonical website rebrand did not just bring the new Vanilla-based frontend, it also…
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…