1

In a DBMS like MySQL, are the underlying files that contain the data encrypted since we want to have role and user based control? If they are encrypted, what encryption keys and algorithms are used? If they are not, how is the data safe from access (by a malicious user directly accessing the file)?

My guess is that directly opening a file wont work as the DBMS might use a proprietary binary format for writing data to files. As for encryption, I couldn't find any good reference detailing the encryption process. I am curious about how the DBMS prevents a malicious user from directly accessing the underlying file and also how a subset of authorized users can be dynamically granted access.

4
  • 2
    Your question appears to be generic but you've tagged this for MySQL. Are you asking specifically what MySQL's behavior is? Or are you asking generically what different database vendors do? Dec 25, 2022 at 10:34
  • Each DBMS handles this differently; there is no generic answer to your question.
    – mustaccio
    Dec 25, 2022 at 14:30
  • With MySQL/MariaDB, you have to specifically ask for encryption. In doing so, you will see what the options/methods are. In all cases, there is a basic "login+password" mechanism.
    – Rick James
    Dec 25, 2022 at 15:08
  • @JustinCave I assumed that there would be one or more general patterns followed by most DBMS since this is a common concern for all. It seems my assumption is wrong and there are varying behaviors. I have updated the question to focus on MySQL.
    – Tabish Mir
    Dec 26, 2022 at 0:33

1 Answer 1

1

Databases that must be kept secure from attackers are typically hosted on a server. The primary way to keep them secure is at the operating system level. Don't let the attacker have shell access to your important server, so they can't open the data files directly.

Stated another way, if an attacker could gain shell access to your production servers, they could do a lot of mischief. Accessing your database files is only the beginning.

You're right that database software employs proprietary binary file formats, because it's more efficient. These formats are complex, so you can't just open the file in an editor and see all the data records. You need to use the DBMS software itself to make sense of it. But if an attacker could gain access to those files, they could copy the whole file to their own computer, where they might have their own instance of the DBMS software and therefore can decode the file format. But that still requires them to gain access to your server, so the files should be safe.

Assuming the attacker does not have shell access on your server, they are restricted to access the database via the network, only in the manner allowed by the client-server protocol. They must authenticate using a MySQL user and password, and then they can only run SQL commands that you have granted them privilege to run.

Many other services exist on a server that have their own restrictions. For example http servers, printing servers, time servers, etc. Clients on other computers can connect over the network, but only using the right protocol, which enforces limits on the client's privileged access to files. These services typically don't need to encrypt their files.

In my opinion, the more important use of at-rest encryption for database files is when you recycle old storage devices. If you throw the spent drives into the trash, then criminals might find them by physically stealing your trash. For this reason, another security practice is to destroy spent drives in powerful shredders.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.