Skip to content

STS: identity-policy denials report AccessDeniedException where AWS sends AccessDenied #595

Closed

Description

@scttfrdmn

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 AccessDenied vs AccessDeniedException; 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.
  • ## Provenance note at release, since these codes come from observed behaviour rather than the API models.
  • CHANGELOG under Fixed with a ## Compatibility note: a test matching on AccessDeniedException for an affected service will need updating.

Activity

  1. added
    type: bug
    area: iam
    area: server
    on Aug 9, 2026
  2. added this to the v0.96.0 milestone on Aug 9, 2026
  3. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    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 AccessDenied vs AccessDeniedException, with sources) is not a formality that can be back-filled after the code change. CheckAccess is genuinely service-wide — server.go:594 calls it for every service request, plus credentials.go, iam_plugin.go, cfn_deployer.go and sts_plugin.go — so any change at that call site is consumer-visible for services nobody audited. There are 43 AccessDeniedException literals 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-188 has

    var serviceErrorProtocols = map[string]awsErrorProtocol{ ... }
    
    func errorProtocolFor(service, contentType string) awsErrorProtocol

    with 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 names AccessDeniedException explicitly, 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) and s3_publicaccess.go:36 all emit the unsuffixed AccessDenied today. 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.

  4. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    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:

    wire protocol AccessDenied AccessDeniedException
    rest-xml 19 services 0
    json 0 72
    rest-json 0 162
    smithy-rpc-v2-cbor 0 1

    The 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-35 already documents for S3. The rest-xml column above is pattern evidence that bare AccessDenied is the XML-family form — it is not a model citation for STS itself. The release notes will carry a ## Provenance section saying so.

    Blast radius, which is wider than the issue notes

    cfn_deployer.go:4120-4127 calls CheckAccess and returns its error as the dispatch error, which becomes a resource's Error, which #501 renders as a StackEvent ResourceStatusReason. So the denial text in CloudFormation stack events changes too. That is 12 assertions across cfn_service_role_test.go, cfn_events_test.go and test/e2e/journey_cfn_events_test.go, all updated in the same commit as the fix.

  5. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    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.json files 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's AccessDenied is a documentation placeholder with no exception flag):

    family services modelling bare AccessDenied modelling AccessDeniedException
    XML (query 17, rest-xml 4, ec2 1) 22 1 (cloudfront) 0
    JSON (json 149, rest-json 242, smithy-rpc-v2-cbor 2) 393 0 233

    So the two claims that carry the decision survive, but with very different weight:

    • Strong: of 233 JSON-family services that model an access-denied exception, every single one uses AccessDeniedException. Zero use the bare form. Substrate emitting AccessDeniedException on a JSON service is correct and stays as-is.
    • Weak, n=1: on the XML side only CloudFront models the shape at all, and it uses the bare 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 AccessDenied for XML protocols rests on observed AWS behaviour — the CLI output quoted in this issue for STS, and what emulator/s3_publicaccess.go:22-35 already 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 ## Provenance section in the release notes, and the helper's doc comment, will state the evidence at this strength rather than the inflated one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: iamarea: servertype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions