skip to content

Encryption at Rest and Governance

Protecting data on disk with volume or KMS encryption, encrypting sensitive payloads client-side, and meeting audit and GDPR requirements. Interviewers ask because Kafka has no native log-segment encryption.

part ofApache Kafkaoverview, primer and where to startread it →
on this pageshow

questions

5

Does Apache Kafka natively encrypt the data it writes to disk (log segments)? If not, how do teams achieve encryption at rest?

level: juniorimportance: must knowfreq 70%

answer

  1. No native log-segment encryption
  2. LUKS / KMS-backed EBS = disk layer
  3. Client-side payload = above broker
  4. TLS = in transit only
  5. log.dirs files are plaintext

basics

~20 s

No. Open-source Kafka has no built-in encryption of log segment files on disk. Encryption at rest is provided externally: encrypt the broker's volume/disk (LUKS or a cloud KMS-backed encrypted EBS volume), or encrypt the message payload before producing it.

solid answer

~40 s

Apache Kafka does not encrypt its on-disk log segments natively; the .log files under log.dirs are written as plaintext bytes. There are two standard ways to get encryption at rest. First, volume/disk encryption beneath Kafka: Linux LUKS/dm-crypt on the data partition, or a cloud-managed encrypted volume such as an AWS EBS volume backed by KMS, GCP persistent disk with CMEK, or Azure disk encryption. This is transparent to Kafka and protects against stolen disks but not against a compromised broker process. Second, client-side (application-level) payload encryption: the producer encrypts the message value before send() and the consumer decrypts after poll(), so the broker only ever stores ciphertext. This protects PII even from broker operators but breaks compaction-by-content and server-side filtering. TLS (SSL) only protects data in transit, not at rest.

go deeper

for a junior

Know the headline: Kafka does not encrypt files on disk by itself; you encrypt the disk (LUKS/cloud KMS) or encrypt the payload in the client.

for a middle

Distinguish in-transit (TLS) vs at-rest, and disk-layer vs application-layer encryption with their different threat coverage.

for a senior

Reason about which threats each layer covers (stolen disk vs malicious broker) and the trade-offs of client-side encryption (compaction, filtering, key mgmt).

for a principal

Design a layered posture combining KMS-backed volumes + selective client-side PII encryption, and articulate why neither alone is sufficient.

## The core fact Apache Kafka stores messages in **log segments** — append-only files (named like `00000000000000000000.log`) inside the directories listed in the broker's `log.dirs` setting. Open-source Kafka writes these bytes to disk exactly as received; there is **no configuration that encrypts log segments at rest**. If someone reads the raw files (or steals the disk), they see the message data in the clear. This surprises people because Kafka has strong security features — but those cover *other* threats: - **TLS / SSL** (`security.protocol=SSL` or `SASL_SSL`) encrypts data **in transit** between clients and brokers, and between brokers. It does nothing for data sitting on disk. - **SASL** handles **authentication** (proving who you are). **ACLs** handle **authorization** (what you may do). Neither encrypts stored bytes. ## How teams actually achieve encryption at rest There are two layers, often combined. ### 1. Volume / disk encryption (below Kafka) Encrypt the storage that holds `log.dirs`, transparently to Kafka: - **LUKS / dm-crypt** on Linux: the block device is encrypted; the OS decrypts on read using a key held in memory. - **Cloud KMS-backed volumes**: AWS **EBS encryption** (keys in AWS KMS), GCP persistent disks with **CMEK** (customer-managed encryption keys), Azure disk encryption. The cloud provider encrypts/decrypts blocks; the key lives in a Key Management Service. **Protects against:** a stolen/decommissioned physical disk, or a snapshot leaking. **Does NOT protect against:** anyone who can read through the running broker (the data is decrypted in memory and via the filesystem), or a broker operator with shell access. ### 2. Client-side / application-level payload encryption (above Kafka) The **producer encrypts the message value before sending**; the **consumer decrypts after receiving**. The broker only ever stores ciphertext. - Implemented via a custom `Serializer`/`Deserializer`, an interceptor, or a library (e.g., envelope encryption with a KMS-issued data key). **Protects against:** even the broker operator and anyone reading the disk — true end-to-end for the payload. **Trade-offs:** key management complexity; you usually leave the **key/headers in cleartext** so partitioning still works; **log compaction by content and server-side filtering can't inspect ciphertext**; CPU cost. ## Putting it together A common production posture is **both**: KMS-backed encrypted volumes for defense-in-depth against physical/snapshot theft, **plus** client-side encryption for sensitive fields (PII) so the broker never sees plaintext. TLS is added on top for in-transit protection. The interview trap is to say 'enable Kafka's at-rest encryption setting' — there is none.

  • What threat does disk/volume encryption NOT protect against?
    A compromised or malicious broker process/operator — the data is decrypted in memory and through the filesystem while the broker runs, so anyone reading through the live broker sees plaintext. It only protects against stolen/decommissioned disks or leaked snapshots.
  • Why doesn't TLS count as encryption at rest?
    TLS (security.protocol=SSL/SASL_SSL) encrypts bytes only while they travel over the network. Once a broker receives and writes a message, it is decrypted and stored as plaintext in the log segment. At-rest means while stored on disk.

saying these in an interview costs you the question

  • Claiming Kafka has a built-in setting to encrypt log segments at rest
  • Saying TLS/SSL provides encryption at rest
  • Believing disk encryption protects against a compromised broker process
  • Confusing authentication (SASL) or authorization (ACLs) with encryption

context

open as a page

How would you implement client-side (application-level) encryption for PII fields in Kafka messages, and what are the trade-offs?

level: seniorimportance: must knowfreq 60%

basics

~20 s

Encrypt the sensitive payload in the producer before send() and decrypt in the consumer after poll(), typically via a custom Serializer or interceptor using envelope encryption: a KMS issues a data key that encrypts the message, and the wrapped data key travels alongside. The broker stores only ciphertext.

open as a page

How do you audit authentication and authorization (ACL) decisions in Kafka for governance and compliance?

level: middleimportance: should knowfreq 40%

basics

~20 s

Kafka's authorizer logs allowed/denied authorization decisions. Enable the authorizer logger (kafka.authorizer.logger) at INFO/DEBUG to capture which principal was allowed or denied which operation on which resource. Ship those logs to a central, tamper-evident store. Enterprise distributions (Confluent) add structured audit-log topics.

open as a page

A GDPR erasure request requires deleting all of a user's data from a compacted Kafka topic. How do tombstones and retention/compaction make this work, and what are the caveats?

level: seniorimportance: should knowfreq 45%

basics

~20 s

On a compacted topic, produce a tombstone — a record with the user's key and a null value. Log compaction eventually removes all prior records for that key and then drops the tombstone after delete.retention.ms. Deletion is asynchronous, not immediate, and only works per key.

open as a page

Compare KMS-backed volume encryption versus client-side payload encryption for Kafka: which threats does each address, and when would you mandate both?

level: principalimportance: should knowfreq 35%

basics

~20 s

Volume encryption (KMS-backed EBS, LUKS) protects against stolen disks and leaked snapshots but the running broker still sees plaintext. Client-side payload encryption protects PII even from the broker/operator but breaks content-based features and adds key-management cost. Mandate both for regulated PII: defense-in-depth plus operator-proof confidentiality.

open as a page