Skip to content

Transparent encrypted storage

Name

Transparent encrypted storage

Summary

All data that has to be added to a storage system is automatically encrypted before it is actually written. All encryption and decryption actions happen transparently from the perspective of the entities using the storage system.

Parent

None

Problem

Solution

In this encrypted storage pattern encryption (and decryption) happen transparently from the perspective of the entities that want to write (or read) data to a storage system. In other words, the clients of the storage system do not request the cryptographic actions themselves, the storage system does this automatically for them. Consequently, this pattern will not stop data from leaking to attackers that interact with the storage system via legitimate clients. It does protect data a rest from an attacker with access the storage system through other means, e.g. physical access to the hard drive or server in question.

This pattern instantiates the Encryption pattern as an cryptographic layer in between the client entities and the actual storage entity.

Roles

  • Writer (: Entity) wants to write one or more data elements to the Data storage
  • Reader (: Entity) wants to read one or more data elements from the Data storage
  • Crypto enforcer (: Entity) manages the read and write requests for the Data store
    • Crypto enforcer <- Encryption.EntityA, Encryption.EntityB
  • Cryptographer (: Cryptographic primitive) a cryptographic primitive that can at least encrypt and decrypt data elements.
    • Cryptographer <- Encryption.Encryption provider
  • Data storage (: Storage) in which data stored persistently, e.g. a hard drive or database

Actions

  • write (: Action) the provided data element(s) to the Data storage under the given identifier, if any
  • encrypt (: Action) a given plaintext d using the identified key and the given cipher configuration, if any
  • read (: Action) the data element(s) stored under the given identifier in Data storage
  • decrypt (: Action) a given ciphertext {d}_k using the identified key and the given cipher configuration, if any

Note

Depending on the used cryptographic library the encrypt and decrypt actions may have to be refined into multiple calls to the library's API. For example, it might be necessary to first instantiate the library with a configuration before encrypting or decrypting any data.

Data elements

  • d (: Data) a plaintext data element
    • d <- Encryption.plaintext
  • {d}_k (: Data) a ciphertext obtained by encrypting plaintext d with cryptography key k
    • {d}_k <- Encryption.ciphertext
  • keyInfoE (: Data) information on the cryptographic key that should be used to encrypt the plaintext. This can, for example, be an identifier so that the Cryptographer knows which key to retrieve or the cryptographic key itself.
    • Tags: Untampered[, Secret]
    • keyInfoE <- Encryption.keyInfo
  • configE (: Data) the necessary information for the Cryptographer to initialise the required encryption cipher. The exact (possible) values depend on the selected cryptographic library, some possible options are key length, mode, and block size.
    • Tags: Untampered
    • ConfigE <- Encryption.config
  • idW (: Data) the identifier under which the Data storage has to write the given data element(s)
  • idR (: Data) the identifier of the data element(s) the Reader wants to retrieve
  • keyInfoD (: Data) information on the cryptographic key that should be used to decrypt the ciphertext. This can, for example, be an identifier so that the Cryptographer knows which key to retrieve or the cryptographic key itself.
    • Tags: Untampered[, Secret]
    • keyInfoD <- Encryption.keyInfo
  • configD (: Data) the necessary information for the Cryptographer to initialise the required decryption cipher. The exact (possible) values depend on the selected cryptographic library, some possible options are key length, mode, and block size.
    • Tags: Untampered
    • configD <- Encryption.config
  • ack (: Data) a message indicating that data was successfully written to Data storage (Optional)
  • error (: Data) a message indicating no data element(s) were found to match the provided identifier

Behaviour

Writing (new) data to Data storage (W.n flows)

  1. The Writer sends the plaintext data d to be stored to the Crypto enforcer, possibly accompanied by the identifier under which is should be stored.
  2. The Crypto enforcer forwards the received data to the Cryptographer along with the required key information and, optionally, a configuration for the encryption cipher.
  3. The Cryptographerperforms the requested encryption and replies the resulting ciphertext {d}_k to the Crypto enforcer.
  4. The Crypto enforcer forwards the received ciphertext to the Data storage to actually store it.
  5. The Data storage writes the received data and acknowledges this to the Crypto enforcer, possibly also providing the identifier under which the data was written.
  6. The Crypto enforcer forwards the acknowledgement and/or identifier to the Writer.

Reading stored data from Data storage (R.n flows)

  1. The Reader requests from the Crypto enforcer the data element(s) stored under a given identifier.
  2. The Crypto enforcer requests from Data storage the ciphertext(s) stored under the given identifier.
  3. The Data storage retrieves the stored ciphertext(s) {d}_k, if any, and replies them to the Crypto enforcer.
  4. The Crypto enforcer requests the Cryptographer to decrypt the retrieved ciphertext(s) using the identified key and, if provided, the decryption cipher configuration.
  5. The Cryptographer decrypts the ciphertext(s) and replies the corresponding plaintext(s) d to the Crypto enforcer.
  6. The Crypto enforcer forwards the received plaintext(s) to the Reader.

All data elements transmitted by Writer to storage are automatically encrypted before they are actually
written.

Role considerations

Identify sensitive data (Writer)

Crucial to determining which data should be encrypted before storage is to identify the sensitive data processed by the system. Once identified, it is advised to asses which sensitive data should be persistently stored and minimise this amount to what is strictly necessary for the system at hand.1 Data that is not stored cannot leak from storage. Furthermore, it should be avoided to cache data that was identified as sensitive as it could leak from such caches.

Encryption role considerations

All role considerations of the instantiated Encryption pattern should also be followed.

Data considerations

Encryption data considerations

All data considerations of the instantiated Encryption pattern should be followed.

Implementations

None

References


  1. OWASP, ‘Cryptographic Storage Cheat Sheet’, OWASP Cheat Sheet Series. https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html ↩


Last update: February 4, 2022