Overview
This feature is available with Conduktor Shield only.
Crypto shredding is like throwing away the only key to a locked safe. Without the key, the contents are inaccessible forever.It’s the process of making encrypted data permanently unreadable by securely deleting the encryption keys.
Benefits
Our solution:- stores only a single master key in your external KMS
- securely manages every individual encryption key in Gateway’s internal key store
- allows individual encryption keys to be deleted when needed, rendering the associated data permanently inaccessible
How does it work?
- Gateway can encrypt a combination of the record key, the record headers and the record value.
- It can encrypt the entire key and record value, or individual fields.
- It does this using an encryption key with an ID derived from a property of each record (e.g., a field or key value that uniquely identifies the associated user)
- This encryption key is called a
DEK(short for Data Encryption Key) and is how we will refer to it for the rest of the tutorial. - The
DEKis securely and configurably generated by Gateway using the TINK AEAD cryptographic library
- This encryption key is called a
- Gateway encrypts the
DEKbefore storing it using a single master encryption key provided by an external KMS (e.g., AWS KMS).- The master encryption key is called a
KEK(short for Key Encryption Key) and is how we will refer to it for the rest of the tutorial. - The encrypted
DEKis called anEDEK(short for Encrypted Data Encryption Key) and is how we will refer to it for the rest of the tutorial.
- The master encryption key is called a
- The
EDEKis stored in a dedicated compacted Kafka topic called the Encryption Keys Store.- This store is secure because an
EDEKcannot be decrypted without theKEKfrom the KMS.
- This store is secure because an
- Overwriting an
EDEKin the Encryption Keys Store makes the associated encrypted data permanently undecryptable via Gateway.
Sample use case
This tutorial will show how to:- Set up a local Gateway to encrypt sensitive user data sent to a Kafka topic, using the Gateway KMS.
- Decrypt data read from the same Kafka topic via Gateway (in order to demonstrate normal working conditions).
- Apply crypto shredding to an
EDEKso that associated data can no longer be decrypted by Gateway.
password, visa) using a DEK derived from a unique customer identifier (userId).
Other data (e.g., name) will be left unencrypted. All of the data will come from the same simple json payload. For example, we might expect to see

1. Setup an environment
The following Docker Compose file will setup Kafka, the Conduktor platform and a Vault KMS instance to work together. It will then create a single Kafka topic calledcustomers that the rest of the tutorial will instruct you how to make use of for the encryption and crypto shredding use case.
docker-compose.yaml
docker-compose.yaml
docker-compose.yml
2. Configure the encryption Interceptor
We’ll use the following encryption Interceptor configuration for this use case. Note that:- Encryption will only be applied to the
customerstopic (already automatically created). - Gateway will use (and create if necessary) a single Vault KMS key called
/transit/keys/master-keyas theKEK. - Each record will associate with an Encryption Keys Store Entry derived from the record value
userId(as templated in the configuration).- Each Encryption Keys Store Entry will have a
DEKgenerated by Gateway and stored as anEDEKgenerated by the KMS using theKEK. - Each
DEKwill be used by Gateway to encrypt thepasswordandvisafields. For example, the sample JSON from earlier would have an Encryption Keys Store Entry with idsec-12345678and the associatedDEKwould be used to encrypt both thepasswordfieldadmin123and thevisafield4111111145551142.
- Each Encryption Keys Store Entry will have a
- This configuration requires raw JSON, AVRO or Protobuf record values to be sent. We’ll send JSON.
- Conduktor CLI
- Console UI
encryption-interceptor.yaml
encryption-interceptor.yaml in the same directory as your docker-compose.yaml and run the following command:3. Produce encrypted data
With encryption configured, we can now produce records via Gateway that will be encrypted at rest on disk in the backing Kafka cluster (and when re-reading via Kafka or Gateway). Here’s a high-level visualization of the produce process:
- Conduktor CLI
- Console UI
password and visa are encrypted as configured, while other fields (e.g., name) remain unencrypted.
4. Inspect the created keys
Gateway creates keys on demand, so now that we’ve produced two messages with differentsecretIds (sec-101 and sec-102), we’d expect to see the associated EDEKs persisted in a keystore.
Because we are using the Gateway KMS we would also expect the two EDEKs to be persisted in a Kafka topic, so that we can later crypto shred them.
The Vault KMS should only contain the master key (/transit/keys/master-key) which was used to encrypt each EDEK.
The following diagram visualizes how the produce process works, including the caches which prevent either KMS being overwhelmed by high traffic.

