Enforce authorization on GcpWorkloadIdentityHttpHandler.getIdentity - #16197
Open
herdiyana256 wants to merge 2 commits into
Open
Enforce authorization on GcpWorkloadIdentityHttpHandler.getIdentity#16197herdiyana256 wants to merge 2 commits into
herdiyana256 wants to merge 2 commits into
Conversation
The GET /v3/namespaces/{namespace-id}/credentials/workloadIdentity endpoint
returned a namespace's configured GCP service account without any
authorization check, while the three sibling endpoints on the same handler
(validate/create/delete) all enforce a NamespacePermission. getIdentity also
calls switchToInternalUser() before reading, so no downstream check applies
either. Any authenticated caller could read another namespace's workload
identity mapping.
Enforce StandardPermission.GET on the target NamespaceId before reading,
mirroring the read path in CredentialProviderHttpHandler.getProfile/getIdentity
and this handler's own write endpoints. The method already declares
throws Exception, so the checked AccessException needs no signature change.
There was a problem hiding this comment.
Code Review
This pull request updates the GcpWorkloadIdentityHttpHandler class to enforce access control when retrieving a workload identity. Specifically, it adds an authorization check using accessEnforcer.enforce with StandardPermission.GET on the requested namespace before retrieving the identity. There are no review comments, and the changes look appropriate, so I have no feedback to provide.
Regression test: an unprivileged principal is rejected by getIdentity, while a principal granted StandardPermission.GET on the namespace succeeds. Uses the real DefaultContextAccessEnforcer + InMemoryAccessController + AuthenticationTestContext stack, mirroring the existing handler authorization tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET /v3/namespaces/{namespace-id}/credentials/workloadIdentity(GcpWorkloadIdentityHttpHandler.getIdentity) returned a namespace's configured GCP service account with no authorization check, while the three sibling endpoints on the same handler enforce aNamespacePermission:validateIdentity(PROVISION_CREDENTIAL),createIdentity(SET_SERVICE_ACCOUNT),deleteIdentity(UNSET_SERVICE_ACCOUNT).getIdentityalso callsswitchToInternalUser()before the read, so any downstream enforcement is bypassed and the handler-level check is the only gate. Any authenticated caller reaching APP_FABRIC_HTTP could therefore read another namespace's workload-identity mapping.This enforces
StandardPermission.GETon the targetNamespaceIdbefore the read, mirroring the read path inCredentialProviderHttpHandler.getProfile/getIdentityand this handler's own write endpoints. The method already declaresthrows Exception, so the checkedAccessExceptionneeds no signature change.If a permission symmetric with the write side is preferred over
StandardPermission.GET, a dedicatedNamespacePermission.GET_SERVICE_ACCOUNTcould be introduced instead; happy to switch.