Repository navigation
fix(auth): end the algorithm of an Authorization header at a comma - #1304
LeeroyHannigan wants to merge 1 commit into
Conversation
ExtendDB ended the first word of an Authorization header at a space or a tab only. With a comma right after the algorithm, the first word ran on to the first space. ExtendDB then answered that parameters were missing, or, when a space followed the comma, refused the word as the algorithm. DynamoDB ends the first word at a comma too. It answers "AWS4-HMAC-SHA256,Credential=..., SignedHeaders=..., Signature=..." as the same pairs after a space, and "AWS4-X,..." with the unsupported algorithm text for "AWS4-X". Measured in us-east-1 on 21 Nov 2026. Fixes #1292.
demohan
left a comment
There was a problem hiding this comment.
The algorithm ends at a comma at 88067f9, and no malformed header authenticates. With 48 signed header shapes and 23 fixed headers sent to us-east-1 and to this head and its base on SQLite and PostgreSQL, twice each, every shape that reached ResourceNotFoundException here also did on the service, and the shapes the service refuses (no separator, ; or = in the algorithm, lowercase, an unknown algorithm, Bearer,) are refused here, with the service's text for each refusal this PR touches. botocore and aws-sigv4 1.3.8 and 1.4.4 put a space before the first comma, so their headers split as before, and the aws CLI and a boto3 create, put, get and delete pass on both backends. Without the comma in the split, malformed_authorization_header fails, the three new wire rows fail on the base, the auth crate tests and 221 wire tests on each backend pass, fmt, clippy and the 1.91.1 check are clean, and CI is green on 59 of 59. It merges with #1306, and on main at 222d80a it adds no conflict of its own; with the lower PRs' conflicts resolved, it builds with --locked and the fidelity file passes 73 of 73.
| id="comma-after-algorithm-with-date"), | ||
| ], | ||
| ) | ||
| def test_authorization_answered_as_another(self, date, header, reference): |
There was a problem hiding this comment.
Optional. Two of the body's rows have no case here: ALG, CRED, SH, SIG (comma then space) and ALG,,CRED, SH, SIG answer UnrecognizedClientException on the service and this head, where the base answered Unsupported AWS 'algorithm': 'AWS4-HMAC-SHA256,'. and the missing Credential text. Adding both would hold all eight the body lists.
What
The
Authorizationparse now ends the algorithm at a comma, as it does at a space or a tab. Before, a comma right after the algorithm left the first pair in the first word. The parse then answered that parameters were missing. When a space followed the comma, it refused the word as the algorithm.The change is one line of
parse_authorizationincrates/auth/src/sigv4/parse.rs:split_once([' ', '\t', ',']).The base of this PR is #1295, which changes the same line.
Fixes #1292
Why
These are DynamoDB's answers, measured in us-east-1 on 21 November 2026 with DescribeTable requests of a table that does not exist. Each request went out twice and got the same answer both times. ALG is
AWS4-HMAC-SHA256. CRED is aCredentialpair of the documentation's example key with the scope date of the send day, SH isSignedHeaders=host;x-amz-targetand SIG isSignature=and 64 zeros. Each request has anX-Amz-Dateof the send time unless the row says otherwise.Authorization header requires 'x' parameter.Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header.(Hashed with SHA-256 and encoded with Base64) Authorization=<hash>.Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): '<hash>'.The security token included in the request is invalid.Each answer is IncompleteSignatureException unless the row names another type.
AuthorizationALG,CRED, SH, SIGALG,CRED, SH, SIG, noX-Amz-DateALG,ALG,garbageAWS4-X,CRED, SH, SIGUnsupported AWS 'algorithm': 'AWS4-X'.aws4-hmac-sha256,CRED, SH, SIGAlgorithm must start with 'AWS4-'; got '<value>'Bearer,abcRequest is missing Authentication TokenMissing Authentication TokenALG, CRED, SH, SIGUnsupported AWS 'algorithm': 'AWS4-HMAC-SHA256,'.ALG,,CRED, SH, SIGgarbage,CRED, SH, SIGBearer,abcBearer,abcBearer,abcWith this change, 8 of the 10 requests get DynamoDB's type and message, where 2 did on #1295. The other two get ExtendDB's answer to a request with no
Authorizationheader, which #1075 covers (#1290). ExtendDB sends UNREC in another__typenamespace than DynamoDB (#1303).The wire test sends the scope date 20261120. On 21 November, DynamoDB gave
AWS4-X,CRED, SH, SIGwith that scope date the answer in the table.Testing done
cargo test -p extenddb-auth: 535 unit tests, 14sigv4_differentialtests and 3 doc tests passed.cargo +1.97.0 clippy -p extenddb-auth --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean.malformed_authorization_headerhas a new row with DynamoDB's text and hash forALG,CRED, SH, SIGwith no date. Without the comma in the split, that row fails.tests/test_auth_error_fidelity.py,tests/test_auth_integration.pyandtests/test_auth_permissions.pypassed 223 tests. The 10 requests went to the same server and got the answers in the table.Line counts: production +3 -2, tests +12 -1.
This PR adds no conflict with origin/main or with an open PR that changes its files.
Not in this PR:
Authorizationheader (A request with no Authorization header gets the typeMissingAuthenticationTokenand the message "Missing Authentication Token", where DynamoDB sendsMissingAuthenticationTokenException#1075, PR fix(core): answer a request with no Authorization header as DynamoDB does #1290).__typenamespace of UnrecognizedClientException (UnrecognizedClientException carries the com.amazonaws.dynamodb.v20120810 namespace, where DynamoDB sends com.amazon.coral.service #1303).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
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.