Repository navigation
fix(server): authenticate a request with an empty body first - #1265
LeeroyHannigan wants to merge 11 commits into
Conversation
For a DescribeTable request with an empty body and no signature,
DynamoDB answers MissingAuthenticationTokenException. Signed for an
access key that does not exist, it answers UnrecognizedClientException.
ExtendDB answered both with a SerializationException, since it checked
the JSON syntax of the body before authentication.
Measured in us-east-1 on 2026-11-20. Each body went out twice and got
the same answer both times. A body of one space, a lone "{" or a lone
byte order mark got a SerializationException, unsigned and with the
unknown key. The bodies {}, null, [], "x" and 5 got the authentication
error. Signed, an empty body got a SerializationException with no
message.
ExtendDB now parses an empty body only after authentication. That parse
refuses it with no message, as before. ExtendDB's type and text for a
missing signature still differ from DynamoDB's (#1075).
Fixes #1259.
An empty body now goes to authentication before its syntax is read, as DynamoDB does. The raw HTTP test of an unsigned empty body expected a SerializationException and skipped DynamoDB. It now expects the missing token error, which DynamoDB also sends, and runs on both.
Merges 748d21e of fix/1195-syntax-fault-message. That brings in fix/request-nesting-depth at 4c2995c and the merge commit of that branch. The 4c2995c head holds the syntax scan with the service's grammar in request_syntax.rs and the merges of main at 44cd436 and 6aef346. Conflicts and their resolution, both in tests/test_request_nesting_depth.py: - test_a_malformed_deep_body_is_refused_before_authentication: the other branch added the leaf parameter and its rows. This branch renamed the helper _unauthenticated_post. Kept: the other branch's body construction and comment, and the call to _unauthenticated_post. - test_a_complete_deep_body_reaches_authentication: the same two changes on the same lines. Kept the same way. Auto-merged: handler.rs keeps the empty body branch before the one-argument check_request_syntax call. request_parse.rs keeps the module doc sentence about an empty body beside the other branch's check. tests/rust/src/raw_http.rs and tests/test_syntax_fault_message.py are this branch's alone.
The security manual's paragraph on the syntax check, from fix/request-nesting-depth, said that every body is checked before authentication. On this branch a body of zero bytes goes to authentication first, as on the service, and the parse refuses it after that. The paragraph now says so.
The note that an empty body goes to authentication first now follows the syntax check paragraph as a paragraph of its own. The first sentence of that paragraph is again the one fix/request-nesting-depth wrote. The sibling branches fix/1257-leading-zero-numbers and fix/1343-number-forms change a later sentence of the same paragraph. With the note inside that paragraph, every edit to it conflicted with theirs. The paragraphs now merge clean.
Merges 0986467 of fix/1195-syntax-fault-message, its merge of fix/request-nesting-depth at b9baaf5. That commit merges main at 018715e, five commits past 6aef346: - #503: the stream retention cutoff shape on SQLite - #526: the Return fields on a TransactWriteItems token replay - #690: catalog-check matches data relations by catalog id - #765: the FilterExpression suffix in the values message - #774: the Message key on two errors No conflicts. None of the five changes a file of this branch. #774 changes crates/server/src/response.rs, which renders the refusals and the authentication errors that this branch's tests assert. The two errors that get the Message key are not among them. A refusal with an empty message still has no message key.
Merges 654fef3 of fix/1195-syntax-fault-message, its merge of fix/request-nesting-depth at 1a9efd7. That brings main at b0d1c64 (#1280, #1009 and #596). It also brings the commit that makes the handler call extenddb_engine::check_operation and with_body(input).admit() around the server's parse. The README item on the PartiQL operations now says that a server answers a body that does not parse with no message. No conflicts. crates/server/src/handler.rs auto-merged. The two hunks of the other branch are the name check and the point-in-time refusal. This branch's empty body branch, before the parse and the syntax check, sits between them. So the handler checks the operation name and scans the depth, and it leaves an empty body for later. Then it authenticates the caller, parses the body and calls admit.
Merges 7d7a089 of fix/1195-syntax-fault-message. That brings three commits: - its merge of fix/request-nesting-depth at 027483d, which changes one sentence of the WebAssembly adapter's module doc - 3f5ccff, after which the helper _is_messageless_serialization_error of tests/test_request_nesting_depth.py compares the whole error document - 7d7a089, after which REQ-ERR-002 in docs/design/01-requirements.md says that a SerializationException for a body that does not parse has no message field No conflicts. tests/test_request_nesting_depth.py auto-merged: the helper is above this branch's _unauthenticated_post. This branch's refused rows in tests/test_syntax_fault_message.py call the helper, so they now compare the whole document too.
test_which_bodies_are_refused_before_authentication compared only the start of the type after the "#" for a body that reaches authentication. For an access key that does not exist, the service and the server send the same message (DescribeTable, us-east-1, 2026-11-25). The test now compares it by equality with "The security token included in the request is invalid." The test does not compare the message for a missing signature, because ExtendDB's type and message differ from the service's (#1075). The comment above AUTHENTICATION_ERRORS now says so.
Merges 600726b of fix/1195-syntax-fault-message, its merge of fix/request-nesting-depth at 71b3e1b. That brings the rows at the edges of the syntax check's looser rules. At 63 and at 20000 wrappers, the numbers 1+, 1e+5 and 1.eE-+ and the escape \ugggg reach authentication. The numbers +1 and .5 and the escapes \u000/ and \u000h get a refusal before it. No conflicts. crates/server/src/request_parse.rs and tests/test_request_nesting_depth.py auto-merged. The new rows are parameters of the two tests that send through _unauthenticated_post, this branch's name for the helper. They run unsigned and badly signed.
navareamol
left a comment
There was a problem hiding this comment.
I think the description and the new test table disagree on the count. The description says "all 30 body and signing pairs in the table", and its Why table lists {} with the bodies that reach authentication. UNAUTHENTICATED_ROWS in tests/test_syntax_fault_message.py has 14 bodies and no {}, so the test sends 28 pairs. Against SQLite at fb0d3ea, {} to DescribeTable, unsigned and signed for the unknown key, gets the authentication error, so adding "empty-object": (b"{}", False) should pass. Could you add that row, or change the number in the description?
The new test pins two of the signings the description lists for an empty body. AUTHENTICATION_ERRORS has the unsigned and unknown key cases only. The description also says a wrong secret gets InvalidSignatureException, a credential scoped to another region gets InvalidSignatureException, and an Authorization header with no = gets IncompleteSignatureException. I checked those on SQLite: each fails on a server built from fb0d3ea with the empty body branch removed and passes at fb0d3ea, so the behaviour is right. _unauthenticated_post already takes "bad-signature". Could you add it to AUTHENTICATION_ERRORS with ("InvalidSignatureException", None), so the wrong secret case is pinned by this PR's own test?
For the stack: this head does not merge cleanly with current main (222d80a). The conflict is in crates/engine/src/lib.rs, between main's #[cfg(test)] mod test_context; and the pub use pre_dispatch line from #807, so it comes from the base and not from this PR. Keeping both lines builds, and the same tests pass on that merged tree against SQLite. CI on fb0d3ea ran against fix/1195-syntax-fault-message only, so I think it needs a run on a tree updated with main once the base lands.
I will approve once the {} row and the wrong secret case are in the test table, or the description says 28 pairs, and CI is green on a branch updated with main.
test_which_bodies_are_refused_before_authentication now sends `{}` too,
and it signs each body with the caller's key and a wrong secret as well.
DynamoDB answers a DescribeTable with the body `{}` with the
authentication error (us-east-1, 2026-11-20 and 2026-12-03). With no
signature it sends MissingAuthenticationTokenException, and for an
access key that does not exist UnrecognizedClientException. With the
caller's key and a wrong secret, it refuses the eight bodies that the
syntax check refuses with a SerializationException with no message. It
answers the other seven with InvalidSignatureException (2026-12-03, and
the empty body on 2026-11-20). ExtendDB sends the same message for this
exception, so the test compares it by equality.
The table now has 15 bodies and three signings, so the test sends 45
pairs. On a server built from this branch with the empty body branch of
handle_request removed, the three pairs with the empty body fail. The
pair with the wrong secret is one of them.
|
The The wrong secret: 53d0c75 also adds The test now sends 15 bodies with three signings, 45 pairs, and the description says 45. At 53d0c75 the file passes 60 tests against SQLite and 60 against PostgreSQL. I also built a server from fb0d3ea with the empty body branch removed. Against it, 3 of the 60 fail: the empty body with no signature, for the unknown key, and with the wrong secret. The The stack and |
|
The
Five checks are red at 53d0c75: run-tests (stable and 1.91.1), test, mongodb-rust and mongodb-integration. The logs show I will approve once the checks are green after the stack has taken main at #807. |
Changes since the last review
test(server): send `{}` and a wrong secret in the empty body test.UNAUTHENTICATED_ROWSintests/test_syntax_fault_message.pygets the row"empty-object": (b"{}", False).AUTHENTICATION_ERRORSgets"bad-signature", a signature with the caller's key and a wrong secret, withInvalidSignatureExceptionand its message. The service and ExtendDB send the same message, so the test compares it by equality. The table now has 15 bodies and three signings, and the test sends 45 pairs. The Why table gets a column for the wrong secret, measured on 3 December 2026. At 53d0c75, the file passes 60 tests against SQLite and 60 against PostgreSQL. With the empty body branch removed, the three pairs with the empty body fail, and the{}row passes.Merge fix/1195-syntax-fault-message into fix/1259-empty-body-auth. It merges fix(server): send no message for a body with a JSON syntax fault #1261 at 600726b, which carries fix(server): parse request bodies nested to the depth the service validates #807 at 71b3e1b. fix(server): parse request bodies nested to the depth the service validates #807's 71b3e1b adds rows at the edges of the syntax check's looser rules. At 63 and at 20000 wrappers,1+,1e+5,1.eE-+and\uggggreach authentication.+1,.5,\u000/and\u000hget a refusal before it. No file conflicted. Intests/test_request_nesting_depth.py, the new rows are parameters of the two tests that send through this PR's_unauthenticated_post. This PR's added and removed lines over fix(server): send no message for a body with a JSON syntax fault #1261 are the same as before the merge. At fb0d3ea,cargo fmt --all -- --checkandcargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warningsare clean. So iscargo +1.91.1 check -p extenddb-server --all-targets. The 11request_parseunit tests pass. Three changes to the check each fail a new row, as on fix(server): send no message for a body with a JSON syntax fault #1261.tests/test_request_nesting_depth.py(105) andtests/test_syntax_fault_message.py(43) pass 148 tests against SQLite. The 10raw_httptests oftests/rustpass against a server of the same build. The clippy step ofwasm.ymlis clean, run locally with a stand-in C compiler because clippy does not link.pytest --collect-onlycollectstests/(6808) andtests/python(672) with no error.test(server): compare the unknown key's message in the empty body test.test_which_bodies_are_refused_before_authenticationcompared only the start of the type after the#for a body that reaches authentication. For an access key that does not exist, the service and ExtendDB send the same message (DescribeTable, 25 November 2026). The test now compares it by equality: "The security token included in the request is invalid." It does not compare the message for a missing signature, because ExtendDB's type and message differ from the service's (A request with no Authorization header gets the typeMissingAuthenticationTokenand the message "Missing Authentication Token", where DynamoDB sendsMissingAuthenticationTokenException#1075). The comment aboveAUTHENTICATION_ERRORSnow says so. With one character of the expected message changed, the 6 unknown key rows that reach authentication fail against SQLite. At 9f7b74f,cargo fmt --all -- --checkandcargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warningsare clean. The 11request_parseunit tests pass.tests/test_request_nesting_depth.pyandtests/test_syntax_fault_message.pypass 116 tests against SQLite. The 10raw_httptests oftests/rustpass against a server of the same build. The clippy step ofwasm.ymlis clean, run locally with a stand-in C compiler because clippy does not link.pytest --collect-onlycollectstests/(6776) andtests/python(672) with no error.Merge fix/1195-syntax-fault-message into fix/1259-empty-body-auth. It merges fix(server): send no message for a body with a JSON syntax fault #1261 at 7d7a089, which carries fix(server): parse request bodies nested to the depth the service validates #807 at 027483d and two commits of fix(server): send no message for a body with a JSON syntax fault #1261. fix(server): parse request bodies nested to the depth the service validates #807's 027483d changes one sentence of the WebAssembly adapter's module doc. After fix(server): send no message for a body with a JSON syntax fault #1261's two commits, the helper_is_messageless_serialization_errorcompares the whole error document, so the refused rows of this PR's table do too. REQ-ERR-002 indocs/design/01-requirements.mdsays that aSerializationExceptionfor a body that does not parse has no message field. No file conflicted.tests/test_request_nesting_depth.pyauto-merged: the helper is above this PR's_unauthenticated_post.Merge fix/1195-syntax-fault-message into fix/1259-empty-body-auth. It merges fix(server): send no message for a body with a JSON syntax fault #1261 at 654fef3, which carries fix(server): parse request bodies nested to the depth the service validates #807 at 1a9efd7 and main at b0d1c64: test(storage-mongodb): end the killed holder's lease by data, not by waiting #1280, feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 and UpdateExpression ADD creates no missing map on its path #596. fix(server): parse request bodies nested to the depth the service validates #807's 1a9efd7 makes the handler callextenddb_engine::check_operationbefore its body checks andwith_body(input).admit()after authentication. No file conflicted. Inhandler.rs, those two hunks auto-merged around this PR's empty body branch. So the handler checks the operation name and scans the depth, and it leaves an empty body for later. Then it authenticates the caller, parses the body and callsadmit. fix(server): send no message for a body with a JSON syntax fault #1261's merge edits the README item on the PartiQL operations. The item now says that a server answers a body that does not parse with no message. This PR's change over fix(server): send no message for a body with a JSON syntax fault #1261 is its change before the merge, with two hunks ofhandler.rsat new line numbers. At d3d8981,cargo fmt --all -- --checkandcargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warningsare clean. The 11request_parseunit tests pass.tests/test_request_nesting_depth.pyandtests/test_syntax_fault_message.pypass 116 tests against SQLite. The 10raw_httptests oftests/rustpass against a server of the same build. The clippy step ofwasm.ymlis clean, run locally with a stand-in C compiler because clippy does not link.pytest --collect-onlycollectstests/(6776) andtests/python(672) with no error.Merge fix/1195-syntax-fault-message into fix/1259-empty-body-auth. It merges fix(server): send no message for a body with a JSON syntax fault #1261 at 0986467, which carries fix(server): parse request bodies nested to the depth the service validates #807 at b9baaf5 and main at 018715e: fix(sqlite): render the stream retention cutoff in the created_at column shape #503, fix(engine): compare the Return fields on a TransactWriteItems token replay #526, fix: match data relations by catalog id in catalog-check, so --fix keeps live tables #690, fix(scan): drop the FilterExpression suffix from the values message #765 and fix(server): send Message on the two errors the service sends it on #774. No file conflicted, and this PR's change over fix(server): send no message for a body with a JSON syntax fault #1261 is byte for byte its change before the merge. fix(server): send Message on the two errors the service sends it on #774 changescrates/server/src/response.rs, which renders the refusals and the authentication errors these tests assert. The two errors that now get theMessagekey are not among them. At 91a55bc, formatting and clippy are clean, and the 11request_parseunit tests pass.tests/test_request_nesting_depth.pyandtests/test_syntax_fault_message.pypass 116 tests against SQLite, and the 10raw_httptests oftests/rustpass against the same server.pytest --collect-onlycollectstests/(6753) andtests/python(672) with no error.docs(server): say that an empty body goes to authentication firstand 6eed1fedocs(server): move the empty body note to its own paragraph. A new paragraph of the security manual follows the one on the syntax check. It says that a body of zero bytes goes to authentication first, as on the service, and that the parse refuses it after that. The syntax check paragraph keeps the text fix(server): parse request bodies nested to the depth the service validates #807 wrote, so the manual merges with fix(server): read a number written with leading zeros in a request body #1344 and fix(server): read a trailing point and a lone minus sign in a request number #1372 with no conflict.Merge fix/1195-syntax-fault-message into fix/1259-empty-body-auth. It merges fix(server): send no message for a body with a JSON syntax fault #1261 at 748d21e, with fix(server): parse request bodies nested to the depth the service validates #807's fix round and main at 6aef346. The two conflicting hunks oftests/test_request_nesting_depth.pykeep fix(server): parse request bodies nested to the depth the service validates #807'sleafrows with this PR's_unauthenticated_post.handler.rsmerged on its own, with the empty body branch before the one-argumentcheck_request_syntaxcall.What
A request with an empty body now goes to authentication before ExtendDB reads the body, as DynamoDB does. Before this change, ExtendDB checked the JSON syntax of each body before authentication, and an empty body failed that check with a SerializationException.
The change is in
crates/server/src/handler.rs. The check before authentication skips a body of zero bytes. After authentication, the parse refuses an empty body withserialization_refusal(), as it did before, so a signed empty body still gets a SerializationException with no message. Every other body takes the same path as before.In the tests,
_unauthenticated_putintests/test_request_nesting_depth.pyis now_unauthenticated_post. It takes the operation, and it can sign for an access key that does not exist.tests/test_syntax_fault_message.pygets one table of 15 bodies. The test sends each body unsigned, signed for that key, and signed with the caller's key and a wrong secret.The Rust test
empty_bodyintests/rust/src/raw_http.rssends an unsigned GetItem with an empty body. It expected a SerializationException and skipped DynamoDB. It now expects the missing token error and runs against DynamoDB too.The base of this PR is #1261, which changes the same lines of
handler.rs.A new paragraph of the security manual (
docs/manuals/10-security-model.md) states this order for an empty body.Why
DynamoDB's answers, measured in us-east-1 on 20 November 2026. Each DescribeTable request went out twice and got the same answer both times. "Unknown key" is a signature for an access key that does not exist. "Wrong secret" is a signature with the caller's key and a wrong secret key. The wrong secret column comes from 3 December 2026, except for the empty body (20 November). On 3 December the
{}row got the same answers again, with no signature and for an unknown key.\n\t,\n,{,x, a byte order mark alone,{not json, one NUL byte{},null,[],"x",5,{"TableName": "<table>"}So DynamoDB checks the JSON syntax of a body before authentication. A body of zero bytes is the one body that passes this check with no JSON in it. Other requests with an empty body, measured the same day, got these answers.
Authorizationheader with no=: IncompleteSignatureExceptionOn #1261's head, ExtendDB answered every one of these unsigned or badly signed requests with a SerializationException. With this change, each of them gets DynamoDB's exception type, as do all 45 body and signing pairs in the table. The type for a missing signature differs (#1075), and so does the namespace of UnrecognizedClientException (#1116).
Fixes #1259
Testing done
run-testsjobs, on stable and on 1.91.1, rancargo test --locked --workspace --exclude extenddb-backup-storeandcargo test --locked -p extenddb-backup-store. In each job, the server crate's unit tests gave 530 passed and 0 failed. 53d0c75 changes onlytests/test_syntax_fault_message.py, and CI has not run on it yet.cargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean at 6aa0a50, at ff8f38b and at 91a55bc.tests/test_syntax_fault_message.pyandtests/test_request_nesting_depth.pypassed 70 tests. Against a server built from fix(server): send no message for a body with a JSON syntax fault #1261's head, an empty body gets a SerializationException, unsigned and with an unknown key.tests/test_syntax_fault_message.pypassed 60 tests against SQLite and 60 against PostgreSQL. The servers ran a build of fb0d3ea, whose Rust code 53d0c75 keeps. Withtests/test_request_nesting_depth.py, 165 tests passed against each.handle_requestremoved fails 3 of the 60 tests. They are the empty body with no signature, for the unknown key, and with the wrong secret. The{}row passes there, because that branch changes only a body of zero bytes.pytest --collect-onlycollectstests/(6825) andtests/python(672) with no error.The unit tests have no new row. The existing unit row for
b""already checks the answer after authentication, and the signedemptyrow oftests/test_syntax_fault_message.pychecks it on the wire.Line counts of this PR's own change at 53d0c75: production +11 -5, tests +97 -14, and one new paragraph of the security manual.
This PR adds no conflict with an open PR: each open PR that conflicts with it has the same conflicting files with #1261. Its empty body branch in
handler.rsfalls inside a conflict hunk that #200, #547, #549, #557, #587, #850 and #854 each already have there. 28 open PRs outside #807, #1261, #1265, #1344 and #1372 changedocs/manuals/10-security-model.md. Of these, only #140 conflicts with this branch in that file, and it has the same four conflict hunks withmain. At 53d0c75,git merge-treeshows no conflict with #1344 at 693b815 or #1372 at 4f689ba.With
mainat c057660 (3 December 2026),git merge-treeof 53d0c75 reports conflicts inREADME.md,crates/engine/src/lib.rsandcrates/wasm-adapter/src/runtime.rs. #1261 at 600726b and #807 at 71b3e1b have the same three conflicts. This PR changes none of the three files.Not in this PR, each in an open issue:
MissingAuthenticationTokenand the message "Missing Authentication Token", where DynamoDB sendsMissingAuthenticationTokenException#1075).__typenamespace of UnrecognizedClientException (UpdateTable with a table ARN of an account that does not exist answers AccessDeniedException with another __type and message key than DynamoDB #1116).Authorizationheader with no=(An Authorization header with no equal sign gets another IncompleteSignatureException text than DynamoDB's #1264).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: n/a
Breaking changes
A request with an empty body and no valid signature now gets the authentication error, where it got a
SerializationExceptionwith no message. With no signature, it gets ExtendDB'sMissingAuthenticationTokenerror (#1075). Signed for an access key that does not exist, it getsUnrecognizedClientException, and with a wrong secretInvalidSignatureException. A signed empty body still gets theSerializationExceptionwith no message.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.