Repository navigation
fix(authz): report the denial code the service's wire protocol uses (#595) - #601
Merged
Merged
Conversation
…595) The generic authorization gate returned AccessDeniedException for every service, while #593's trust-policy gate returned the bare AccessDenied AWS actually sends for STS. Two gates therefore reported two different codes for one conceptual outcome, and a consumer matching on the code got a denial it could not identify — the case IaC error handling is most likely to branch on. Audited across every botocore model, deduplicated by service (botocore ships many versioned models per service, so counting files inflates the XML side nineteen-fold) and restricted to shapes carrying "exception": true. The JSON side is unanimous: all 233 services that model the shape use the suffixed form, none the bare one. The XML side is not settled by the models at all — only CloudFront declares the shape, and no query-protocol service declares one, nor do S3 or EC2. Every service where this code is observable in substrate is in that set, so the XML value is observed AWS behavior: the CLI output for a refused sts:AssumeRole quoted in #595, and what s3_publicaccess.go already documents for S3. Keying on protocol rather than on a per-service table means a newly registered plugin gets the right code from its existing classification, with no second table to keep in step. A test asserts that property over every registered service rather than over a sample, and the two-gate agreement test #595 asks for pins that an identity denial and a trust-policy denial cannot drift apart again. The IAM plugin's own gate is fixed with it: it runs a separate authorize() and built its ~40 denials from a hardcoded literal, so fixing only the controller would have left substrate reporting two codes for one service — this issue's complaint restated one level down. IAM speaks the query protocol, so its denials are bare too. Because cfn_deployer surfaces a denial as a resource's error and #501 renders that as a StackEvent ResourceStatusReason, the denial text in stack events and DescribeStackResources changes with it; those assertions and the docs that quoted the old code are updated in the same commit.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Aug 9, 2026
Merged
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.
Closes #595
Why
The generic authorization gate returned
AccessDeniedExceptionfor every service, while #593's trust-policy gate returned the bareAccessDeniedAWS actually sends for STS. Substrate therefore answered one conceptual outcome with two different codes depending on which gate refused, and a consumer matching on the code got a denial it could not identify — the case IaC error handling is most likely to branch on.The audit, and what it does and does not settle
Posted in full on #595, including a correction to my first pass. Run across every botocore model, deduplicated by service (botocore ships many versioned models per service, so counting files inflates the XML side nineteen-fold) and restricted to shapes carrying
"exception": true:AccessDeniedAccessDeniedExceptionquery17,rest-xml4,ec21)cloudfront)json149,rest-json242,cbor2)sts:AssumeRole(quoted in STS: identity-policy denials report AccessDeniedException where AWS sends AccessDenied #595), and whats3_publicaccess.go:22-35already documents for S3.Keying on wire protocol rather than on a hand-maintained per-service table means a newly registered plugin inherits the right code from its existing classification, with no second table to keep in step.
TestAccessDeniedCode_MatchesTheServiceErrorProtocolasserts that property over every registered service rather than over a sample, so a plugin added later is covered without anyone remembering to extend a list.The IAM plugin's own gate is fixed with it
IAMPlugin.authorizeis a separate gate and built its ~40 denials from a hardcodedAccessDeniedException. Fixing onlyAuthControllerwould have left substrate reporting two codes for one service — this issue's complaint restated one level down. IAM speaks the query protocol, so its denials are now bare too, routed through a named constant that a test pins against whataccessDeniedCodeForderives for"iam".Blast radius
cfn_deployer.gosurfaces aCheckAccessdenial as a resource'sError, and #501 renders that as aStackEventResourceStatusReason— so the denial text in CloudFormation stack events andDescribeStackResourceschanges. Those 12 assertions, and the docs indocs/services.mdanddocs/testing-guide.mdthat quoted the old code (including a paragraph that explicitly documented the two-code behaviour as correct), are updated in this same commit.Tests
Four new, plus the two-gate agreement test #595 asks for by name: an identity denial and a trust-policy denial on the same role must report one code, so they cannot drift apart again. It asserts they are equal and that the shared value is
AccessDenied, so agreeing on the wrong code would not satisfy it.Verification
gofmt·go build·go vet·golangci-lint run ./...→ 0 issues ·make test(race) ·make docs-reference-check docs-versions·go test -C test/e2e ./...·npm --prefix docs run build.Live server with the AWS CLI (
AWS_MAX_ATTEMPTS=1), confirming the split reaches a real client: STS →AccessDenied, IAM →AccessDenied, SQS →AccessDeniedException, DynamoDB →AccessDeniedException; and all three gates (identity, trust-policy, IAM-plugin) reportingAccessDeniedon XML services with the message distinguishing which one refused.Mutation testing — 6 mutants, all CAUGHT, tree verified clean after each restore:
errProtoS3XMLdropped from the XML armcontentTypeignored in the fallbackOne note on method: the boundary-site mutant first read SURVIVED under a
-run 'Authz|…'filter that does not matchTestAuthController_*. Re-run against the whole package it is caught byTestAuthController_PermissionBoundary_Deny. The filter was the defect, not the coverage; all six verdicts above are from full-package runs.