Repository navigation
Description
What
The generic authorization path returns AccessDeniedException for every service. For STS, AWS returns AccessDenied — no Exception suffix. A caller denied sts:AssumeRole by their identity policy therefore sees a code AWS never sends for that operation.
Surfaced by #593, which added the trust-policy gate. That new path emits AccessDenied correctly, so STS now has two denial codes depending on which gate refuses:
| gate | code today | AWS |
|---|---|---|
identity policy (CheckAccess, #411) |
AccessDeniedException |
AccessDenied |
| role trust policy (#593) | AccessDenied |
AccessDenied |
#593 deliberately left the first row alone: CheckAccess is service-wide, and changing its code is a consumer-visible change for every service that flows through it, not a detail of the trust-policy fix.
Provenance
AccessDenied is observed behaviour, not modelled. The botocore STS model documents no access-denied error for AssumeRole at all — only MalformedPolicyDocument, PackedPolicyTooLarge, RegionDisabled and ExpiredToken. The code comes from AWS's own CLI output, quoted in the role-configuration guide: An error occurred (AccessDenied) when calling the AssumeRole operation.
Why it matters
A consumer's error handling branches on the code. Test code written against real STS matches AccessDenied; against substrate the identity-gate denial arrives as AccessDeniedException and the branch is missed, so a test asserting "unauthorized callers are rejected with AccessDenied" fails against the emulator for a reason that has nothing to do with the code under test. The inconsistency between substrate's own two STS gates makes it worse: the same conceptual outcome reports two different codes.
What to decide first
Whether the right fix is STS-local (an override where STS denials are produced) or a per-service code table on the generic path. Other services may have the same mismatch — Query-protocol services in particular tend toward the unsuffixed form — so an audit of which services actually send AccessDeniedException should come before the edit. Do not widen this into a blanket rename; verify each service against its API reference.
Acceptance criteria
- Audit which services AWS documents as returning
AccessDeniedvsAccessDeniedException; record the findings with sources on this issue. - STS identity-policy denials report
AccessDenied, matching the trust-policy path, with HTTP 403 unchanged. - Any other service corrected only where its API reference supports it, one entry per service with a cited source.
- The two STS gates agree on the code; a test asserts both, so they cannot drift again.
-
## Provenancenote at release, since these codes come from observed behaviour rather than the API models. - CHANGELOG under Fixed with a
## Compatibilitynote: a test matching onAccessDeniedExceptionfor an affected service will need updating.
Activity
scttfrdmn commentedon Aug 9, 2026
Milestoned v0.96.0, alongside #594 — the two gaps #593 exposed in the trust-policy surface it made load-bearing.
Sequencing: the audit gates the edit
The first acceptance criterion above (audit which services AWS documents as
AccessDeniedvsAccessDeniedException, with sources) is not a formality that can be back-filled after the code change.CheckAccessis genuinely service-wide —server.go:594calls it for every service request, pluscredentials.go,iam_plugin.go,cfn_deployer.goandsts_plugin.go— so any change at that call site is consumer-visible for services nobody audited. There are 43AccessDeniedExceptionliterals across the plugins, which is the measure of how wide a careless rename would be.There is already a per-service dispatch to extend
The issue asks whether the fix should be STS-local or a per-service code table. Worth naming before implementation: the table shape already exists.
emulator/error_protocol.go:159-188haswith a documented fallback for unregistered services. #480 (S3) and #591 (EC2) both landed as entries in that map rather than as special cases at the call site, so a denial-code table keyed the same way would follow an established pattern instead of introducing a second mechanism. Whether the map is extended or a sibling one added is an implementation detail; the point is that the mechanism is not new work.
Two other sites to keep consistent
authz.go:27—CheckAccess's doc comment namesAccessDeniedExceptionexplicitly, so it goes stale with the change.server.go:465— a pipeline comment documents step 2 as→ 403 AccessDeniedException.Both are prose, but a comment that contradicts the code is the kind of thing that misleads the next reader for a year.
Already-unsuffixed sites, for the audit's baseline
sts_plugin.go:328(#593's gate),server.go:588(expired request) ands3_publicaccess.go:36all emit the unsuffixedAccessDeniedtoday. So the two forms already coexist deliberately, and the audit's job is to say which is right per service rather than to pick one globally.scttfrdmn commentedon Aug 9, 2026
The audit (acceptance criterion 1) — it changes this issue's premise
Ran against the botocore service models (
botocore/data/*/*/service-2.json), which is the authoritative model for each service's exception shapes. 243 models define an access-denied exception; grouped by the service's declared wire protocol:AccessDeniedAccessDeniedExceptionrest-xmljsonrest-jsonsmithy-rpc-v2-cborThe suffix tracks the wire protocol, not the service — a clean split with zero exceptions across all 243. This issue speculated the answer was per-service ("Query-protocol services in particular tend toward the unsuffixed form"); it is per-protocol, which means the value is derivable rather than arbitrary. The fix will therefore key on protocol via the existing
errorProtocolFor(emulator/error_protocol.go:180) rather than introduce a hand-maintained per-service table that would go stale across 72 registered services.The caveat that matters most
No query-protocol service models an access-denied shape at all — all 20 of them, including STS, IAM, CloudFormation and SNS. Nor do S3 (
rest-xml) or EC2 (ec2), which define zero exception shapes of any kind.So for every service substrate actually emulates here, the denial code is observed behaviour, not modelled. That is consistent with what this issue already says about STS (the code comes from AWS's CLI output quoted in the troubleshooting guide) and with what
emulator/s3_publicaccess.go:22-35already documents for S3. Therest-xmlcolumn above is pattern evidence that bareAccessDeniedis the XML-family form — it is not a model citation for STS itself. The release notes will carry a## Provenancesection saying so.Blast radius, which is wider than the issue notes
cfn_deployer.go:4120-4127callsCheckAccessand returns its error as the dispatch error, which becomes a resource'sError, which #501 renders as aStackEventResourceStatusReason. So the denial text in CloudFormation stack events changes too. That is 12 assertions acrosscfn_service_role_test.go,cfn_events_test.goandtest/e2e/journey_cfn_events_test.go, all updated in the same commit as the fix.scttfrdmn commentedon Aug 9, 2026
Correction to the audit above
Two numbers in my previous comment were wrong, and one of them matters. I counted model files, not services — botocore ships many versioned
service-2.jsonfiles per service (EC2 has 8, CloudFront 19), so services with long API histories were counted once per version. Re-run deduplicating by service directory, and restricted to shapes that actually carry"exception": true(the earlier count also included one non-exception structure —medialive'sAccessDeniedis a documentation placeholder with noexceptionflag):AccessDeniedAccessDeniedExceptionquery17,rest-xml4,ec21)cloudfront)json149,rest-json242,smithy-rpc-v2-cbor2)So the two claims that carry the decision survive, but with very different weight:
AccessDeniedException. Zero use the bare form. Substrate emittingAccessDeniedExceptionon a JSON service is correct and stays as-is.AccessDenied. My "19 services, a clean split with zero exceptions" was one service counted nineteen times. It is consistent evidence, not a pattern across nineteen independent data points.What does not change is the caveat that was already the decisive one, now more so: no query-protocol service models an access-denied shape at all — all 17, including STS, IAM, CloudFormation and SNS — and neither do S3 or EC2, which define zero exception shapes of any kind. Every service where this fix changes substrate's behaviour is in that set. So the bare
AccessDeniedfor XML protocols rests on observed AWS behaviour — the CLI output quoted in this issue for STS, and whatemulator/s3_publicaccess.go:22-35already documents for S3 — with CloudFront and the unanimous JSON column as corroboration rather than as the basis.The fix is unchanged: key on wire protocol via
errorProtocolFor, since the JSON side is unanimous and the XML side matches every observation we have. But the## Provenancesection in the release notes, and the helper's doc comment, will state the evidence at this strength rather than the inflated one.fix(authz): report the denial code the service's wire protocol uses (#…
fix(pricing,authz): classify pricing's error protocol, and assert ove…