Skip to content

fix(auth): end the algorithm of an Authorization header at a comma - #1304

Open
LeeroyHannigan wants to merge 1 commit into
fix/1270-authorization-textsfrom
fix/1292-comma-after-algorithm
Open

LeeroyHannigan wants to merge 1 commit into
fix/1270-authorization-textsfrom
fix/1292-comma-after-algorithm

Conversation

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator

What

The Authorization parse 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_authorization in crates/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 a Credential pair of the documentation's example key with the scope date of the send day, SH is SignedHeaders=host;x-amz-target and SIG is Signature= and 64 zeros. Each request has an X-Amz-Date of the send time unless the row says otherwise.

  • MISS(x) is Authorization header requires 'x' parameter.
  • DATE is Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header.
  • HASH is (Hashed with SHA-256 and encoded with Base64) Authorization=<hash>.
  • EQ is Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): '<hash>'.
  • UNREC is UnrecognizedClientException, The security token included in the request is invalid.

Each answer is IncompleteSignatureException unless the row names another type.

Authorization DynamoDB ExtendDB on #1295 ExtendDB with this PR
ALG,CRED, SH, SIG UNREC MISS(Credential) HASH UNREC
ALG,CRED, SH, SIG, no X-Amz-Date DATE HASH MISS(Credential) DATE HASH DATE HASH
ALG, MISS(Credential) MISS(Signature) MISS(SignedHeaders) HASH the same the same
ALG,garbage EQ MISS(Credential) MISS(Signature) MISS(SignedHeaders) HASH EQ
AWS4-X,CRED, SH, SIG Unsupported AWS 'algorithm': 'AWS4-X'. MISS(Credential) HASH DynamoDB's
aws4-hmac-sha256,CRED, SH, SIG Algorithm must start with 'AWS4-'; got '<value>' the same the same
Bearer,abc MissingAuthenticationTokenException, Request is missing Authentication Token MissingAuthenticationToken, Missing Authentication Token the same as on #1295
ALG, CRED, SH, SIG UNREC Unsupported AWS 'algorithm': 'AWS4-HMAC-SHA256,'. UNREC
ALG,,CRED, SH, SIG UNREC MISS(Credential) HASH UNREC
garbage,CRED, SH, SIG as Bearer,abc as Bearer,abc as Bearer,abc

With 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 Authorization header, which #1075 covers (#1290). ExtendDB sends UNREC in another __type namespace than DynamoDB (#1303).

The wire test sends the scope date 20261120. On 21 November, DynamoDB gave AWS4-X,CRED, SH, SIG with that scope date the answer in the table.

Testing done

  • cargo test -p extenddb-auth: 535 unit tests, 14 sigv4_differential tests and 3 doc tests passed.
  • cargo +1.97.0 clippy -p extenddb-auth --all-targets -- -D warnings and cargo +1.97.0 fmt --all -- --check are clean.
  • The unit table malformed_authorization_header has a new row with DynamoDB's text and hash for ALG,CRED, SH, SIG with no date. Without the comma in the split, that row fails.
  • Against ExtendDB on SQLite, tests/test_auth_error_fidelity.py, tests/test_auth_integration.py and tests/test_auth_permissions.py passed 223 tests. The 10 requests went to the same server and got the answers in the table.
  • The 3 new wire rows fail against fix(auth): name every missing Authorization parameter as DynamoDB does #1295.
  • These wire runs used the commit before its last amend. The amend removed 2 wire rows, which pass on fix(auth): name every missing Authorization parameter as DynamoDB does #1295 too, and changed the commit message.
  • No AWS SDK writes a comma after the algorithm: botocore and aws-sigv4 write a space. A test put a comma after the algorithm of a ListTables request that botocore signed. That request gets HTTP 200 with this change and HTTP 400 on fix(auth): name every missing Authorization parameter as DynamoDB does #1295. DynamoDB's answer to that request with a valid key is not measured.

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:

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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.

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 demohan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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.

2 participants