Skip to content
Kafka · Guide

Guide: securing a Kafka cluster, layer by layer

Encryption in transit, authentication with TLS, SASL or OAuth, authorization with ACLs or RBAC, secrets, and audit: what each layer protects, the settings involved, and the mistakes we see most often.

A default Kafka installation trusts the network: plaintext listeners, no authentication, and anyone who can reach a broker can read or write any topic. That is fine for a laptop and alarming anywhere else, because Kafka topics tend to carry exactly the data an attacker wants: payments, customer events, change streams from core databases.

This guide goes through the layers of a secure cluster, what each protects, and the mistakes we most often find in assessments. It applies to self-managed Apache Kafka and Confluent Platform; managed services handle some layers for you, and we note where.

1. Network

Keep brokers off the public internet. Use private connectivity (VPC peering, private endpoints, Transit Gateway or equivalents) and firewall rules that allow only known client networks. Use separate listeners for clients, inter-broker traffic and controllers, so each can have its own security settings.

2. Encryption in transit

Enable TLS on every listener, including inter-broker and controller traffic, not only the client listener. Use certificates from your own CA with a plan for rotation before they expire, which is a common cause of outages. Kafka doesn't encrypt data at rest itself: rely on encrypted volumes, and on application-level encryption for fields that must stay unreadable even to platform administrators.

3. Authentication

MechanismFitsWatch for
Mutual TLSService-to-service, where certificates are already managedCertificate issuance and revocation at scale
SASL/SCRAM-SHA-512Simple username and password per service accountStoring and rotating the credentials safely
SASL/GSSAPI (Kerberos)Organisations already on Active Directory or KerberosKeytab management and KDC availability
SASL/OAUTHBEARERCentral identity provider, short-lived tokensToken refresh and the identity provider as a dependency
SASL/PLAINOnly over TLS, and usually only on managed services with API keysNever without TLS: the password travels as sent

Whatever the mechanism: one identity per application, never shared, so access can be revoked for one service and audit logs name the application.

4. Authorization

Turn on an authorizer and deny by default (allow.everyone.if.no.acl.found=false). Then grant the minimum: write and describe on a producer's topics; read on a consumer's topics and its own consumer group. Use prefixed ACLs so a team's rules follow its naming convention, and keep super.users to the platform's own admin identities. Confluent Platform and Confluent Cloud add role-based access control (RBAC) on top, which is easier to manage across many teams and resources.

# broker: a TLS listener for clients using SCRAM, and one for brokers (illustrative)
listeners=CLIENT://:9093,INTERNAL://:9094
listener.security.protocol.map=CLIENT:SASL_SSL,INTERNAL:SSL
inter.broker.listener.name=INTERNAL
sasl.enabled.mechanisms=SCRAM-SHA-512
# brokers present certificates
listener.name.internal.ssl.client.auth=required
# KRaft clusters
authorizer.class.name=org.apache.kafka.metadata.authorizer.StandardAuthorizer
allow.everyone.if.no.acl.found=false
super.users=User:platform-admin
# secrets come from a provider, not from this file
config.providers=file
config.providers.file.class=org.apache.kafka.common.config.provider.FileConfigProvider

An illustrative broker configuration: SCRAM over TLS for clients, TLS between brokers, deny by default. Adapt listener names and paths to your environment.

5. Secrets

Keystore passwords, SASL credentials and connector secrets should not sit in plain text in server.properties or connector configs. Kafka's config providers read values at runtime from files, directories or environment variables, and providers exist for vaults such as HashiCorp Vault and the cloud secret managers. Rotate credentials on a schedule, and test that rotation works before you need it.

6. Audit

Record authentication and authorization decisions (who connected, who was denied, who changed an ACL or a topic) and send them to your SIEM. Confluent provides structured audit logs; on Apache Kafka, the authorizer's logger can be routed for the same purpose. Audit logs are what turns "someone read the payments topic" into a name and a time.

The mistakes we see most. TLS on the client listener but plaintext between brokers. One shared service account for every application. Wildcard ACLs granted during an incident and never removed. Certificates that expire on a weekend with nobody watching. Credentials in plain text in a Git repository's connector configs.

Securing a cluster that is already in use

Most clusters we review are not new. Turning security on in one step would stop every client at once, so we do it in stages:

  1. Add a secure listener (for example SASL_SSL) next to the existing plaintext one. Nothing changes for current clients.
  2. Create identities and ACLs for each application, from an inventory of who reads and writes what. On KRaft, ACLs can only be created once StandardAuthorizer is configured, so configure it now with allow.everyone.if.no.acl.found=true, which still lets through resources that have no ACLs yet.
  3. Move clients to the secure listener one application at a time, with their own credentials.
  4. Switch to deny by default (allow.everyone.if.no.acl.found=false) once every client has ACLs, then watch the authorizer log for denials before they become incidents.
  5. Remove the plaintext listener when no client uses it, and switch inter-broker traffic to TLS.

The order matters at steps 2 and 4: as soon as a topic has any ACL, clients without a matching ACL lose access to it, and with deny-by-default switched on, any client without ACLs stops working immediately. Some teams use a temporary allow.everyone.if.no.acl.found=true during the transition, but it must have an end date.

A short review checklist

  1. Is any listener reachable without TLS or without authentication?
  2. Does every application have its own identity, and is any identity shared?
  3. Are there wildcard ACLs, and who holds super-user rights?
  4. When do the certificates expire, and who is alerted before they do?
  5. Where do credentials live, and when were they last rotated?
  6. Are authorization denials and ACL changes reaching your SIEM?

Managed services

On Confluent Cloud or Amazon MSK, the provider runs the brokers and handles encryption in transit and at rest, patching and much of the network layer. Authentication, authorization (on MSK often IAM access control rather than Kafka ACLs), service accounts, secrets in your applications and audit review remain yours: managed Kafka with a shared API key and broad permissions is no more secure than a self-managed cluster configured the same way.

Compliance

Standards such as PCI DSS, HIPAA and GDPR translate into requirements on these layers: encryption, access control, least privilege, audit trails and retention of personal data. What applies depends on your data and jurisdictions, so treat this guide as the technical side and confirm the requirements with your compliance team.

To keep these settings consistent as the platform grows, manage them as code; see the shared-platform use case. To spot authentication failures and other problems early, see the monitoring guide.

Questions we are often asked

Does TLS slow Kafka down?

It costs CPU on brokers and clients, and it stops brokers using zero-copy transfer when sending data to consumers, so throughput per broker can fall. The cost depends on your hardware, message sizes and Java version; measure it on your own workload. It is rarely a reason not to encrypt.

How do certificate identities map to ACLs?

With mutual TLS, the principal is derived from the certificate's distinguished name. Principal mapping rules let you turn a long DN into a short service name, which keeps ACLs readable.

Is encryption at rest enough for sensitive fields?

It protects the disks, not the data from anyone with read access to the topic. Fields that must stay hidden from platform administrators or other consumers need encryption or tokenisation by the application before the message is produced.

Planning a Kafka migration or a platform clean-up?

The Kafka POD assesses, builds, migrates and hardens Kafka on Confluent, Amazon MSK, Redpanda or Apache Kafka, inside your environment, in a typical 12 weeks.

Kafka POD

Keep reading

Back to blog