Consider the scenario:

Someone in power decides they don't like you and wants to frame you for some virtual crime. The police come and take away your computer but the hard drive is encrypted. They demand your encryption key but as you do not trust them to not tamper with the evidence (your hard drive), you say you will provide the key as long as they send an exact copy of the hard drive to an independent trusted 3rd party. This third party would then be able to verify whether any evidence found on the police version of the hard drive is real or fake.

Is it possible that the police could add incriminating data to your hard drive despite not knowing the decryption key?

The reason I ask is because if it works in the same way as RSA encoding, I would have thought if they got a hold of the public/encryption key, they could add any data they wanted despite not being then able to decode it.

  • 2
    Disk encryption doesn't normally use public key encryption. It generally uses symmetric encryption, for speed, and because for most drives, there isn't a "public" aspect.
    – Matthew
    Jul 7, 2017 at 16:46

2 Answers 2


A properly encrypted drive is a fixed size blob of seemingly random data, the size of your drive. You have to decrypt it in order to be able to correctly maintain the data structures inside the container; without the key, you can't write anything valid into it, and if you try, you will only corrupt it.


If the question is taken literally, then yes, you cannot add a new file to an encrypted hard drive. If your question is instead better phrased as "can an attacker modify data on an encrypted hard drive without knowing the key?", then the answer is that it depends on the mode of operation being used, but it is very possible.

Encrypting data requires two algorithms: the cipher itself (such as AES), and a mode of operation (such as CBC). The cipher can be assumed to be secure in all realistic circumstances, but the mode of operation may either be quite secure, or may give away a large amount of information about the encrypted data or worse, depending on how it is used. Each mode of operation has its pros and cons, and is only supposed to be used for specific purposes. Some examples:

  • ECB: extremely simple, safe when used only to encrypt a single block of data with a given key
  • CTR: very fast and does not need to encrypt in multiples of one block, so common in networking
  • GCM: similar to CTR, but prevents tampering at the expense of space efficiency
  • CBC: pretty simple, useful to encrypt individual files where integrity is not important
  • XTS: more complicated than the others, but useful to encrypt block devices like hard drives
  • EME: better for block device encryption than XTS, but patent encumbered so rarely used

Encrypted hard drives typically use either CBC or XTS. With CBC, the answer to your question is no, it does not stop someone from adding or modifying data, though it does stop them from adding whole, intact files as that would require fine control over various complicated filesystem structures. CBC is vulnerable to so-called malleability attacks, which allow targeted manipulation of already encrypted data (see Practical malleability attack against CBC-Encrypted LUKS partitions). While someone couldn't simply add an entire new file, they could, for example, modify an existing executable file to add malicious behavior. A description of the capabilities of this attack against CBC, from the above paper:

We can use this technique to change every 2nd plaintext block in a sector to anything we want to while destroying the blocks between the manipulated blocks. Given a blocksize of 16 bytes (128 bits) this does allow injecting more or less arbitrary shellcode to an executable file by dividing the shellcode to small chunks and adding JMP instructions to jump over the garbage blocks.

This allows for a scary level of control over your encrypted data. While the confidentiality of the data itself is still guaranteed with essentially all modes of operation (with the exception of ECB, which results in the famous ECB penguin when used to encrypt more than a single block of data), you probably wouldn't want to use this mode if you expect someone may be able to tamper with your data.

XTS is not perfect and does not guarantee integrity of the data, it does prevent such targeted modifications. With XTS, you can corrupt an arbitrary 16 byte block of data, but you cannot choose what the modified data will decrypt to. While this is not nearly as bad as being able to insert arbitrary data, it can still be dangerous. For example, it could be used to cut out vital permission checks from within the machine code of an executable, making it vulnerable.

There are special block modes called wide-block modes (such as XCB and EME/EME2) which are similar to XTS, but increase the minimum block size for tampering up to the size of a single sector (typically 512 bytes). An attacker who can corrupt an arbitrary 512 bytes is much less dangerous than one who can corrupt an arbitrary 16 bytes (or 1 bit, if something silly like CTR is used!). Unfortunately, these block modes are or have for most of their lives been patented, which hinders their adoption.

Authenticated modes like GCM provide perfect integrity on top of the confidentiality provided by the cipher, so that if any ciphertext is modified without knowing the key, it will not decrypt at all, rather than decrypting to corrupted plaintext. The problem with authenticated modes is that they require a little bit of extra integrity data called a MAC after every message. This is fine for things like networking to replace CTR, where the MAC is sent after a long stream of ciphertext, but a hard drive requires being able to read and write with per-sector granularity, so each sector would need to contain its own MAC, greatly reducing the amount of space available for storing data.

Most hard drive encryption software uses either CBC or XTS, though some versions of Windows include a "diffuser", which acts similar to wide-block modes by increasing the minimum tampering size. For something like Linux, a drive may be encrypted with aes-cbc-essiv when in CBC mode, or aes-xts-plain64 when in XTS mode. You can check what mode is being used by running the command dmsetup table as root.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .