Skip to content

Require exact single audience match in local token validation - #167

Merged
gargipanatula merged 1 commit into
aws:mainfrom
gargipanatula:fix-audience-exact-match
Sep 4, 2026
Merged

gargipanatula merged 1 commit into
aws:mainfrom
gargipanatula:fix-audience-exact-match

Conversation

@gargipanatula

@gargipanatula gargipanatula commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Change:
Amend the local JWT validation logic to require a token to strictly have 1 audience (pods.eks.amazonaws.com).

Why:
A token can carry multiple audiences (via the TokenRequest API) so it can be shared between two consumers. A token that names another audience alongside the Pod Identity one is also scoped to that other consumer, so honoring it here would let that consumer exchange a shared token for these credentials (a confused deputy). Limiting to a single audience prevents that. Standaed pod identity webhook-projected tokens are single-audience and unaffected.

Testing:
Extended the tests in claims_validation_test.go to cover single-string, single-element-array, multi-audience, empty, and missing aud forms, both directly and through ValidateClaims. Ran go build ./..., go test ./..., and go vet ./... — all pass.

@gargipanatula
gargipanatula requested a review from a team as a code owner September 3, 2026 23:22
@gargipanatula
gargipanatula force-pushed the fix-audience-exact-match branch from 80b644f to 92dd985 Compare September 3, 2026 23:26
A token whose audience list names another consumer in addition to the
EKS Pod Identity audience is scoped to that other consumer as well.
The local audience check previously accepted such a token because the
expected audience appeared somewhere in the list, which on the
cache-hit path could let a shared token be exchanged for credentials it
should not unlock (a confused deputy).

validateAudience now normalizes the aud claim and accepts only when it
contains exactly one element equal to the expected audience. Table tests
cover single-string, single-element-array, multi-audience, empty, and
missing forms, both directly and through ValidateClaims.
@gargipanatula
gargipanatula force-pushed the fix-audience-exact-match branch from 92dd985 to 68ceadd Compare September 3, 2026 23:27
@gargipanatula
gargipanatula merged commit 93db89b into aws:main Sep 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants