Normalize string role claims before claim-based role mapping evaluation - #6306
Open
Yanhaoxi wants to merge 2 commits into
Open
Normalize string role claims before claim-based role mapping evaluation#6306Yanhaoxi wants to merge 2 commits into
Yanhaoxi wants to merge 2 commits into
Conversation
Yanhaoxi
requested review from
ChrisJBurns,
JAORMX,
jhrozek,
rdimitrov and
tgrunnagle
as code owners
August 13, 2026 13:03
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6306 +/- ##
==========================================
- Coverage 72.85% 72.83% -0.02%
==========================================
Files 742 742
Lines 77804 77836 +32
==========================================
+ Hits 56683 56693 +10
- Misses 17145 17168 +23
+ Partials 3976 3975 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Fixes #6305. Claim-based role mappings are evaluated with the fixed CEL expression
claim_value in claims[role_claim_key], whose semantics depend on the role claim value's runtime type. cel-go v0.30.0 definesinonly for list/map operands, so a string-typed role claim raised a "no such overload" error thatSelectRoleswallowed and treated as a non-match — the user silently gotFallbackRoleArneven when their claim exactly equaled the configuredClaim. An object-typed role claim madeintest map-key membership, spuriously matching when the configured value was a key.WHAT changed:
normalizeRoleClaim, applied to the role claim value before evaluation: string → one-element list (exact membership restored); missing claim → empty list (fallback preserved); any other shape (object, number, bool, null) → rejected.SelectRolenow fails closed on unsupported claim shapes and claim-mapping evaluation errors (ErrNoRoleMapping, HTTP 403 via theaws_stsmiddleware) instead of silently grantingFallbackRoleArn; matcher-expression errors keep their skip-and-fall-back behavior but log at Warn instead of Debug.Type of change
Test plan
task test)task test-e2e)task lint-fix)Run:
go test ./pkg/auth/awssts/... ./pkg/vmcp/auth/strategies/.... New testsTestRoleMapper_SelectRole_StringRoleClaimandTestRoleMapper_SelectRole_UnsupportedRoleClaimShapeFAIL without the source fix and PASS with it; full suites pass.go vetandgofmtclean;golangci-lintreports only 3 pre-existinggciissues in files this PR does not touch.API Compatibility
v1beta1API. Configuration shape is unchanged.Changes
pkg/auth/awssts/role_mapper.gopkg/auth/awssts/role_mapper_test.goDoes this introduce a user-facing change?
Yes. Two intentional behavior changes:
Claimnow selects the mapped role (e.g.groups: "admins"withClaim: "admins"→AdminRole); previously it silently fell back. Strings merely containing the value still do not match.Special notes for reviewers