How can you secure sensitive data within Kafka?
Instruction: Describe the mechanisms Kafka offers for securing data at rest and in transit, including considerations for encryption and access control.
Updated
Official answer
Protect each part of the data path, including client connections, inter-broker traffic, controllers and the surrounding Connect, registry, administration and monitoring services.
Use TLS with trusted certificates and hostname verification. Select mutual TLS or an appropriate SASL mechanism for client authentication; SASL alone does not imply transport encryption. Restrict reachable listeners and rotate credentials and trust material without disabling certificate verification.
Enable an authorizer and grant least privilege to distinct service principals. Kafka ACLs cover resources such as topics, groups and transactional IDs. They do not provide field-level or record-level filtering inside a topic: a principal permitted to read it can obtain its readable records. Separate sensitive datasets or encrypt/tokenize fields at the application boundary when required.
Apache Kafka does not supply a general transparent log-encryption feature. Use appropriate encrypted disks/volumes and protect their keys, snapshots, backups and temporary copies. Disk encryption protects storage under its threat model; it does not hide plaintext from an authorized running broker, a privileged compromised host or a consumer with read access. Application encryption has its own key-rotation and processing tradeoffs.
Minimize sensitive payloads and avoid putting secrets into keys, headers, logs or metric labels. Define retention and deletion across replicas and downstream copies, protect audit records, and test denied operations and credential rotation. These measures support a security policy; they do not by themselves prove legal compliance.