- Conduktor CLI
- Console UI
The following The following command should return exactly two EDEKs from the
curl command should return master-key:_conduktor_gateway_encryption_keys topic that Gateway uses as its Encryption Keys Store.| Key | Value |
|---|---|
{"algorithm":"AES128_GCM","keyId":"gateway-kms://sec-101","uuid":"8dc60b5e-b53b-4804-bb02-b827792c9ee4"} | {"edek":"vault:v1:5FWLvI/AcXn5ABTBPGONK5yqNVEdnxDfU6FWN8hvIb5aKy3lsXxgFF9LfLr6Og=="} |
{"algorithm":"AES128_GCM","keyId":"gateway-kms://sec-102","uuid":"492d6b5e-c353-4bc1-9768-0d2f3b074a92"} | {"edek":"vault:v1:5RALxs8+0z4w9Xu9ZlEhdTzrti3Laj5JD+5oF06TafLAg+0qHLPjGog3T+jSTA=="} |
EDEK) that match the two keyIds.
As the number of records with different keyIds grows, this can lead to substantial cost savings and improved performance compared to storing the same keys in the KMS.
The record Key is composed of:
algorithm: hardcoded in the configuration and then used to generate the associatedDEKin this recordkeyId: templated in the configuration and evaluated using data from the associated record (theuserIdfield)uuid: uniquely generated per inserted record
edek: theDEKgenerated by Gateway and encrypted using the GatewayKMS.
The
uuid field is necessary because it’s possible for two different Gateway nodes to process a record with the same userId for the first time at the same time.In such a scenario two Encryption Keys Store records with the same keyId but a different uuid would be created (thus avoiding a race condition).This means that it’s possible (although relatively rare) for the same keyId to have multiple EDEKs (i.e., multiple EDEKs to be assigned to the same user).Make a copy of the UUID returned for
"keyId":"gateway-kms://sec-101" as we’ll need it for crypto shredding the associated EDEK in step 7: Crypto shredding.5. Configure Gateway decryption Interceptor
The decryption Interceptor configuration mirrors the encryption Interceptor configuration that we added earlier. As before, pick the preferred method:- Conduktor CLI
- Console UI
decryption-interceptor.yaml
decryption-interceptor.yaml in the same directory as your docker-compose.yaml and run the following command:6. Consume and decrypt data
With a decryption Interceptor configured on consumption (from the same topic we’ve been encrypting data), it’s now possible to decrypt and read the records. Here’s a diagram visualizing how the consume process works for our use case, including the caches which prevent either KMS being overwhelmed by high traffic:
- Conduktor CLI
- Console UI
Although we now produce and consume un-encrypted data, the
password and visa fields are still encrypted at rest (on disk in the Kafka broker).If you delete the decryption Interceptor, all of the fields would go back to being encrypted when consumed.7. Crypto shredding
Records encrypted with Gateway KMS can have theirEDEKs crypto shredded by tombstoning the associated record in the Encryption Keys Store topic.
The same keyId can have multiple record entries, so it’s important to tombstone every record sharing the same keyId (each will have a unique uuid).
We currently don’t offer an automated solution for this process; you have to read the entire topic manually and find every record with the keyId which needs tombstoning.
For this tutorial, we only published two records and both had a different keyId, so we can be confident that only one record needs tombstoning.
- Crypto shred using the CLI
- Crypto shred using Console UI
EDEK that we’ve crypto shredded as null (or empty, if consuming via the CLI).
Gateway is now unable to decrypt data associated with it.
To verify this, repeat step 4: Inspect the created keys.
You should see something like the following (if using the UI, the order will be in reverse):
| Key | Value |
|---|---|
{"algorithm":"AES128_GCM","keyId":"gateway-kms://sec-101","uuid":"9871c88e-d5dd-4cb2-86e0-4d65ef0a8361"} | {"edek":"vault:v1:rTbfUBpiPM23WAGu2njeeeqty60BzIPedhl6CL3jaViGDP9Nf0EfRe9+0pbD4A=="} |
{"algorithm":"AES128_GCM","keyId":"gateway-kms://sec-102","uuid":"381e3464-8876-4bcc-9b75-ff49d19a918f"} | {"edek":"vault:v1:c8h+LWonSpPi0Q8Zd8KjHE9GTcxXzvUwAEULDVPQdxDKkSLtiN9teE8lhDeHNw=="} |
{"algorithm":"AES128_GCM","keyId":"gateway-kms://sec-101","uuid":"9871c88e-d5dd-4cb2-86e0-4d65ef0a8361"} | null |
"keyId":"gateway-kms://sec-101" (or first entry if using the UI) should be null. This indicates that it’s been successfully crypto shredded.
There are two entries for
"keyId":"gateway-kms://sec-101" because Kafka compaction isn’t instantaneous.Gateway guarantees to use the latest record and to prevent decryption if the associated EDEK has been shredded.However, the earlier record still exists on disk and its EDEK is available to anyone who consumes the Kafka topic directly.This means that it is technically possible for someone with access to the topic and the KEK to recover crypto shredded data. The key should eventually be deleted because the topic is configured for compaction, but there’s no guarantee of when that will occur.Reducing the time until encrypted encryption keys are deleted from disk is possible but beyond the scope of this tutorial.8. Verify crypto shredded record no longer decrypts
Once an EDEK has been crypto shredded, Gateway will pass any associated records directly to consumers without attempting to decrypt them. The following diagram visualizes how the consume process works for our use case.
- The record
userId:101is associated with the crypto shreddedkeyId:sec-102and is no longer decryptable. - The record
userId:102is associated withkeyId:sec-101and is decryptable.
Gateway crypto shredding only applies to historical records.If a new record was produced for
userId: 101 at this point, then a new EDEK would be created (with a new UUID that doesn’t conflict) and the new record would be decryptable.Historical records will remain crypto shredded.