memq icon indicating copy to clipboard operation
memq copied to clipboard

rpc: enforce Authorizer on TOPIC_METADATA requests

Open herdiyana256 opened this issue 4 months ago • 0 comments

PacketSwitchingHandler.authorize() only sets a resource for WRITE and READ requests (see the switch statement); TOPIC_METADATA falls to the default case with resource left null, and authorize() returns early whenever resource == null -- so the configured Authorizer is never consulted for TOPIC_METADATA at all, regardless of whether one is configured. A principal the Authorizer would deny on every WRITE/READ still gets the full, unfiltered topic-metadata map back (broker host sets, storage handler config, everything in TopicMetadata) via an empty-topic-list "list all" request, or metadata for any topic named explicitly.

This adds a per-topic authorize check (as a READ) specifically for TOPIC_METADATA: the list-all case is now silently filtered down to topics the caller is authorized for, and requests naming specific topics the caller isn't authorized for now raise NotAuthorizedException, matching how WRITE/READ already behave. When no Authorizer is configured at all (authz not enabled for the broker), behavior is unchanged.

Added TopicMetadataAuthorizationGapPocTest (3 cases: list-all filters out unauthorized topics, an explicitly-named unauthorized topic is rejected instead of returned, and an authorized caller still gets results back). Full memq module suite passes (188/190; the other 2 failures are a pre-existing, unrelated self-signed-certificate generation issue in TestMemqClientServerIntegration.testLocalServerSSL, confirmed unrelated by git diff --stat showing only PacketSwitchingHandler.java touched by this change).

herdiyana256 avatar Jul 30 '26 17:07 herdiyana256