Skip to content

fix: S3 Control requests were served by S3, silently - #142

Merged
skyoo2003 merged 4 commits into
mainfrom
fix/s3-control-routing
Sep 5, 2026
Merged

skyoo2003 merged 4 commits into
mainfrom
fix/s3-control-routing

Conversation

@skyoo2003

Copy link
Copy Markdown
Owner

Summary

S3 Control requests were served by S3, and the write paths returned 200. s3control signs with S3's own signing name, so every call fell through DetectProtocol to the REST-XML default, where the S3 provider parsed PUT /v20180820/accesspoint/x as bucket v20180820, key accesspoint/x and stored it. That is a fabricated success against a registered service, which docs/coverage.md calls the one guarantee that must not bend.

Shipped alone because it is a correctness fix against released behaviour (#140) and depends on nothing else in Milestone 5.

Related Issue

Refs #

Changes

  • DetectProtocol branch 4 splits s3-control off s3 by its /v20180820/ path prefix — the third instance of the URL-path split already used for opensearch and apigateway. Branch 4 was the only branch that never consulted SigningSiblings, even though aliases.SigningSiblings["s3"] already listed both.
  • Regression tests at both levels, plus the boto3 file that proves the guarantee end to end.
  • Changie Fixed fragment.

Why a path prefix, not the route table

A route-table split would be wrong here rather than merely larger: S3's own PutObject PUT /{Bucket}/{Key+} matches /v20180820/accesspoint/x, so asking which service models the path answers s3.

The one case this gets wrong, asserted rather than left to be found

A bucket named exactly v20180820 produces object paths under /v20180820/, which the prefix claims, so those objects become unreachable.

The alternative was measured and rejected. x-amz-account-id is bound by 96 of S3 Control's 97 operations and by 0 of S3's 107 — but gating on it routes the one operation that does not bind it, Outposts CreateBucket PUT /v20180820/bucket/{Bucket}, to S3, where it becomes a stored object and a 200. A wrong-but-honest error beats a fabricated success, so the shadowing stands and is tested.

Test Plan

RED, before the fix:

--- FAIL: TestDetectProtocol_S3Control/create_access_point
    expected: "s3control"
    actual  : "s3"

5 of 10 subtests failed; the 5 S3 guard subtests passed, so the failure was the defect, not the setup.

RED at the boto3 level, with the fix reverted (git revert --no-commit):

>       with pytest.raises(ClientError):
E       Failed: DID NOT RAISE ClientError

CreateAccessPoint returned a success and stored an object.

GREEN:

go test ./internal/gateway/ -run TestDetectProtocol_S3Control   11/11 subtests
CGO_ENABLED=0 go test ./...                                     111 packages ok
pytest tests/compatibility/                                     846 passed, 3 skipped

Manual, against ./dist/devcloud:

buckets unchanged: True | v20180820 absent: True

Checklist

  • Self-reviewed the code
  • Added/updated tests
  • Lint/format passes (pre-commit: gofmt, go vet, go build, ruff)
  • Updated documentation (if applicable) — N/A, the coverage docs move in the follow-up PR
  • Added a Changie changelog fragment for user-facing changes

RED: TestDetectProtocol_S3Control fails 5/10 subtests with
expected "s3control", actual "s3". S3 Control signs with S3's own
signing name, so DetectProtocol branch 3's `svc != "s3"` guard sends
it to the REST-XML default — the one branch that never consults
SigningSiblings — and the S3 provider parses /v20180820/accesspoint/ap
as bucket + key. The 5 S3 guard subtests pass, so the failure is the
defect and not the test setup.
GREEN: TestDetectProtocol_S3Control 10/10 subtests pass; full suite
111 packages ok, 0 failures.

DetectProtocol branch 4 splits s3-control off s3 by its /v20180820/
path prefix — the third instance of the URL-path split already used
for opensearch and apigateway. A route-table split would be wrong
rather than merely larger: S3's own PutObject PUT /{Bucket}/{Key+}
matches an S3 Control path, so asking which service models the path
answers "s3".
Compat RED (fix reverted): create_access_point DID NOT RAISE — it
returned 200 and stored an object. GREEN with the fix: 4 passed.
Full compat suite 846 passed, 3 skipped; go test ./... all green.

The guard test caught a real gap in the fix's blast radius: a bucket
named exactly "v20180820" produces object paths under /v20180820/,
which the prefix claims. That is now asserted rather than left to be
found, in both the Go table and the compat suite, with the reason the
alternative is worse: x-amz-account-id is bound by 96 of S3 Control's
97 operations and none of S3's 107, but gating on it sends Outposts
CreateBucket to S3 as a stored object and a 200. A wrong-but-honest
error beats a fabricated success.
@github-actions github-actions Bot added the tests Test code and test infrastructure label Sep 5, 2026
@skyoo2003
skyoo2003 merged commit 9315d50 into main Sep 5, 2026
8 checks passed
@skyoo2003
skyoo2003 deleted the fix/s3-control-routing branch September 5, 2026 17:14
skyoo2003 added a commit that referenced this pull request Sep 6, 2026
The four Fixed entries were written before the PR existed and guessed
consecutive numbers. custom.Issue carries the PR number in this repo — #142
through #145 all match their PR — and all four fragments ship in one PR.
skyoo2003 added a commit that referenced this pull request Sep 6, 2026
* test: add reproducer for the four unreachable Lex services

RED: CGO_ENABLED=0 go test ./internal/gateway/ -run TestDetectProtocol_Lex

    --- FAIL: TestDetectProtocol_Lex/models_v1_get_bots
    --- FAIL: TestDetectProtocol_Lex/models_v1_get_intents
    --- FAIL: TestDetectProtocol_Lex/models_v1_builtin_intents
    --- FAIL: TestDetectProtocol_Lex/models_v2_list_bots
    --- FAIL: TestDetectProtocol_Lex/models_v2_create_bot
    --- FAIL: TestDetectProtocol_Lex/models_v2_describe_bot
    --- FAIL: TestDetectProtocol_Lex/runtime_v1_get_session
    --- FAIL: TestDetectProtocol_Lex/runtime_v1_put_session
    --- FAIL: TestDetectProtocol_Lex/runtime_v2_get_session
    --- FAIL: TestDetectProtocol_Lex/runtime_v2_delete_session
    --- PASS: TestDetectProtocol_Lex/delete_bot_is_contested

Every failure reads `expected: <a lex service>, actual: "lex"` — the request
never leaves the contested alias. The one PASS is the genuine collision
(DELETE /bots/{id}, claimed by both model services), which must stay refused.

Recorded in .claude/tdd/aws-service-coverage-100-milestone-6.tdd.md as
"Coverage and known gaps", item 3.

* fix: the four Lex services were reachable by no boto3 caller

GREEN: CGO_ENABLED=0 go test ./internal/gateway/ -run TestDetectProtocol_Lex → ok
       CGO_ENABLED=0 go test ./...                                          → all pass
       DEVCLOUD_BIN=dist/devcloud pytest tests/compatibility/
         → 1123 passed, 17 skipped, 2 xfailed (was 1119 passed)

All four Lex clients sign as "lex" and no service is called "lex", so the alias
stays contested. normalizeServiceID hands the unresolved name through, the
registry has nothing under it, and every Lex call died as UnknownService — four
services registered, counted in "serving >=1 operation", and reachable by nobody.

The fix needed no new routing. resolveSharedSigningName already picks the
sibling whose route table models the request; it was never reached, because
signingNameOf only recognised a *member* service ID and "lex" is the group's
key. One map lookup.

The four route tables separate cleanly on method and literal segment:

    GET  /bots                                  lexmodelbuildingservice
    POST /bots                                  lexmodelsv2 (ListBots)
    PUT  /bots                                  lexmodelsv2 (CreateBot)
    GET  /bot/{n}/alias/{a}/user/{u}/session    lexruntimeservice
    GET  /bots/{b}/botAliases/.../sessions/{s}  lexruntimev2

One genuine collision, DeleteBot at DELETE /bots/{id}, claimed by both model
services. It stays refused: deleting the wrong bot is worse than an honest
UnknownService. Asserted, not left to be found.

The pin test told whoever fixed this to delete it, so it is deleted and replaced
by a check on the direction that still matters — UNREACHABLE_FROM_BOTO3 must
stay empty. docs/coverage.md's compatibility-tested figure moves 199 -> 203, the
Lex exclusion section is rewritten, and the stale claim that each Lex service is
"reached by its own unambiguous name" is corrected: no boto3 caller has one.

Plan: .claude/plans/aws-service-coverage-100-milestone-7.plan.md, Task 1

* test: add reproducer for hand-verified operations no route reaches

RED: DEVCLOUD_BIN=dist/devcloud pytest tests/compatibility/test_handverified_is_reachable.py

    FAILED [appsync.ListApis]
    FAILED [eks.ListAccessPolicies]
    FAILED [opensearch.ListApplications]
    3 failed in 1.56s

Each answers NotImplemented. All three are labelled hand-verified in the
fidelity manifest, and all three are implemented — codegen reads the case
clause, and the case clause is there. What is missing is the route: the
gateway passes no operation name for rest-json, so the provider recovers it
from method and path with a hand-written resolver, and none of these three
resolvers knows the path its own model publishes.

    appsync/ListApis          GET /v2/apis            resolveOp strips only /v1
    eks/ListAccessPolicies    GET /access-policies    no case at all
    opensearch/ListApplications
                              GET /2021-01-01/opensearch/list-applications
                              resolveOp knows only GET /application

Recorded in .claude/tdd/aws-service-coverage-100-milestone-6.tdd.md as
"Coverage and known gaps", item 2.

* fix: three hand-verified operations were reached by no route

GREEN: DEVCLOUD_BIN=dist/devcloud pytest tests/compatibility/test_handverified_is_reachable.py
         → 3 passed
       CGO_ENABLED=0 go test ./...                → all pass
       DEVCLOUD_BIN=dist/devcloud pytest tests/compatibility/
         → 1126 passed, 17 skipped, 2 xfailed (was 1123)
       make codegen; git status --porcelain internal/generated → clean
       golangci-lint run                          → 0 issues

appsync/ListApis, eks/ListAccessPolicies and opensearch/ListApplications are
each implemented by a case clause the provider already has. Codegen reads that
clause and labels the operation hand-verified — which proves the code exists,
not that any request arrives at it. For rest-json those are different
questions: the gateway passes no operation name, so the provider recovers it
from method and path with a hand-written resolver, and none of these three
resolvers knew the route its own model publishes.

The resolvers are partial copies of a table codegen already emits. Each
provider now ends with crud.Route(service, method, uri) instead of losing the
request. The fallback fires only where the resolver produced nothing, so it
cannot displace a decision a provider made — it fills gaps.

crud.Route is HasRoute's implementation, exported; HasRoute becomes its
one-line caller. Nothing else in the gateway changes.

No published figure moves. These operations were already counted as served;
what changes is that the count is now true about them.

27 other providers hand-roll the same kind of resolver. Whether any of them has
the same gap is not measured here — the compat manifest carries served
operations but not their tier, so the fleet-wide version of this test needs a
codegen change first. Recorded, not guessed at.

Plan: .claude/plans/aws-service-coverage-100-milestone-7.plan.md, Task 2

* fix: the manifest reported an implemented operation as unimplemented

RED (compile-time, the intended missing field):
    CGO_ENABLED=0 go test ./internal/codegen/

    internal/codegen/gen_fidelity_test.go:83:4: unknown field ShortOperations
        in struct literal of type ProviderScan
    internal/codegen/scan_handverified_test.go:93:45:
        scans["resourcegroups"].ShortOperations undefined
    FAIL github.com/skyoo2003/devcloud/internal/codegen [build failed]

The RED could not be committed on its own: .pre-commit-config.yaml runs go vet,
which rejects a non-compiling tree, so RED and GREEN share this commit and the
output above is the evidence. Same constraint as #144.

GREEN: CGO_ENABLED=0 go test ./internal/codegen/  → ok
       CGO_ENABLED=0 go test ./...                → all pass
       make codegen                               → exactly one tier change
       DEVCLOUD_BIN=dist/devcloud pytest tests/compatibility/
         → 1126 passed, 17 skipped, 1 xfailed (was 2 xfailed)
       golangci-lint run                          → 0 issues

opNamePattern requires four characters. resourcegroups implements Tag and Untag
in the same switch; Untag was scanned, Tag was not, and the manifest called
implemented code unimplemented. test_no_fabricated_success then asked for Tag,
got the 200 the provider has always returned, and reported a fabricated success.
It was never fabricated. The answer was real and the manifest was wrong, so the
probe was right to complain and wrong about what it had found — which is why
that entry recorded only an observation and refused to name a mechanism.

Loosening the pattern is not the fix. At two characters it admits the HTTP verbs
every path resolver switches on. The model separates them: Tag is an operation
because resourcegroups.json says so, and no model AWS publishes declares GET.
Short literals are collected into ProviderScan.ShortOperations and promoted by
BuildFidelityData only where the service's model declares them.

Fleet-wide, exactly one operation is short enough to be affected:

    rg -o '"[A-Z][A-Za-z0-9]{2}":\s+Tier[A-Za-z]+' \
       internal/generated/fidelity/manifest_gen.go   → 1 hit, "Tag"

The gate caught the consequence, as designed:

    coverage_test.go:162: docs/coverage.md publishes 4496 hand-verified
        operations, the manifest holds 4497
    coverage_test.go:162: docs/coverage.md publishes 2718 unimplemented
        operations, the manifest holds 2717

Plan: .claude/plans/aws-service-coverage-100-milestone-7.plan.md, Task 3

* test: add reproducer for S3 serving unknown sub-resources as listings

RED: CGO_ENABLED=0 go test ./internal/services/s3/ -run UnhandledBucketSubresource

    --- FAIL: .../analytics    --- FAIL: .../lifecycle
    --- FAIL: .../inventory    --- FAIL: .../encryption
    --- FAIL: .../metrics      --- FAIL: .../versions
    --- FAIL: .../replication  --- FAIL: .../object-lock

    "<ListBucketResult><Name>sub-bucket</Name>..." should not contain
    "ListBucketResult"
    "200" is not greater than or equal to "400"

GET /{bucket}?analytics misses every bucket sub-resource check and falls through
to listObjects, so botocore reads a 200 <ListBucketResult> as a successful
ListBucketAnalyticsConfigurations. Seven more sub-resources take the same path.

The seven legitimate listing shapes in the same test already pass, and are there
so the fix cannot be a guard that declines a real ListObjects.

Recorded in .claude/tdd/query-providers-fabricate-success.tdd.md as one of the
two remaining xfail(strict) violations.

* fix: S3 served an unimplemented bucket sub-resource as a listing

GREEN: CGO_ENABLED=0 go test ./internal/services/s3/  → ok (8 sub-resources
         decline, 7 listing shapes still serve)
       CGO_ENABLED=0 go test ./...                    → all pass
       DEVCLOUD_BIN=dist/devcloud pytest tests/compatibility/
         → 1127 passed, 17 skipped, 0 xfailed
       make codegen; git status --porcelain internal/generated → clean
       bash scripts/generate-imports.sh; git diff --exit-code  → clean
       golangci-lint run                              → 0 issues

GET /{bucket}?analytics matched no sub-resource branch and fell through to
listObjects, which answers 200 with <ListBucketResult>. botocore reads that as
a successful ListBucketAnalyticsConfigurations — a fabricated success, the one
thing docs/coverage.md calls absolute. The recorded report named one
sub-resource; the fall-through covered eight.

The guard is an allow-list of the parameters a listing carries, not a deny-list
of sub-resource names, because the two fail in opposite directions. A missing
allow-list entry declines a real listing and a test says so at once; a missing
deny-list entry serves a sub-resource as a listing, silently, which is the
defect. A sub-resource AWS adds next year now declines on its own.

The xfail(strict) marker did its job: it turned XPASS the moment the guard
landed, so KNOWN_UNFIXED could not quietly keep an entry for something already
fixed. Both entries are now gone and the dict is empty.

Plan: .claude/plans/aws-service-coverage-100-milestone-7.plan.md, Task 4

* chore: point the changelog fragments at PR #146

The four Fixed entries were written before the PR existed and guessed
consecutive numbers. custom.Issue carries the PR number in this repo — #142
through #145 all match their PR — and all four fragments ship in one PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test code and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant