Bird
Raised Fist0
Kafkadevops~20 mins

Security best practices in Kafka - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Kafka Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this Kafka ACL command?
Consider the following Kafka ACL command to allow a user to produce to a topic:
kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:Alice --operation Write --topic sales-data

What will be the result when Alice tries to produce messages to the topic sales-data?
Kafka
kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:Alice --operation Write --topic sales-data
AAlice can successfully produce messages to the topic sales-data.
BAlice will get a permission denied error when producing to sales-data.
CThe command will fail due to missing consumer permission.
DAlice can only consume messages from sales-data, not produce.
Attempts:
2 left
💡 Hint
Think about what the --operation Write permission allows.
🧠 Conceptual
intermediate
1:30remaining
Which Kafka security feature encrypts data in transit?
Kafka supports several security features. Which one specifically ensures that data sent between clients and brokers is encrypted to prevent eavesdropping?
ASASL (Simple Authentication and Security Layer)
BKerberos Authentication
CACLs (Access Control Lists)
DSSL/TLS (Secure Sockets Layer / Transport Layer Security)
Attempts:
2 left
💡 Hint
Encryption protects data while it moves over the network.
🔧 Debug
advanced
2:30remaining
Why does this Kafka client fail to authenticate?
A Kafka client configured with SASL/PLAIN authentication fails to connect to the broker. The client config snippet is:
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="user1" password="wrongpass";

The broker expects username "user1" with password "correctpass".
What is the cause of the failure?
AThe client is missing the SSL truststore configuration.
BThe client uses SASL_PLAINTEXT instead of SASL_SSL, causing encryption failure.
CThe password in sasl.jaas.config is incorrect, causing authentication failure.
DThe client is using the wrong SASL mechanism; it should be SCRAM-SHA-256.
Attempts:
2 left
💡 Hint
Check the username and password values carefully.
📝 Syntax
advanced
2:00remaining
Which Kafka ACL command syntax correctly removes all ACLs for a user?
You want to remove all ACLs for user Bob. Which command is syntactically correct?
Akafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --remove --principal User:Bob
Bkafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --delete --principal User:Bob
Ckafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --remove --allow-principal User:Bob
Dkafka-acls --authorizer-properties zookeeper.connect=localhost:2181 --remove --principal Bob
Attempts:
2 left
💡 Hint
The correct flag to remove ACLs is --remove and the principal must be specified correctly.
🚀 Application
expert
3:00remaining
How to securely configure Kafka brokers for multi-tenant environment?
You manage a Kafka cluster used by multiple teams. You want to ensure:
1. Each team can only access their own topics.
2. Data in transit is encrypted.
3. Clients authenticate securely.

Which combination of Kafka security features should you enable?
AEnable SSL encryption, configure SASL authentication, and set ACLs restricting topic access per team.
BEnable only ACLs for topic restrictions; encryption and authentication are optional.
CUse plaintext communication with SASL authentication and no ACLs.
DEnable SSL encryption and ACLs but allow anonymous access without authentication.
Attempts:
2 left
💡 Hint
Think about encryption, authentication, and authorization all together.

Practice

(1/5)
1. Which of the following is the primary purpose of using SSL/TLS in Kafka security?
easy
A. To manage access permissions with ACLs
B. To authenticate users with usernames and passwords
C. To encrypt data transmitted between Kafka clients and brokers
D. To compress messages for faster transmission

Solution

  1. Step 1: Understand SSL/TLS role in Kafka

    SSL/TLS is used to encrypt data sent over the network to protect it from eavesdropping.
  2. Step 2: Differentiate from other security features

    Authentication uses SASL, and ACLs manage permissions, not encryption.
  3. Final Answer:

    To encrypt data transmitted between Kafka clients and brokers -> Option C
  4. Quick Check:

    SSL/TLS = Encryption [OK]
Hint: SSL/TLS encrypts data in transit, not authentication or permissions [OK]
Common Mistakes:
  • Confusing SSL/TLS with authentication methods
  • Thinking ACLs handle encryption
  • Assuming SSL/TLS compresses data
2. Which of the following is the correct way to enable SASL authentication in Kafka's server.properties file?
easy
A. acl.enable=true
B. security.protocol=PLAINTEXT
C. ssl.enabled=true
D. sasl.enabled.mechanisms=PLAIN

Solution

  1. Step 1: Identify SASL configuration property

    The property sasl.enabled.mechanisms specifies which SASL mechanisms Kafka accepts.
  2. Step 2: Check other options for correctness

    security.protocol=PLAINTEXT disables security, ssl.enabled is not a valid property, and acl.enable is unrelated to SASL.
  3. Final Answer:

    sasl.enabled.mechanisms=PLAIN -> Option D
  4. Quick Check:

    SASL config uses sasl.enabled.mechanisms [OK]
Hint: SASL uses sasl.enabled.mechanisms property in server.properties [OK]
Common Mistakes:
  • Using PLAINTEXT disables security
  • Confusing SSL properties with SASL
  • Assuming acl.enable controls authentication
3. Given the following ACL command, what permission does it grant?
kafka-acls --add --allow-principal User:Alice --operation Read --topic sales-data
medium
A. Alice can read messages from the sales-data topic
B. Alice can create new topics
C. Alice can delete the sales-data topic
D. Alice can write messages to the sales-data topic

Solution

  1. Step 1: Analyze the ACL command parameters

    The command adds an ACL allowing User:Alice the Read operation on the topic sales-data.
  2. Step 2: Understand the Read operation

    Read permission allows consuming or reading messages from the topic, not writing or deleting.
  3. Final Answer:

    Alice can read messages from the sales-data topic -> Option A
  4. Quick Check:

    ACL Read = Permission to consume messages [OK]
Hint: Read operation in ACL means permission to consume messages [OK]
Common Mistakes:
  • Confusing Read with Write permission
  • Assuming Read allows topic deletion
  • Mixing topic creation with ACL permissions
4. Identify the error in the following Kafka security configuration snippet:
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
medium
A. security.protocol should be SASL_SSL to enable encryption
B. The property should be sasl.mechanism instead of sasl.mechanisms
C. SCRAM-SHA-256 is not a valid SASL mechanism
D. No error, configuration is correct

Solution

  1. Step 1: Check security.protocol value

    SASL_PLAINTEXT enables SASL but does not encrypt traffic, which is insecure for sensitive data.
  2. Step 2: Recommend secure protocol

    Using SASL_SSL enables SASL authentication with SSL encryption, which is a best practice.
  3. Final Answer:

    security.protocol should be SASL_SSL to enable encryption -> Option A
  4. Quick Check:

    Use SASL_SSL for encrypted SASL connections [OK]
Hint: SASL_PLAINTEXT lacks encryption; use SASL_SSL for security [OK]
Common Mistakes:
  • Thinking SASL_PLAINTEXT encrypts data
  • Confusing sasl.mechanism property name
  • Believing SCRAM-SHA-256 is invalid
5. You want to secure a Kafka cluster so that only authenticated users can produce or consume messages, and all traffic is encrypted. Which combination of settings achieves this best?
hard
A. Use PLAINTEXT protocol with ACLs to restrict access, no encryption needed
B. Enable SSL encryption with security.protocol=SASL_SSL, configure SASL authentication, and set ACLs for user permissions
C. Enable SASL_PLAINTEXT for authentication and rely on network firewall for encryption
D. Use SSL only without SASL or ACLs to simplify configuration

Solution

  1. Step 1: Ensure encryption and authentication

    Using security.protocol=SASL_SSL enables both encryption (SSL) and authentication (SASL).
  2. Step 2: Control access with ACLs

    ACLs restrict which authenticated users can produce or consume messages, enforcing permissions.
  3. Final Answer:

    Enable SSL encryption with security.protocol=SASL_SSL, configure SASL authentication, and set ACLs for user permissions -> Option B
  4. Quick Check:

    Encryption + Authentication + ACLs = Secure Kafka [OK]
Hint: Combine SASL_SSL, SASL auth, and ACLs for full security [OK]
Common Mistakes:
  • Using PLAINTEXT disables encryption
  • Relying on firewall instead of encryption
  • Skipping ACLs allows unauthorized access
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard