fix(broker): emit https://aws.amazon.com/tags claim so STS sets PrincipalTag#68
Closed
hanwencheng wants to merge 1 commit intomainfrom
Closed
fix(broker): emit https://aws.amazon.com/tags claim so STS sets PrincipalTag#68hanwencheng wants to merge 1 commit intomainfrom
hanwencheng wants to merge 1 commit intomainfrom
Conversation
5 tasks
Member
Author
|
Consolidating with #67 into a single PR for the Stage 7 federation fix (docs + broker code together — same conceptual change). |
3 tasks
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
The OIDC broker mints JWTs with
agentkeys_user_walletas a top-level claim, but AWS STS does not auto-promote arbitrary claims to session tags. It looks specifically for the magic-namedhttps://aws.amazon.com/tagsclaim withprincipal_tags(and optionallytransitive_tag_keys). Without that claim:sts:AssumeRoleWithWebIdentityreturns a session with no PrincipalTag${aws:PrincipalTag/agentkeys_user_wallet}in bucket policies expands to emptyThis PR adds the AWS-magic claim to the JWT in
mint_oidc_jwtand a regression-guard test assertion.Spec: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#oidc-session-tags
Reproduction (before this fix)
End-to-end §4.5 against the deployed prod broker, with the §4.4 bucket policy correctly applied (PR #67) and the §3 inline-policy broad grant removed:
Both succeed because the bucket policy's
${aws:PrincipalTag/agentkeys_user_wallet}expands to empty (no tag set), and theStringLike "${tag}/*"condition then becomesStringLike "/*"which matches nothing — so the bucket policy denies both. Combined with theagentkeys-data-role-inlinestatic-IAM grant the runbook also leaves attached (separate runbook fix in #67), the request falls through to broad-bucket access. Net: no tenant boundary anywhere.Decoded JWT confirming the missing claim:
{ "agentkeys_user_wallet": "0xe5cc...", "aud": "sts.amazonaws.com", "exp": 1778086977, "iat": 1778086677, "iss": "https://broker.litentry.org", "sub": "agentkeys:agent:0xe5cc..." }No
https://aws.amazon.com/tags. After this PR's fix, the JWT will additionally carry:Changes
crates/agentkeys-broker-server/src/handlers/oidc.rsmint_oidc_jwtbuilds thehttps://aws.amazon.com/tagsclaim withprincipal_tags.agentkeys_user_wallet = [session.wallet].transitive_tag_keysensures the tag survives if the daemon role-chains.claims_supportednow advertiseshttps://aws.amazon.com/tags.crates/agentkeys-broker-server/tests/oidc_flow.rsmint_oidc_jwt_signs_claims_for_session_walletnow asserts the JWT carries the AWS tags claim with the wallet underprincipal_tagsandtransitive_tag_keysset. Bug-regression guard: prevents this claim from being silently dropped in a future refactor.discovery_returns_aws_compatible_shape(theclaims_supportedtest) now asserts the tags claim is advertised in discovery.Test plan
cargo test -p agentkeys-broker-server— all 9 + 6 + 0 tests pass locally.https://aws.amazon.com/tagsclaim populated.aws sts get-session-token(or any subsequent call with the assumed creds) should reflect the session tag. Could verify via CloudTrail event for the assume-role call (look forprincipalTagsin the request).Deploy notes
This needs to be built and rolled out to the broker host (
broker.litentry.org) for §4.5 to actually pass. The runbook fix (PR #67) gets the AWS side correct; this PR gets the broker side correct; both are needed.After merge:
git pull && cargo build --release -p agentkeys-broker-serversudo cp target/release/agentkeys-broker-server /usr/local/bin/sudo systemctl restart agentkeys-brokerRelated
docs/cloud-setup.md§4 fixes (the runbook side of the same federation-isolation story)🤖 Generated with Claude Code