Scrivio Interview library
CodingIntermediate7 min read · updated 13 November 2026

A service with principal User:billing-svc consumes orders with group id billing and transactionally produces to invoices with transactional ids starting billing-tx-. The cluster runs the KRaft StandardAuthorizer with allow.everyone.if.no.acl.found=false.

Write the kafka-acls.sh commands that give it least privilege, and explain each permission.

Grant User:billing-svc Read and Describe on topic orders and Read on group billing for consuming, Write and Describe on topic invoices for producing (since Kafka 3.0 an idempotent producer needs no separate IdempotentWrite permission), and Write and Describe on transactional id billing-tx- with a prefixed pattern so every instance's transactional.id is covered. sendOffsetsToTransaction needs Read on group billing, which the consume ACL already gives. We verify with kafka-acls.sh --list, and a missing grant shows as a Topic, Group or TransactionalId authorization exception in the client and a denial in the authorizer log.

Why this question is asked

With allow.everyone.if.no.acl.found=false, the cluster denies everything that no ACL allows, so a new service starts with no rights at all. That is the right default, but it means we must know exactly which operations each client action needs. Grant too little and the service fails in confusing ways; grant too much, such as All on every topic, and one leaked password exposes the whole cluster. Interviewers like this question because a transactional consume-process-produce service touches every resource type Kafka authorizes. In this answer, we will recap how Kafka ACLs work, write the grants for consuming, producing and transactions, keep the ACL count manageable with prefixes, and verify and debug the result.

1A Quick Recap: Principals, Resources and Operations

An ACL says that a principal may, or may not, perform an operation on a resource. The principal is the authenticated identity, here User:billing-svc. Resources have types: Topic, Group (a consumer group), TransactionalId, Cluster and a few others. Operations include Read, Write, Describe, Create, Delete, Alter and All. A resource pattern is either literal, matching one exact name, or prefixed, matching every name that starts with a string.

In KRaft clusters, ACLs are stored in the metadata log and checked by StandardAuthorizer on every request. With allow.everyone.if.no.acl.found=false, a resource with no matching ACL is denied, so least privilege is the default and every grant below is something the service genuinely needs.

What billing-svc does and what it needs
Client actionResourceOperations
Fetch from ordersTopic ordersRead, Describe
Join group, commit offsetsGroup billingRead
Send to invoices (idempotent)Topic invoicesWrite, Describe
initTransactions, commit, abortTransactionalId billing-tx-*Write, Describe
sendOffsetsToTransactionGroup billingRead (already granted)

2Consuming From orders

A consumer needs Read on the topic to fetch records and Describe to look up its metadata and offsets. It also needs Read on its group to join the group, receive partitions and commit offsets.

Text
kafka-acls.sh --bootstrap-server kafka-1:9093 --command-config admin.properties --add \
--allow-principal User:billing-svc --operation Read --operation Describe --topic orders
kafka-acls.sh --bootstrap-server kafka-1:9093 --command-config admin.properties --add \
--allow-principal User:billing-svc --operation Read --group billing
# same result with the shortcut:
# kafka-acls.sh ... --add --allow-principal User:billing-svc --consumer --topic orders --group billing

The --consumer shortcut grants exactly these three operations, which makes it a handy way to remember them. admin.properties holds the connection settings for an administrator account, because creating ACLs is itself an operation that needs permission (Alter on the cluster).

3Producing to invoices

A producer needs Write on the topic to append records and Describe to fetch its metadata. Before Kafka 3.0, an idempotent producer also needed IdempotentWrite on the cluster resource, a broad permission. Since 3.0, Write on any topic is enough for the producer to get a producer id, so we no longer grant anything at cluster level. Idempotence has been the producer default since 3.0 as well, so this matters for nearly every producer.

YAML
kafka-acls.sh --bootstrap-server kafka-1:9093 --command-config admin.properties --add \
--allow-principal User:billing-svc --operation Write --operation Describe --topic invoices
# Adding ACLs for resource `ResourcePattern(resourceType=TOPIC, name=invoices, patternType=LITERAL)`:
# (principal=User:billing-svc, host=*, operation=WRITE, permissionType=ALLOW)
# (principal=User:billing-svc, host=*, operation=DESCRIBE, permissionType=ALLOW)

Notice that we did not grant Create. Topics on a shared platform are created by the provisioning pipeline, so a service that tries to auto-create a topic should fail rather than silently make one with default settings.

4Transactions: the Transactional Id and the Group

A transactional producer registers a transactional.id with the transaction coordinator. initTransactions, adding partitions to a transaction, and committing or aborting all require Write on that TransactionalId resource, and finding the coordinator needs Describe. Each instance of the service uses its own id, for example billing-tx-0, billing-tx-1 and so on, so a literal grant would have to be updated whenever we scale. A prefixed pattern covers them all.

