SlideShare a Scribd company logo
Kafka Security 101
& Real World Tips
Stephane Maarek - DataCumulus
My Kafka Security Journey
Stephane, implement
Kafka Security!
Who am I?
• I’m Stephane!
• Consultant & Solution Architect at DataCumulus
• Apache Kafka SeriesVideo Courses on Udemy
• Full productions deployments (with security)
• You can find me on
• GitHub: https://github.com/simplesteph
• LinkedIn: https://www.linkedin.com/in/stephanemaarek
• Medium: https://medium.com/@stephane.maarek
• Twitter: https://twitter.com/stephanemaarek
• Udemy: https://udemy.com/stephane-maarek
Who has not secured Kafka?
Kafka without Security is RISKY
5 disastrous scenarios
1. Read all your data
2. Write to any topic and break your consumers
3. Intercept and read plaintext network packets
4. Delete all your Kafka data in one command without SSH
5. Kafka Connect? Database Credentials are in a Kafka Topic, plaintext
You need Kafka Security
If you intend to make Kafka a cornerstone of your infrastructure
What’s Kafka Security?
Disclaimer: the source of truth is always the documentation
Kafka Security in three words
Encryption
Authentication
Authorization
Encryption in Kafka
• SSL encryption = secure communications
• Similar to HTTPS
Super secret
message
Kafka Client
(producer / consumer )
Kafka Brokers
Port 9093 - SSL
aGVsbG8gd29
ybGQgZWh…
Encrypted data
Kafka Client
(producer / consumer )
Kafka Brokers
Port 9092 - PLAINTEXT
SSL, Concretely?
• Create a Certificate Authority (CA)
• Generate certificates for your brokers, sign them
• Make sure your broker and clients trust the CA Root.
ssl.keystore.location=/home/ubuntu/ssl/kafka.server.keystore.jks
ssl.keystore.password=serversecret
ssl.key.password=serversecret
ssl.truststore.location=/home/ubuntu/ssl/kafka.server.truststore.jks
ssl.truststore.password=serversecret
SSL in the Real World
• SSL lowers the performance of your brokers
• You lose the zero-copy optimization
• Kafka heap usage increases
• CPU usage increases
• SSL only allows to encrypt data in flight
• Data at rest sits un-encrypted on Kafka Disk
What about end-to-end encryption?
• Closed source: Apple
• Open source:
• https://github.com/Quicksign/kafka-encryption
• https://github.com/nucypher/kafka-oss
• POC in progress at DataCumulus
Producer
Kafka
PLAINTEXT
Consumer
Encrypted
data
Encrypted
data
encrypt data decrypt data
Check Point
Encryption
Authentication
Authorization
Authentication in Kafka
• Clients need to have and prove their identity
• ~= Login (username / password or token)
Kafka Client Kafka Broker
Authentication data
Verify authentication
Client is authenticated
99 Forms Of Authentication
But Easy Ain’t One
• SSL Authentication: two way client authentication
• SASL (Simple Authentication and Security Layer):
• SASL/GSSAPI (Kerberos) – v0.9.0.0+ - Enterprises (Microsoft AD)
• SASL/PLAIN – v0.10.0.0+ - Passwords hardcoded in broker
• SASL/SCRAM-SHA-256/512 – v0.10.2.0+ - Passwords in Zookeeper (secure it)
• SASL/OAUTHBEARER – v2.0+ - Leverage OAuth 2
• Write your own (contribute back!)
• Extend SASL/PLAIN and SASL/SCRAM with KIP-86 (change credentials store)
• Real world advice:
choose the authentication mechanism you already have in your enterprise
Take-aways from the battlefield
• SSL authentication makes it really hard to revoke authentication
• SASL (Simple Authentication and Security Layer) is not simple (YMMV)
• Kerberos is by far the hardest to setup right. Errors are cryptic
• This is the most challenging part of the Kafka security journey
Authentication in Kerberos, concretely?
1. Create Kerberos or use Active Directory
2. Ensure Kafka servers have correct CNAME & hostname
3. Generate credentials for the brokers
4. Generate KeyTabs for the brokers from the credentials
5. Create a JAAS file:
KafkaServer {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
storeKey=true
keyTab="/tmp/kafka.service.keytab"
principal="kafka/<<KAFKA-SERVER-INTERNAL-DNS>>@KAFKA.SECURE";
};
Authentication in Kerberos, concretely?
Continued…
• Start Kafka and use java options to reference JAAS file
• Add properties to Kafka:
• Start Kafka
• Pray !
advertised.listeners=SASL_SSL://<<KAFKA-SERVER-DNS>>:9094
sasl.enabled.mechanisms=GSSAPI
sasl.kerberos.service.name=kafka
Real-World Tips: Authentication
• Turn on DEBUG log during setup!
• Go slow
• Ensure CNAME and PTR records are correct
• Scrape and repeat can sometimes solve issues
• Automate
Almost there…
Encryption
Authentication
Authorization
Authorisation in Kafka
• Kafka knows our client’s identity
• + Authorization rules:
• ”User alice can read topic finance”
• ”User bob cannot write topic trucks”
• = Security
• ACL (Access Control Lists) have to be maintained by administrators
ACLs, where are they?
• Default:ACLs are stored in Zookeeper
• Must secure Zookeeper (network rules or authentication)
• OR write your own authorizer (AD, LDAP, a database, Kafka…)
Managing ACLs
Producers
• Adding Permissions:
• Shortcuts for producer:
~/kafka/bin/kafka-acls.sh 
--authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 
--add --allow-principal User:myproducer --operation Write --topic mytopic
~/kafka/bin/kafka-acls.sh 
--authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 
--add --allow-principal User:myproducer --producer --topic mytopic
Managing ACLs
Consumers
• Adding Permissions:
• Shortcut for consumers:
~/kafka/bin/kafka-acls.sh 
--authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 
--add --allow-principal User:myconsumer --operation Read --topic mytopic
~/kafka/bin/kafka-acls.sh 
--authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 
--add --allow-principal User:writer --consumer --topic mytopic
~/kafka/bin/kafka-acls.sh 
--authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 
--add --allow-principal User:myconsumer --operation Write --group mygroup
Managing ACLs at Scale?
• Look into Kafka Security Manager
(https://github.com/simplesteph/kafka-security-manager )
Real World Tips on ACLs
• Authorisation denials will be logged as INFO in the Kafka log.
• Define your broker as super users
• Careful with: allow.everyone.if.no.acl.found=true
• ACLs can be applied to:
• Topics: Create, Read, Describe,Write, etc…
• Groups: Read,Write, Describe
• Cluster: DescribeConfigs,AlterConfigs, Create
• Wildcards are supported in Kafka 2.0! (useful for Kafka Streams)
Cluster Security
Broker
Broker
Broker ZookeeperSASL_SSL
SASL
Clients
SASL_SSL
Kafka Cluster Zookeeper Cluster
Kafka Server is Secured ! Done?
Encryption
Authentication
Authorization
Security Journey
Continued…
Stephane, secure
Kafka Clients!
Broker
Security
Client Security
YOU
Kafka Client Security
is the real challenge
• Technical Challenge:
• Java Clients: easy
• Non Java Clients: please use a client that wraps librdkafka
• People Challenge:
• Kafka Administrator: I’m a security guru! But I don’t want to secure all the apps
• Kafka Developer: wt* is security?
Client Security in Java
security.protocol=SASL_SSL
sasl.kerberos.service.name=kafka
ssl.truststore.location=/home/kafka/ssl/kafka.client.truststore.jks
ssl.truststore.password=clientpass
sasl.jaas.config='com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
storeKey=true
useTicketCache=false
keyTab="/etc/security/keytabs/client.service.keytab"
principal="clientusername";'
• It’s not fun
• It’s not easy
• It’s error prone
Kafka Clients are not tailored to your
security needs
• Observation 1: Default Kafka clients have every options for security
• Observation 2: Your enterprise will only have one security setup
• Observation 3: Every client security configuration will look the same
• Take-away: don’t use the default Kafka clients
Real World Advice #1
Distribute your own wrapped Kafka Clients
• Developers love nice APIs:
• Standardized applications
• No copy and paste errors
• Centralized debugging
• Reduced learning curve for devs
new MyCorpKafkaProducer(bootstrapServers, keySerializer, valueSerializer)
.withSSL(sslEnabled, pathToTrustStore)
.withAuth(authEnabled, pathToKeyTab, usernameOrPrincipal)
.withSchemaRegistry(url)
.withExtraProperties(properties)
.build()
Real World Advice #2
Create a Kafka Client Base Docker Image
Security at scale goes hands in hands with consistency.
• Embed modified Java Truststore
• Standard Retrieval of SSL certificates
• Standard Retrieval of Credentials fromVault / Secure Store
• Kafka environment switches, Security switches
• Bootstrap Server Discovery & Schema Registry Discovery
• Extend to Kafka Connect & Schema Registry
Real World Advice #3
Make a checklist before going to prod
• What’s the application username?
• Are all ACLs listed and created?
• Is the application using the MyCorp Kafka clients?
• Is the application running in the standardized Docker Container?
• Are quotas defined for this application?
• Is the application monitored?
• …Check? Release!
Next steps
Where to take your learning from here!
Okay, I want to implement security!
What’s next?
• Read the docs:
• Kafka Documentation: https://kafka.apache.org/documentation/#security
• Confluent Documentation: https://docs.confluent.io/current/security.html
• Read some blogs:
• https://medium.com/@stephane.maarek/introduction-to-apache-kafka-security-
c8951d410adf
• https://www.confluent.io/blog/apache-kafka-security-authorization-authentication-
encryption/
• Video Course:
• ConfluentYoutube: https://www.youtube.com/watch?v=MsQo-yoVleU&t=21s
• Udemy: https://www.udemy.com/apache-kafka-security (coupon KAFKASUMMIT18)
Thank you!
Any questions?

More Related Content

PDF
Apache Kafka® Security Overview
PDF
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
PDF
Kafka 101 and Developer Best Practices
ODP
Stream processing using Kafka
PPTX
Apache Kafka Best Practices
PDF
Fundamentals of Apache Kafka
PDF
Securing Kafka
PPTX
Introduction to Apache Kafka
Apache Kafka® Security Overview
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
Kafka 101 and Developer Best Practices
Stream processing using Kafka
Apache Kafka Best Practices
Fundamentals of Apache Kafka
Securing Kafka
Introduction to Apache Kafka

What's hot (20)

PDF
From Zero to Hero with Kafka Connect
PDF
[2018] MySQL 이중화 진화기
PPTX
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
PDF
Kafka Connect & Streams - the ecosystem around Kafka
ODP
Introduction to Kafka connect
PPTX
Kafka 101
PDF
Producer Performance Tuning for Apache Kafka
PDF
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
PDF
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
PDF
ksqlDB - Stream Processing simplified!
PDF
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
PDF
Introduction to Kafka Streams
PDF
Apache Kafka Introduction
PPTX
Apache Kafka 0.8 basic training - Verisign
PPTX
PPTX
Kafka presentation
PDF
Apache Kafka Architecture & Fundamentals Explained
PDF
Apache Kafka Fundamentals for Architects, Admins and Developers
PDF
PDF
A Deep Dive into Kafka Controller
From Zero to Hero with Kafka Connect
[2018] MySQL 이중화 진화기
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Connect & Streams - the ecosystem around Kafka
Introduction to Kafka connect
Kafka 101
Producer Performance Tuning for Apache Kafka
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
ksqlDB - Stream Processing simplified!
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Introduction to Kafka Streams
Apache Kafka Introduction
Apache Kafka 0.8 basic training - Verisign
Kafka presentation
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Fundamentals for Architects, Admins and Developers
A Deep Dive into Kafka Controller
Ad

Similar to Kafka Security 101 and Real-World Tips (20)

PDF
Kafka 2018 - Securing Kafka the Right Way
PPTX
Visualizing Kafka Security
PDF
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
PPTX
Managing your secrets in a cloud environment
PPTX
Azure Low Lands 2019 - Building secure cloud applications with Azure Key Vault
PDF
Securing Cassandra The Right Way
PDF
MariaDB Server & MySQL Security Essentials 2016
PDF
Instaclustr: Securing Cassandra
PDF
Securing Cassandra
PDF
Cassandra and security
PPTX
PPTX
Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
PDF
Better encryption & security with MariaDB 10.1 & MySQL 5.7
PPTX
Techdays Finland 2018 - Building secure cloud applications with Azure Key Vault
PPTX
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
PDF
TechEvent 2019: Wie sichere ich eigentlich Kafka ab?; Markus Bente - Trivadis
PDF
Meet MariaDB Server 10.1 London MySQL meetup December 2015
PDF
IglooConf 2019 Secure your Azure applications like a pro
PPTX
How to Lock Down Apache Kafka and Keep Your Streams Safe
PDF
Training Slides: 302 - Securing Your Cluster With SSL
Kafka 2018 - Securing Kafka the Right Way
Visualizing Kafka Security
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Managing your secrets in a cloud environment
Azure Low Lands 2019 - Building secure cloud applications with Azure Key Vault
Securing Cassandra The Right Way
MariaDB Server & MySQL Security Essentials 2016
Instaclustr: Securing Cassandra
Securing Cassandra
Cassandra and security
Intelligent Cloud Conference 2018 - Building secure cloud applications with A...
Better encryption & security with MariaDB 10.1 & MySQL 5.7
Techdays Finland 2018 - Building secure cloud applications with Azure Key Vault
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
TechEvent 2019: Wie sichere ich eigentlich Kafka ab?; Markus Bente - Trivadis
Meet MariaDB Server 10.1 London MySQL meetup December 2015
IglooConf 2019 Secure your Azure applications like a pro
How to Lock Down Apache Kafka and Keep Your Streams Safe
Training Slides: 302 - Securing Your Cluster With SSL
Ad

More from confluent (20)

PDF
Stream Processing Handson Workshop - Flink SQL Hands-on Workshop (Korean)
PPTX
Webinar Think Right - Shift Left - 19-03-2025.pptx
PDF
Migration, backup and restore made easy using Kannika
PDF
Five Things You Need to Know About Data Streaming in 2025
PDF
Data in Motion Tour Seoul 2024 - Keynote
PDF
Data in Motion Tour Seoul 2024 - Roadmap Demo
PDF
From Stream to Screen: Real-Time Data Streaming to Web Frontends with Conflue...
PDF
Confluent per il settore FSI: Accelerare l'Innovazione con il Data Streaming...
PDF
Data in Motion Tour 2024 Riyadh, Saudi Arabia
PDF
Build a Real-Time Decision Support Application for Financial Market Traders w...
PDF
Strumenti e Strategie di Stream Governance con Confluent Platform
PDF
Compose Gen-AI Apps With Real-Time Data - In Minutes, Not Weeks
PDF
Building Real-Time Gen AI Applications with SingleStore and Confluent
PDF
Unlocking value with event-driven architecture by Confluent
PDF
Il Data Streaming per un’AI real-time di nuova generazione
PDF
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
PDF
Break data silos with real-time connectivity using Confluent Cloud Connectors
PDF
Building API data products on top of your real-time data infrastructure
PDF
Speed Wins: From Kafka to APIs in Minutes
PDF
Evolving Data Governance for the Real-time Streaming and AI Era
Stream Processing Handson Workshop - Flink SQL Hands-on Workshop (Korean)
Webinar Think Right - Shift Left - 19-03-2025.pptx
Migration, backup and restore made easy using Kannika
Five Things You Need to Know About Data Streaming in 2025
Data in Motion Tour Seoul 2024 - Keynote
Data in Motion Tour Seoul 2024 - Roadmap Demo
From Stream to Screen: Real-Time Data Streaming to Web Frontends with Conflue...
Confluent per il settore FSI: Accelerare l'Innovazione con il Data Streaming...
Data in Motion Tour 2024 Riyadh, Saudi Arabia
Build a Real-Time Decision Support Application for Financial Market Traders w...
Strumenti e Strategie di Stream Governance con Confluent Platform
Compose Gen-AI Apps With Real-Time Data - In Minutes, Not Weeks
Building Real-Time Gen AI Applications with SingleStore and Confluent
Unlocking value with event-driven architecture by Confluent
Il Data Streaming per un’AI real-time di nuova generazione
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Break data silos with real-time connectivity using Confluent Cloud Connectors
Building API data products on top of your real-time data infrastructure
Speed Wins: From Kafka to APIs in Minutes
Evolving Data Governance for the Real-time Streaming and AI Era

Recently uploaded (20)

PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
MYSQL Presentation for SQL database connectivity
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
The AUB Centre for AI in Media Proposal.docx
GamePlan Trading System Review: Professional Trader's Honest Take
MYSQL Presentation for SQL database connectivity
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx
Empathic Computing: Creating Shared Understanding
Diabetes mellitus diagnosis method based random forest with bat algorithm
Mobile App Security Testing_ A Comprehensive Guide.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Kafka Security 101 and Real-World Tips

  • 1. Kafka Security 101 & Real World Tips Stephane Maarek - DataCumulus
  • 2. My Kafka Security Journey Stephane, implement Kafka Security!
  • 3. Who am I? • I’m Stephane! • Consultant & Solution Architect at DataCumulus • Apache Kafka SeriesVideo Courses on Udemy • Full productions deployments (with security) • You can find me on • GitHub: https://github.com/simplesteph • LinkedIn: https://www.linkedin.com/in/stephanemaarek • Medium: https://medium.com/@stephane.maarek • Twitter: https://twitter.com/stephanemaarek • Udemy: https://udemy.com/stephane-maarek
  • 4. Who has not secured Kafka?
  • 5. Kafka without Security is RISKY 5 disastrous scenarios 1. Read all your data 2. Write to any topic and break your consumers 3. Intercept and read plaintext network packets 4. Delete all your Kafka data in one command without SSH 5. Kafka Connect? Database Credentials are in a Kafka Topic, plaintext
  • 6. You need Kafka Security If you intend to make Kafka a cornerstone of your infrastructure
  • 7. What’s Kafka Security? Disclaimer: the source of truth is always the documentation
  • 8. Kafka Security in three words Encryption Authentication Authorization
  • 9. Encryption in Kafka • SSL encryption = secure communications • Similar to HTTPS Super secret message Kafka Client (producer / consumer ) Kafka Brokers Port 9093 - SSL aGVsbG8gd29 ybGQgZWh… Encrypted data Kafka Client (producer / consumer ) Kafka Brokers Port 9092 - PLAINTEXT
  • 10. SSL, Concretely? • Create a Certificate Authority (CA) • Generate certificates for your brokers, sign them • Make sure your broker and clients trust the CA Root. ssl.keystore.location=/home/ubuntu/ssl/kafka.server.keystore.jks ssl.keystore.password=serversecret ssl.key.password=serversecret ssl.truststore.location=/home/ubuntu/ssl/kafka.server.truststore.jks ssl.truststore.password=serversecret
  • 11. SSL in the Real World • SSL lowers the performance of your brokers • You lose the zero-copy optimization • Kafka heap usage increases • CPU usage increases • SSL only allows to encrypt data in flight • Data at rest sits un-encrypted on Kafka Disk
  • 12. What about end-to-end encryption? • Closed source: Apple • Open source: • https://github.com/Quicksign/kafka-encryption • https://github.com/nucypher/kafka-oss • POC in progress at DataCumulus Producer Kafka PLAINTEXT Consumer Encrypted data Encrypted data encrypt data decrypt data
  • 14. Authentication in Kafka • Clients need to have and prove their identity • ~= Login (username / password or token) Kafka Client Kafka Broker Authentication data Verify authentication Client is authenticated
  • 15. 99 Forms Of Authentication But Easy Ain’t One • SSL Authentication: two way client authentication • SASL (Simple Authentication and Security Layer): • SASL/GSSAPI (Kerberos) – v0.9.0.0+ - Enterprises (Microsoft AD) • SASL/PLAIN – v0.10.0.0+ - Passwords hardcoded in broker • SASL/SCRAM-SHA-256/512 – v0.10.2.0+ - Passwords in Zookeeper (secure it) • SASL/OAUTHBEARER – v2.0+ - Leverage OAuth 2 • Write your own (contribute back!) • Extend SASL/PLAIN and SASL/SCRAM with KIP-86 (change credentials store) • Real world advice: choose the authentication mechanism you already have in your enterprise
  • 16. Take-aways from the battlefield • SSL authentication makes it really hard to revoke authentication • SASL (Simple Authentication and Security Layer) is not simple (YMMV) • Kerberos is by far the hardest to setup right. Errors are cryptic • This is the most challenging part of the Kafka security journey
  • 17. Authentication in Kerberos, concretely? 1. Create Kerberos or use Active Directory 2. Ensure Kafka servers have correct CNAME & hostname 3. Generate credentials for the brokers 4. Generate KeyTabs for the brokers from the credentials 5. Create a JAAS file: KafkaServer { com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab="/tmp/kafka.service.keytab" principal="kafka/<<KAFKA-SERVER-INTERNAL-DNS>>@KAFKA.SECURE"; };
  • 18. Authentication in Kerberos, concretely? Continued… • Start Kafka and use java options to reference JAAS file • Add properties to Kafka: • Start Kafka • Pray ! advertised.listeners=SASL_SSL://<<KAFKA-SERVER-DNS>>:9094 sasl.enabled.mechanisms=GSSAPI sasl.kerberos.service.name=kafka
  • 19. Real-World Tips: Authentication • Turn on DEBUG log during setup! • Go slow • Ensure CNAME and PTR records are correct • Scrape and repeat can sometimes solve issues • Automate
  • 21. Authorisation in Kafka • Kafka knows our client’s identity • + Authorization rules: • ”User alice can read topic finance” • ”User bob cannot write topic trucks” • = Security • ACL (Access Control Lists) have to be maintained by administrators
  • 22. ACLs, where are they? • Default:ACLs are stored in Zookeeper • Must secure Zookeeper (network rules or authentication) • OR write your own authorizer (AD, LDAP, a database, Kafka…)
  • 23. Managing ACLs Producers • Adding Permissions: • Shortcuts for producer: ~/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 --add --allow-principal User:myproducer --operation Write --topic mytopic ~/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 --add --allow-principal User:myproducer --producer --topic mytopic
  • 24. Managing ACLs Consumers • Adding Permissions: • Shortcut for consumers: ~/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 --add --allow-principal User:myconsumer --operation Read --topic mytopic ~/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 --add --allow-principal User:writer --consumer --topic mytopic ~/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<<ZOOKEEPER-DNS>>:2181 --add --allow-principal User:myconsumer --operation Write --group mygroup
  • 25. Managing ACLs at Scale? • Look into Kafka Security Manager (https://github.com/simplesteph/kafka-security-manager )
  • 26. Real World Tips on ACLs • Authorisation denials will be logged as INFO in the Kafka log. • Define your broker as super users • Careful with: allow.everyone.if.no.acl.found=true • ACLs can be applied to: • Topics: Create, Read, Describe,Write, etc… • Groups: Read,Write, Describe • Cluster: DescribeConfigs,AlterConfigs, Create • Wildcards are supported in Kafka 2.0! (useful for Kafka Streams)
  • 28. Kafka Server is Secured ! Done? Encryption Authentication Authorization
  • 31. Kafka Client Security is the real challenge • Technical Challenge: • Java Clients: easy • Non Java Clients: please use a client that wraps librdkafka • People Challenge: • Kafka Administrator: I’m a security guru! But I don’t want to secure all the apps • Kafka Developer: wt* is security?
  • 32. Client Security in Java security.protocol=SASL_SSL sasl.kerberos.service.name=kafka ssl.truststore.location=/home/kafka/ssl/kafka.client.truststore.jks ssl.truststore.password=clientpass sasl.jaas.config='com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true useTicketCache=false keyTab="/etc/security/keytabs/client.service.keytab" principal="clientusername";' • It’s not fun • It’s not easy • It’s error prone
  • 33. Kafka Clients are not tailored to your security needs • Observation 1: Default Kafka clients have every options for security • Observation 2: Your enterprise will only have one security setup • Observation 3: Every client security configuration will look the same • Take-away: don’t use the default Kafka clients
  • 34. Real World Advice #1 Distribute your own wrapped Kafka Clients • Developers love nice APIs: • Standardized applications • No copy and paste errors • Centralized debugging • Reduced learning curve for devs new MyCorpKafkaProducer(bootstrapServers, keySerializer, valueSerializer) .withSSL(sslEnabled, pathToTrustStore) .withAuth(authEnabled, pathToKeyTab, usernameOrPrincipal) .withSchemaRegistry(url) .withExtraProperties(properties) .build()
  • 35. Real World Advice #2 Create a Kafka Client Base Docker Image Security at scale goes hands in hands with consistency. • Embed modified Java Truststore • Standard Retrieval of SSL certificates • Standard Retrieval of Credentials fromVault / Secure Store • Kafka environment switches, Security switches • Bootstrap Server Discovery & Schema Registry Discovery • Extend to Kafka Connect & Schema Registry
  • 36. Real World Advice #3 Make a checklist before going to prod • What’s the application username? • Are all ACLs listed and created? • Is the application using the MyCorp Kafka clients? • Is the application running in the standardized Docker Container? • Are quotas defined for this application? • Is the application monitored? • …Check? Release!
  • 37. Next steps Where to take your learning from here!
  • 38. Okay, I want to implement security! What’s next? • Read the docs: • Kafka Documentation: https://kafka.apache.org/documentation/#security • Confluent Documentation: https://docs.confluent.io/current/security.html • Read some blogs: • https://medium.com/@stephane.maarek/introduction-to-apache-kafka-security- c8951d410adf • https://www.confluent.io/blog/apache-kafka-security-authorization-authentication- encryption/ • Video Course: • ConfluentYoutube: https://www.youtube.com/watch?v=MsQo-yoVleU&t=21s • Udemy: https://www.udemy.com/apache-kafka-security (coupon KAFKASUMMIT18)