Skip to content

fix(authz): name a REST request by its operation, not its HTTP method (#572) - #573

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/572-rest-operation-names
Aug 5, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/572-rest-operation-names

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

A REST-JSON or REST-XML service carries its operation in the shape of its URL and
nowhere else, so extractOperation fell through to its last-resort HTTP-method
fallback and the request entered the pipeline named POST. Authorization, fault
injection, cost and consistency all read req.Operation before any plugin
runs
, while each plugin resolved the real name only at the top of its own
HandleRequest — one step too late.

Measured on the parent commit (87a966f), 17 of 18 REST services were
affected. S3 was the only exception, because #480 had wired its resolver in for
exactly this reason.

Why this blocks the release

The defect was inert while the evaluator was unreachable, and stopped being inert
with #411 (merged, unreleased). A user holding lambda:InvokeFunction was refused
an invoke, because the action evaluated was lambda:POST. A wildcard policy masks
it, so it is precisely the scoped policy #411 exists to let a consumer test that
gets a false AccessDeniedException — the inverse of the release's headline claim.
Transcript from a throwaway probe at 87a966f:

policy: Allow lambda:InvokeFunction on *
POST /2015-03-31/functions/fn/invocations
  → AccessDeniedException: not authorized to perform: lambda:POST

The fix

Resolve the operation name once, before the pipeline reads it — generalizing
#480 instead of repeating it 17 times. Every entry in the new
operationResolvers table wraps a resolver the service's plugin already owns and
already calls, rather than reimplementing it, so there is one definition of "what
operation is this" and the name the pipeline authorizes, meters and records cannot
drift from the name the plugin routes on.

AWSRequest gains HTTPMethod. This is the root modeling error: the verb and the
operation had been sharing one field, so resolving the operation destroyed the
verb that all 17 REST resolvers key on — POST and DELETE on the same path are
different operations. The alternative was 17 defensive guards; splitting the field
is the fix that leaves each resolver's contract intact, and the whole existing
suite went green with no test edits beyond the one intentional behaviour change
noted below.

CloudFormation's resource calls are built in-process and never pass through
ParseAWSRequest, so dispatch resolves too — otherwise a stack's bucket is
authorized as s3:PUT, which matches no policy a consumer would write.

The IAM action is not always the operation name

Treating it as such denies a caller whose policy is right, so the mapping is
explicit and each entry was checked against the AWS documentation rather than
assumed:

Operation Action a policy must name
lambda:Invoke lambda:InvokeFunction
s3:ListObjects / ListObjectsV2 / HeadBucket s3:ListBucket
s3:ListBuckets s3:ListAllMyBuckets
s3:ListObjectVersions s3:ListBucketVersions
s3:ListMultipartUploads s3:ListBucketMultipartUploads
s3:DeleteObjects s3:DeleteObject

API Gateway v1 is the sharp case. Its Service Authorization Reference defines
apigateway:GET/POST/PUT/PATCH/DELETE/HEAD/OPTIONS and no
apigateway:CreateRestApi — its IAM actions genuinely are HTTP verbs. So for
that service the verb remains the action, while apigatewayv2 is a separate
prefix that does use operation names. Blind resolution would have broken v1 in the
act of fixing the other 16; I had this wrong in a first draft of the tests and the
docs caught it.

Two pre-existing consequences, also fixed

Compatibility

The action strings a policy must name have changed. A REST call is now
authorized as its real operation rather than as its HTTP verb, and the renames in
the table above apply. A caller whose policy named lambda:POST (which no AWS
policy would) is now denied; a caller whose policy named lambda:InvokeFunction
(which every real policy does) is now correctly allowed. A recorded event's
operation for a REST service changes accordingly. Anything with a wildcard policy,
a nil principal, or a credential that resolves to no IAM entity is unaffected.

Verification

  • Baseline: 28 subtests fail at 87a966f and pass here.
  • Mutation testing — 8 mutants, each reversing one load-bearing decision:
    8 CAUGHT, 0 survivors, 0 broken. Two rounds were needed. The first found a
    real gap: HTTPMethod's contract held only incidentally, because
    resolveOperationName backfills the field, so a REST service added later
    without a table entry would have reached its plugin with no verb at all. Now
    asserted where nothing backfills. One mutant (resolveOperationName's
    resolved-name guard) was provably equivalent — every resolver echoes back the
    verb it was handed, never a different one — so rather than leave an unmeasurable
    branch, the now-unused bool return was dropped and the ""-or-verb contract
    documented.
  • gofmt -l ., go build ./..., go vet ./..., golangci-lint run ./... → 0
    issues
    , make test (race), make docs-reference docs-reference-check docs-versions (65 plugins, no change), go vet -C test/e2e ./...,
    go test -C test/e2e ./... — all green.

Provenance

The 17-service list and the false-denial transcript above were measured with
throwaway in-package probes against 87a966f, not read off a reference. The
action-name mappings and the API Gateway v1 verb-action behaviour are from the AWS
API and Service Authorization references.

Closes #572

…#572)

A REST-JSON or REST-XML service carries its operation in the shape of its URL
and nowhere else, so extractOperation fell through to its last-resort fallback
and the request entered the pipeline named "POST". Authorization, fault
injection, cost and consistency all read req.Operation before any plugin runs,
while each plugin resolved the real name only at the top of its own
HandleRequest — one step too late. Measured on the parent commit, 17 of 18 REST
services were affected; S3 was the exception because #480 had wired its resolver
in for exactly this reason.

This was inert until #411 made the evaluator reachable. A user holding
lambda:InvokeFunction was then refused an invoke, because the action evaluated
was lambda:POST — precisely the scoped policy the release exists to let a
consumer test, getting a false AccessDeniedException.

Resolve the name once, before the pipeline reads it, generalizing #480 rather
than repeating it 17 times. Each service's resolver already existed and is
wrapped rather than reimplemented, so the name that is authorized, metered and
recorded cannot drift from the name its plugin routes on.

AWSRequest gains HTTPMethod. The verb and the operation had been sharing one
field, and resolving the operation destroyed the verb every REST resolver keys
on — POST and DELETE on the same path are different operations. The 17 plugin
call sites now read requestMethod(req), which prefers HTTPMethod and falls back
to a verb still sitting in Operation, as an in-process caller leaves it.

The IAM action is not always the operation name, and treating it as such denies
a caller whose policy is right, so the mapping is explicit and sourced per
operation against the AWS documentation:

  - lambda:Invoke requires lambda:InvokeFunction;
  - S3's listings authorize against the bucket — ListObjects/ListObjectsV2 and
    HeadBucket require s3:ListBucket, ListBuckets requires s3:ListAllMyBuckets,
    and the versioned and multipart listings have their own bucket-scoped
    actions; DeleteObjects requires s3:DeleteObject;
  - API Gateway v1's IAM actions genuinely are HTTP verbs (apigateway:POST, with
    no apigateway:CreateRestApi), so for that service the verb remains the
    action — while apigatewayv2 is a separate prefix that does use operation
    names. Conflating them would have broken v1 in the act of fixing the others.

Two consequences beyond authorization, both pre-existing and now fixed: a fault
rule can name a REST operation, closing #480's gap for the 17 services its
S3-only fix never reached (a rule naming "POST" used to take out every call to
the service at once); and a recorded event carries its operation, so an event log
is greppable by operation — which is why cfn_nested_test.go's assertion moved
from "POST" to "CreateCluster". CloudFormation's resource calls are built
in-process and never parsed off the wire, so dispatch resolves them too: a
stack's bucket is recorded and authorized as CreateBucket, not PUT.

Closes #572
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.44262% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/operation_names.go 90.90% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 1eb9dc7 into main Aug 5, 2026
13 checks passed
@scttfrdmn
scttfrdmn deleted the fix/572-rest-operation-names branch August 9, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

authz/parser: 17 REST services reach the pipeline named after their HTTP method, so a correct policy is denied

1 participant