Text
kafka-acls.sh --bootstrap-server kafka-1:9093 --command-config admin.properties --add \
--allow-principal User:billing-svc --operation Write --operation Describe \
--transactional-id billing-tx- --resource-pattern-type prefixed
# covers billing-tx-0, billing-tx-1, ... and nothing outside the prefix

We run this as its own command because --resource-pattern-type applies to every resource in the command; mixing it with --topic invoices would turn the topic grant into a prefix as well. The last piece is sendOffsetsToTransaction, which commits the consumer's offsets as part of the transaction. The broker checks Read on group billing for that, and we already granted it for consuming, so nothing more is needed. The service now has exactly what its code path uses.

5Keeping ACLs Manageable With Prefixes

One service is five ACL entries. A platform with 150 services and literal grants per topic quickly reaches thousands, which nobody can review. The answer is to give each team a namespace and grant on prefixes. If the billing team owns every topic starting with billing., a single prefixed ACL can give its services rights across all of them, and a new topic in the namespace needs no new ACL.

Wildcards, the resource name *, are reserved for platform tooling such as the lag exporter, which needs Describe on every group. A wildcard on an application principal defeats the whole model, so the provisioning pipeline rejects such requests.

6Verifying and Debugging Denials

After applying the ACLs we list what the principal has, so a reviewer can see the complete picture in one place.

Properties
kafka-acls.sh --bootstrap-server kafka-1:9093 --command-config admin.properties --list --principal User:billing-svc
# Current ACLs for principal `User:billing-svc`:
# ResourcePattern(resourceType=TOPIC, name=orders, patternType=LITERAL): READ, DESCRIBE
# ResourcePattern(resourceType=GROUP, name=billing, patternType=LITERAL): READ
# ResourcePattern(resourceType=TOPIC, name=invoices, patternType=LITERAL): WRITE, DESCRIBE
# ResourcePattern(resourceType=TRANSACTIONAL_ID, name=billing-tx-, patternType=PREFIXED): WRITE, DESCRIBE

When something is missing, the client says which resource type was refused: TopicAuthorizationException names the topics, GroupAuthorizationException the group, and TransactionalIdAuthorizationException appears at initTransactions. On the broker side, the authorizer logger, kafka.authorizer.logger, records each denial with the principal, operation and resource, which is the quickest way to see exactly what was asked for. We keep that log at INFO so denials are always recorded, and ship it to the central log platform.

7Follow-up questions

Why does a consumer need Describe on the topic as well as Read?

Describe lets the client fetch the topic's metadata and offsets, for example to find partition leaders and to list offsets when it starts. Read alone allows fetching records but some of the surrounding requests need Describe, so the two are granted together, which is also what --consumer does.

Do we still need IdempotentWrite on the cluster?

No, not since Kafka 3.0. Write on a topic now allows the InitProducerId request for idempotent producers, so the cluster-level permission is no longer needed. Granting it does no harm, but least privilege says leave it out.

What happens if two services share the transactional id prefix?

They can fence each other: when an instance calls initTransactions with an id another instance is using, the older producer is fenced and fails. That is why each service gets its own prefix and each instance a unique id within it.

8Conclusion

In this answer, we saw that billing-svc needs Read and Describe on orders and Read on group billing to consume, Write and Describe on invoices to produce, with no cluster-level IdempotentWrite since Kafka 3.0, and Write and Describe on a prefixed transactional id billing-tx- for transactions, while sendOffsetsToTransaction reuses the group Read. Prefixed namespaces keep ACLs manageable, wildcards stay with platform tooling, and kafka-acls.sh --list, the client exceptions and the authorizer log let us verify and debug.

What to say in the interviewAbout 70 seconds aloud

Open with

Because allow.everyone.if.no.acl.found is false, the service starts with nothing, so I grant exactly what its code uses. For consuming orders, Read and Describe on topic orders and Read on group billing; the --consumer shortcut with --topic and --group grants the same three.

Then, if they want more

For producing to invoices, Write and Describe on topic invoices. Since Kafka 3.0 an idempotent producer no longer needs IdempotentWrite on the cluster; Write on the topic is enough. For transactions, Write and Describe on transactional id billing-tx- with resource-pattern-type prefixed, in a separate command so the prefix does not apply to the topics.

That covers every instance's transactional.id as we scale. sendOffsetsToTransaction checks Read on group billing, which the consume ACL already gives. I would not grant Create, since topics come from the pipeline. On a shared platform I would use prefixed ACLs per team namespace to keep the count manageable and keep wildcards for platform tooling only.

To verify, kafka-acls.sh list with the principal shows everything in one place. If something is missing, the client throws TopicAuthorizationException, GroupAuthorizationException or TransactionalIdAuthorizationException, and the broker's kafka.authorizer.logger records the denial with the principal, operation and resource.

About this answer

Last updated
13 November 2026
Versions it names
Kafka 3.0
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Write the kafka-acls.sh commands that give it least privilege, and explain each...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/caf4d9602d/