Repository navigation
Description
Summary
STSPlugin.AssumeRole (emulator/sts_plugin.go) checks that the named role exists in IAM state, and nothing else about the request against it. It never reads the role's AssumeRolePolicyDocument (stored by CreateRole/UpdateAssumeRolePolicy and already used for drift comparison in CloudFormation's policyDocumentsEqual), and never evaluates the calling principal or an sts:ExternalId condition against it.
Net effect: any caller, with any or no ExternalId, can assume any role that exists — the trust policy is stored but decorative.
This is distinct from #411 (closed), which authorizes calls made with an assumed session against the role's permissions policy. That half works. The half missing here is the assumption itself: whether this caller, with this ExternalId, is even allowed to become that role.
Why this matters (concrete, from a real consumer)
A cross-account broker pattern — module A creates a narrow IAM role in account B with a trust policy naming module A's account and requiring a specific sts:ExternalId (the standard confused-deputy defense for third-party/cross-account access) — is untestable against Substrate today for the one property that defense exists to provide: that assumption fails for the wrong caller or the wrong ExternalId. Every AssumeRole call succeeds regardless, so a test exercising this against Substrate would pass whether or not the trust policy's Principal/Condition block was ever rendered correctly, malformed, or omitted entirely.
Proposed capability
AssumeRolereads the target role'sAssumeRolePolicyDocumentand evaluates it as a resource policy against the calling principal (same evaluator IAM/S3-bucket-policy paths already use, presumably), before minting session credentials.sts:ExternalId, evaluated viaStringEquals/StringNotEqualsconditions the way IAM already evaluates other condition operators, against theExternalIdparameter on the request.- A caller that fails the trust check gets
AccessDenied— the same undifferentiated denial real AWS gives for "not trusted" and "wrong ExternalId", so a consumer test can assert on that non-distinction rather than on a distinction AWS itself doesn't provide.
Acceptance
- A role created with a trust policy naming a specific account/principal and an
sts:ExternalIdcondition refusesAssumeRolefrom a different principal, or with a missing/wrong ExternalId, withAccessDeniedException. - The same role accepts
AssumeRolefrom the named principal with the correct ExternalId, and the returned session credentials work as they do today. - A role with an unconditional principal trust policy (no ExternalId) continues to accept assumption from that principal, unchanged.
Scope note
Same shape as #411: higher-fidelity emulation of an existing observable (the trust decision + error code AWS actually returns), not workload execution.
Activity
scttfrdmn commentedon Aug 9, 2026
Reproduced and fixed. Three of the issue's premises turned out to be false, and each one changed the work materially, so recording them here.
1. The evaluator this issue assumes exists does not. The issue suggests reusing "the same evaluator IAM/S3-bucket-policy paths already use, presumably".
Evaluateinemulator/iam_eval.gonever readreq.Principal—statementMatchesconsulted action ∧ resource ∧ condition only.EvaluationRequest.Principalwas populated by all four call sites and read by none, which is exactly why a trust policy could name one account and still admit every caller. No principal matcher existed anywhere in the codebase, so building one (Principal/NotPrincipal,"*", exact ARN, bare account ID and account-root delegation,Service,Federated) is the bulk of this fix rather than a wiring exercise.The load-bearing constraint: absent
Principalmust match, because all four existingEvaluatecall sites are identity/permission-boundary paths whose documents carry noPrincipalelement — IAM rejects the element there. A mutant flipping that guard tofalseturnsTestAuthController_AssumedRoleandTestIAMAuthorize_AgreesWithCheckAccessred, which is the proof it's tested rather than incidental.2.
UpdateAssumeRolePolicydoes not exist in substrate. The issue describes the document as "stored byCreateRole/UpdateAssumeRolePolicy"; there is no such case in the IAM operation switch, soCreateRoleis the only way to set a trust policy today and there is no way to change one afterwards. Out of scope here — filed as a follow-up.3. The wire code is
AccessDenied, not theAccessDeniedExceptionthe Acceptance section names. AWS's own CLI output readsAn error occurred (AccessDenied) when calling the AssumeRole operation. The botocore STS model documents no access-denied error for AssumeRole at all (onlyMalformedPolicyDocument,PackedPolicyTooLarge,RegionDisabled,ExpiredToken), so this code is observed behaviour, not modelled, and it gets a## Provenancenote at release. AWS's two documented message forms map exactly onto substrate's two deny decisions:…is not authorized to perform: sts:AssumeRole because no role trust policy allows the sts:AssumeRole action(DecisionImplicitDeny)…is not authorized to perform: sts:AssumeRole with an explicit deny in the role trust policy(DecisionDeny)A separate follow-up covers the pre-existing generic
AccessDeniedExceptionfromCheckAccess, which stays as it is — narrowing it for STS is a service-wide consumer-visible change, not part of this fix.The four paths, reproduced then re-run against the fix
Measured with a live server and the real CLI. A role trusting account
111111111111withStringEquals sts:ExternalId secret-123, assumed as a signed IAM user already grantedsts:AssumeRole(so the #411 identity gate passes first — that success was precisely the defect: the identity gate passed and there was no trust gate behind it). Before: all four returnedASIA…credentials. After:ASIA…AccessDenied, implicit-deny wordingASIA…AccessDeniedASIA…AccessDenied{"Effect":"Deny","Principal":"*","Action":"sts:AssumeRole"}ASIA…AccessDenied, explicit-deny wordingASIA…ASIA…(still works)Without that last row the suite would pass for a rule that denies everything.
Decisions worth knowing
A trust policy is the opt-in; a role without one stays unenforced. A zero-value
AssumeRolePolicyDocumentmeans "not configured", soAssumeRoleon such a role behaves exactly as before. This is the documenteddocs/testing-guide.mdrule — existence in state is the opt-in — one level down: there enforcement starts when the principal exists, here when the role carries a trust policy. Strict fidelity would treat an empty document as an implicit deny, but AWS'sCreateRolerequires a trust policy, a state substrate permits, so denying it would refuse roles that cannot exist on AWS. A nilctx.Principalis unenforced for the same reasonCheckAccessreturns nil on one: an unauthenticated caller resolves to no ARN, so there is nothing for aPrincipalelement to be true of.The trust policy is evaluated before any credential is minted. Checking after would leave a usable session in state behind a 403; there's a test asserting the session store is empty after a denial.
CFN is unaffected —
cfnAttribution.resolveuses a service role ARN directly rather than running through AssumeRole, so no stack deploy passes the new gate.Blast radius is narrow. No existing test both set a trust policy and assumed that role; all five pre-existing
sts_plugin_test.goAssumeRole tests pass unchanged, which is the opt-in decision stated as an executable claim.Verification
gofmt,go build,go vet,golangci-lint(0 issues),make test(race),make coverage(emulator 81.5%, total 80.7%),make docs-reference-check docs-versions, the docs site build, andgo test -C test/e2eall green. A real-SDK e2e journey assertsAccessDeniedwithout the ExternalId andASIA…credentials with it on the same role. Eight mutants — including one restoring this bug exactly — were all CAUGHT.fix(sts,iam): AssumeRole evaluates the role's trust policy (#593) (#596)
feat(iam): implement UpdateAssumeRolePolicy (#594) (#600)
fix(authz): report the denial code the service's wire protocol uses (#…