Example scenario
Imagine a banking application that produces events to a Kafka cluster:- When a customer logs in, the app produces an event to the topic
login-events. - When a payment occurs, the app produces an event to the topic
card-payment-event.
- Are events protected while in transit from producers/consumers to brokers?
- Who is consuming these events and are they authorized to read them?
- How is the data stored on broker disks protected?
Producers and consumers
- Producers: banking app writing to
login-eventsandcard-payment-event. - Consumers: internal data consumers that read one or both topics.
- Encryption for data in transit (TLS).
- Strong client authentication and authorization (SASL / OAuth + ACLs or RBAC).
- Protection of data at rest (disk-level encryption or application-level encryption).
Data in transit: TLS (encryption and client auth)
Encrypt connections between clients and brokers using TLS. For mutual TLS, enable client certificate authentication so brokers verify producer/consumer identities. Example server-side configuration snippets (server.properties):- Use strong cipher suites and rotate certificates regularly.
- Consider standard PKI (internal CA or cloud-managed) to simplify certificate management.
Authentication and authorization: SASL, OAuth, ACLs, RBAC
Kafka supports multiple authentication mechanisms:- SASL/SCRAM for username/password.
- SASL/GSSAPI for Kerberos.
- SASL/OAUTHBEARER for OAuth2 tokens.
card-payment-event and consume permission to login-events using kafka-acls.sh:
- Enforce least privilege per topic and per client.
- Use short-lived tokens (OAuth) or rotate SCRAM credentials regularly.
- Log and audit ACL changes and authentication events.
Data at rest: disk encryption and application-level encryption
Protect broker storage:- Use OS-level disk encryption or cloud provider-managed encryption (e.g., AWS EBS encryption, Azure Disk Encryption).
- Enable full-disk encryption for on-prem clusters.
- For extremely sensitive fields, apply application-level or field-level encryption before producing to Kafka.
Schemas and serialization
Use schema registries and structured serialization (Avro, Protobuf) to:- Enforce schema compatibility.
- Prevent accidental schema drift and certain misuse patterns.

Summary — three primary layers to secure
- Data in transit — ensure TLS between clients and brokers and consider client certificate authentication.
- Authentication & authorization — ensure only allowed clients can access specific topics (SASL/Kerberos/OAuth + ACLs or RBAC).
- Data at rest — ensure stored data on broker disks is encrypted (disk encryption or application-level encryption).
Quick security checklist
- Enable encryption-in-transit (TLS) for all listeners.
- Require client authentication for production clusters.
- Use SCRAM/Kerberos/OAuth for client authentication and integrate with IAM where possible.
- Apply topic-level ACLs or RBAC and follow least privilege.
- Encrypt broker disks or use provider-managed encryption.
- Consider application-level encryption for highly sensitive fields.
- Enforce schemas (Avro/Protobuf) to reduce data-quality issues and accidental misuse.
- Enable logging and auditing for authentication and ACL changes.
When designing Kafka security for sensitive data, combine encryption-in-transit, strong authentication/authorization, and encryption-at-rest. Consider least-privilege access for consumers and evaluate whether additional protections (such as field-level encryption or tokenization) are required for highly sensitive fields.
- Kafka Security Documentation
- TLS (Transport Layer Security) — Wikipedia
- SASL — Wikipedia
- SCRAM — Wikipedia
- Kerberos — MIT
- OAuth2 — OAuth.net
- Avro, Protobuf