Repository navigation
fix(server): answer by media type, method and path as DynamoDB does - #1079
LeeroyHannigan wants to merge 6 commits into
Conversation
Amazon DynamoDB serves its API for a POST at any path when the Content-Type is application/x-amz-json-1.0 or application/json. It compares the media type without its parameters and in any letter case, and it answers in that media type. A POST whose body is over the 16 MiB limit gets 413 in every media type. Under the limit, a POST in any other media type, or with none, gets a 404 with an HTML page and no Content-Type. This 404 comes ahead of authentication and of the X-Amz-Target, operation and JSON checks. A GET of / with no query string, or of /ping with or without one, gets the text "healthy: dynamodb.<region>.amazonaws.com " in text/plain. Every other request gets the 404 page, and HEAD gets it without the body. Each answer but the 413 carries an x-amzn-RequestId and the X-Amz-Crc32 of its body. The signature covers the request's path and query string. ExtendDB served the API for POST / only, in any media type, and answered in application/x-amz-json-1.0 only. Other methods and paths got a 405 or a 404 with no body and no X-Amz-Crc32. The signature check used / with no query string, whatever the request's target. The router now has a fallback in place of the POST / route. The fallback serves the API for a POST at any path, under the 16 MiB body limit and behind the same layers as before. It also gives the health text and the 404 page. In another media type, it reads the body through the limit first, so a body over it gets the handler's 413 however it is framed. A path under /management or /console that their routers do not take keeps its empty 404. The signature check builds the canonical URI and query string from the request's own path and query string. The issue's rows were measured in us-east-1 on 2026-11-14. Requests to us-east-1 on 2026-11-17 showed where the size check and the media type check come among the other checks. They also showed that the signature covers the path and query string. Fixes #1020.
crates/auth/src/lib.rs keeps the cached signing key of main (#1003) and the request's path and query string of this branch in the call to verify_signature. crates/auth/tests/sigv4_differential/harness.rs keeps the provider over a pass-through credential cache from main and the path and query string arguments of authenticate_at from this branch.
… of main Main (#1003) removed the store type parameter of BuiltinAuthProvider, so BuiltinAuthProvider<MockCredentialStore> no longer names a type. The unit tests in tests.rs build each provider through provider_over, over a pass-through CachedCredentialStore. The shim that sends the unit tests' requests to authenticate with the path / and no query string is now an impl block on BuiltinAuthProvider. Its body does not change.
Main's #1009 moved the error body to `extenddb_core::error::error_document` and `SERIALIZATION_FAILURE_BODY` to `crates/core/src/error/mod.rs`. In `crates/server/src/response.rs` the merge keeps this branch's `wire_response` and drops the local copy of the fallback body, which main now imports from core. #1009 also replaced the `axum` dependency of `extenddb-auth` with `http`, so the new `tests/sigv4_differential/paths.rs` of this branch reads `Uri` from `http`. `Cargo.lock` is main's, with this branch's `urlencoding` dependency of `extenddb-auth` added back.
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at e47661f. The auth and server crate tests, the sigv4_differential suite, and test_http_routes.py with test_auth_error_fidelity.py on PostgreSQL (81 passed) ran at this head, plus a probe run against main. The review covers how the wire-answer changes are documented for upgrades.
Docs — outside the diff
docs/manuals/07-upgrade-manual.md:385— Please add an entry under Behavior Changes by Release for the clients this change stops serving. A signed ListTablesPOST /from a scratch probe got 200 on main with no Content-Type, withtext/plainand withapplication/x-amz-json-1.1. At this head all three get the 404 page, andGET /changes from 405 to 200healthy: dynamodb.us-east-1.amazonaws.com. An entry that names the two served media types, theGET /and/pinganswers, and the newAuthProvider::authenticatearguments would close this.
navareamol
left a comment
There was a problem hiding this comment.
The branch no longer builds its auth tests against current main. #949 is on main now (5252eda) and added crates/auth/src/scope_tests.rs, which calls provider(false).authenticate(&headers, b"{}") with two arguments. The two-argument shim this PR adds at crates/auth/src/tests.rs line 178 is private to mod tests, and scope_tests is a sibling module, so those calls go to the four-argument trait method. I merged origin/main into e47661f locally (no text conflict) and cargo test -p extenddb-auth stops with 12 E0061 errors, "this method takes 4 arguments but 2 arguments were supplied", at scope_tests.rs lines 32, 80, 100, 117, 204, 260, 263, 300, 314, 342, 396 and 417. The green checks on this head ran on a merge of 3534c9e, before #949. Changing the shim to pub(crate) async fn authenticate fixed it here: 534 lib tests and 15 sigv4_differential tests pass on the merged tree. Could you merge main and push that change, or pass "/" and "" in scope_tests.rs?
botocore signs some query strings in a form the new canonical_query_string refuses. I signed a ListTables with botocore 1.43.127 for each target below and sent it to that same target on a SQLite server built from this head. /?s=a+b, /?t=%7E and /?a=1&&b=2 got InvalidSignatureException. /?t=~, /?b=2&a=1, /?c, /?k=v%2Fw and /?A=1&a=1 were served. botocore's _canonical_query_string_url keeps each pair as sent and sorts them, so it signs s=a+b, t=%7E and an empty pair as =. This PR reads + as a space, decodes %7E to ~ and drops empty pairs, which is what the Rust SDK signer does in paths.rs. Main refuses all of these too, so this is not a regression, but the description names only the /. and /.. path case as a gap with botocore. Has anyone sent these three botocore requests to DynamoDB? If DynamoDB serves them, I think the query rule needs to accept what both signers send. If it refuses them, could you add the three rows to TARGETS in tests/test_http_routes.py so the live run pins the answer, and name these query forms next to the /. note in the description?
I will approve once the branch builds its auth tests on current main and the botocore query rows have a measured answer in the tests or a note in the description.
What
This PR has two commits. The first is the fix below. The second updates one Rust integration test, which expected ExtendDB to answer
GET /with 405. With the fix,GET /gets the health text, as on DynamoDB.ExtendDB now answers a request by its media type, its method and its path, as DynamoDB does.
application/x-amz-json-1.0orapplication/json, in any letter case and with or without parameters. The answer comes back in the media type of the request.GET /with no query string andGET /pingget the texthealthy: dynamodb.<region>.amazonaws.comintext/plain, with no authentication. The text holds only the configured region.POST /with no query string. A request signed for one path now fails at another, as on DynamoDB.ExtendDB's own routes keep their answers:
/healthkeeps its JSON,/metricskeeps its admin authentication, and the routes under/managementand/consolekeep their own authentication. A path under/managementor/consolewith no route keeps its empty 404, and a POST to/healthor/metricskeeps its 405. DynamoDB serves the API at those paths, anddocs/differences-from-dynamodb.mdnow has a row for this difference.How the code does it:
crates/server/src/wire_routes.rs, answers each request that no ExtendDB route takes. It sits behind the same layers as the oldPOST /route, with the 16 MiB body limit./managementand/consoleprefixes itself. A server without a catalog store mounts neither router, and the prefix test keeps the empty 404 there too.AuthProvider::authenticatetakes the path and the query string.canonical_requestbuilds the SigV4 canonical URI and canonical query string from them.response.rsadds the request id and CRC32 headers forsuccess_response,error_response, the page and the health text.No measurement settles one rule of the canonical URI. For a path that ends in
/.or/.., ExtendDB keeps the final slash, as the AWS SDK for Rust signer does. botocore drops it, so ExtendDB refuses a botocore request signed for such a path with InvalidSignatureException.Other open PRs that this change meets:
git merge-treescan on 25 November 2026 against the open heads and main atb0d1c6443:tests/raw_signed_request.py: fix(core): send DynamoDB's text for a B value that does not decode #1260, fix(core): read a B value with its padding left out or cut short #1313, fix(core): read a B value with "=" or another character inside #1355, fix(core): give a set with duplicate members DynamoDB's text #1368 and fix(engine): end a failed ImportTable as DynamoDB does #1370.tests/test_auth_error_fidelity.py: fix(auth): read the request date in the basic and extended ISO-8601 forms #1356. Each side adds a block at the same place, and a resolution keeps both.docs/differences-from-dynamodb.md: docs: architecture dash sweep and one feature status owner #530, docs: configuration reference generated from the sample file, pinned to the structs #537 and feat(bigtable): add Google Cloud Bigtable storage backend #1154 change the Storage backend row of the table, and this PR adds the HTTP endpoint and path row after it. A resolution keeps their row and this PR's row.authenticate. Whichever of test(auth): pin the order of the scope date and token expiry checks #949 and fix(server): answer by media type, method and path as DynamoDB does #1079 merges second must adapt theauthenticatecalls inscope_tests.rsto the path and query string arguments.Why
The answers are DynamoDB's, measured in us-east-1. I measured the issue's rows on 14 November 2026. On 17 November 2026, requests showed the order of the rules, the signature,
GET /pingwith a query string and the 413 over 16 MiB. Each request went out twice and got the same answer both times. This PR leaves the empty body of DynamoDB's 413 to #1076, and the error type of a request with no Authorization header to #1075.Closes #1020
Merge of #1003
84a75b3d9mergesmainata60c2b9f3(#1003). Incrates/auth/src/lib.rs,verify_signaturetakes main's cached signing key and this branch's path and query string. Thesigv4_differentialharness builds main's provider over a pass-through credential cache. The follow-upb4967521fgives the two-argumentauthenticateshim oftests.rsthe typeBuiltinAuthProvider, which #1003 made non-generic.At
b4967521f,cargo +1.97.0 test --locked -p extenddb-auth --libgives 533 passed, and thesigv4_differentialsuite 15 passed.cargo +1.97.0 test --locked -p extenddb-server --libgives 515 passed, and 5backup_storetests fail because of the test host's sandbox user.Merges of 24 November
f2d4555f6mergesmainat018715e0d(#774). Incrates/server/src/response.rsboth sides add a block after the imports, and the merge keeps both.e47661ff7mergesmainat3534c9e4d(#1009), which moved the error body toextenddb_core::error::error_document. Incrates/server/src/response.rsthe merge keeps this branch'swire_responseand drops the local copy ofSERIALIZATION_FAILURE_BODY, which main now imports fromcrates/core/src/error/mod.rs.Cargo.lockis main's, with this branch'surlencodingdependency ofextenddb-authadded back. #1009 replaced theaxumdependency ofextenddb-authwithhttp, sotests/sigv4_differential/paths.rsreadsUrifromhttp.At
e47661ff7, with--locked:cargo +1.97.0 check --workspace --all-targetsis clean.cargo +1.97.0 test -p extenddb-auth --libgives 533 passed, and thesigv4_differentialsuite 15 passed.cargo +1.97.0 test -p extenddb-server --libgives 516 passed, and the 5backup_storetests fail because of the test host's sandbox user.cargo test -p extenddb-wasm-adapterpasses its 3 tests and the parity corpus.-D warningson the auth and server crates, andcargo fmt --check, are clean.Testing done
On the fix commit:
cargo test -p extenddb-auth: 533 passed. The signer comparison tests sign requests for 9 paths and query strings with the AWS SDK for Rust signer. Each request passes at its own target and fails at another.cargo test -p extenddb-server --lib: 503 passed. 5backup_storetests fail on the test host on main too, because of its sandbox user.tests/test_http_routes.py: 54 passed on the SQLite backend over TLS. In dev mode over plain HTTP, 54 passed on the previous version of the commit, before the last change to the size rule.tests/test_auth_error_fidelity.py: 27 passed on the SQLite backend.cargo +1.97.0 clippy -p extenddb-auth -p extenddb-server --all-targets -- -D warningsandcargo fmt --checkare clean.Line counts: production +252 -56, tests +548 -54, docs +15 -10.
Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: none. The change brings the wire answers to DynamoDB's measured ones, and it changes the
AuthProvidertrait (see Breaking changes).Breaking changes
/in a media type other thanapplication/x-amz-json-1.0orapplication/json, or with no Content-Type, now gets a 404. Before, ExtendDB served it.AuthProvider::authenticatetakes two more arguments, the path and the query string.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.