Skip to content

fix(auth): answer an Authorization part with no '=' with DynamoDB's text - #1277

Open
LeeroyHannigan wants to merge 6 commits into
mainfrom
fix/1264-auth-missing-equal-sign
Open

LeeroyHannigan wants to merge 6 commits into
mainfrom
fix/1264-auth-missing-equal-sign

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

A part of the Authorization header with no = after the algorithm now gets DynamoDB's IncompleteSignatureException text:

Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): '<hash>'.

<hash> is the standard Base64 of the SHA-256 of the header value. Before this change, ExtendDB skipped such a part and answered with the text of a later check, such as Authorization header requires 'Credential' parameter.

On PutItem, GetItem, DeleteItem, UpdateItem, Query, Scan, BatchGetItem, TransactGetItems and TransactWriteItems, DynamoDB reads the parts by position for a valid request body. The first part is Credential, the second is SignedHeaders and the rest of the value is Signature. On these operations the text above answers only when a parameter is missing and the last of the three parts has no =. Otherwise ExtendDB names the missing parameter, and a part after the signature is part of the signature. The other operations read the parts by key, and the text answers wherever the part sits. ExtendDB makes the choice from the operation alone. With a body that is not a valid request, such as {}, DynamoDB reads the parts by key, and ExtendDB still reads them by position. docs/differences-from-dynamodb.md lists this difference (#1552).

The change is in parse_authorization (crates/auth/src/sigv4/parse.rs), which now takes a by_position flag, and in its caller authenticate (crates/auth/src/lib.rs), which sets the flag from X-Amz-Target. The 8 KB cap and the algorithm check still run first. The parse by key still skips an empty part, such as the one after a trailing comma. The auth crate now uses the workspace's base64 crate for the hash. That crate is already in the auth crate's dependency graph through extenddb-core, so Cargo.lock gains one line and no package.

Why

DynamoDB's answers, measured in us-east-1 on 20 November 2026 with DescribeTable requests. Each request went out twice and got the same answer both times. CRED, SH and SIG are well-formed Credential, SignedHeaders and Signature pairs for the documentation's example key. EQ is the text above.

Authorization DynamoDB ExtendDB on main
AWS4-HMAC-SHA256 garbage EQ Authorization header requires 'Credential' parameter
AWS4-HMAC-SHA256 garbage, CRED, SH, SIG EQ Authorization header requires existence of 'X-Amz-Date' header
AWS4-HMAC-SHA256 CRED, SH, SIG, garbage EQ Authorization header requires existence of 'X-Amz-Date' header
AWS4-HMAC-SHA256 CRED, garbage, SIG EQ Authorization header requires 'SignedHeaders' parameter
AWS4-HMAC-SHA256 garbage, other EQ Authorization header requires 'Credential' parameter
AWS4-HMAC-SHA256 Credential EQ Authorization header requires 'Credential' parameter

DynamoDB gave EQ for the first row with an X-Amz-Date header too, and for PutItem. The quoted hash is the hash of the header value, with spaces and tabs at either end removed. With this change, ExtendDB gives each of these requests DynamoDB's type and full text. It also hashes what DynamoDB hashes for values with spaces or tabs at either end or inside.

DynamoDB's answers on the item operations, measured in us-east-1 on 2 and 3 December 2026 with an X-Amz-Date header and a valid body, each request twice. MISS names the missing parameters, which #1295 gives in DynamoDB's form.

Authorization after the algorithm Operation DynamoDB
garbage, CRED, SH, SIG the nine item operations MISS for Credential, Signature and SignedHeaders
garbage, CRED, SH, SIG BatchWriteItem EQ
CRED, garbage, SH, SIG PutItem MISS for Signature and SignedHeaders
CRED, garbage, SH, other PutItem MISS for Signature and SignedHeaders
CRED, SH, garbage, SIG PutItem MISS for Signature
CRED, SH, garbage PutItem EQ
garbage, CRED, other PutItem EQ
CRED, SH, SIG, garbage, valid signature PutItem InvalidSignatureException
CRED, SH, SIG, garbage, valid signature DescribeTable EQ

DynamoDB's answers to garbage, CRED, SH, SIG with other bodies, measured in us-east-1 on 3 December 2026, each request twice. With a body that is not a valid request, the nine operations read the parts by key.

Operation Body DynamoDB
the nine item operations {} EQ
PutItem TableName only, Item only, a TableName that is a number, an Item that is a string, null or {"pk": "x"}, or "ReturnValues": 5 added EQ
GetItem, DeleteItem, UpdateItem TableName only or Key only EQ
BatchGetItem a table entry with no Keys EQ
PutItem a TableName of one character, an empty Item, or a member that PutItem does not have MISS for Credential, Signature and SignedHeaders
Query TableName only MISS for Credential, Signature and SignedHeaders

Fixes #1264

Testing done

  • At 07ea221, cargo test -p extenddb-auth: 542 unit tests, 14 differential tests and 3 doc tests passed.
  • cargo +1.97.0 clippy -p extenddb-auth --all-targets -- -D warnings, cargo +1.97.0 fmt --all -- --check and cargo +1.94.0 check -p extenddb-auth --all-targets are clean. The cargo commands ran with --locked.
  • cargo test -p extenddb-wasm-adapter passed its 3 unit tests and the parity corpus. The clippy step of the WebAssembly job is clean, and cargo fuzz build builds sigv4_authorization and sigv4_verify.
  • The unit test part_without_equal_sign checks the six rows of the first table with DynamoDB's hashes, two control rows, and nine item operation rows. the_item_operations_read_the_parts_by_position sends PutItem and ListTables requests through authenticate, with bodies that DynamoDB reads as valid.
  • Against ExtendDB on SQLite at 07ea221, tests/test_auth_error_fidelity.py passed 39 tests. Its parametrized test test_authorization_part_without_equal_sign sends five DescribeTable rows of the first table, eight PutItem rows and two control rows.
  • At 798d9ee, with the read by position turned off, 3 unit tests and 3 wire tests fail. With the last part of the value in place of the last of the three parts, part_without_equal_sign fails.
  • At 2e51215, parse_authorization had one caller, which serves POST /. Requests to the data plane, management, console, metrics and health routes went to that head and to main. Of 15 requests, only the two rows with no = got other answers.

Line counts: production +75 -12 (Cargo.lock, crates/auth/Cargo.toml, lib.rs, parse.rs), tests +244 -7, fuzz targets +4 -2, docs +1.

#1009 merged first. Cargo.lock is main's file with this branch's base64 dependency of extenddb-auth, because #1009 replaced the axum dependency of that crate with http. dc6d767 merges main at c8e66fb with no conflict.

Not in this PR: other malformed headers, which DynamoDB answers with other texts or another exception (#1270). #1295 also refuses CRED, SH, SIG, = with a valid signature on the operations that read the parts by key. The check of the body that DynamoDB makes before it reads the parts by position is not in this PR either (#1552).

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

Breaking changes

A request with a part of the Authorization header that has no = gets DynamoDB's IncompleteSignatureException text, where ExtendDB sent the text of a later check. On the item operations, a request with a valid signature and a part after it gets InvalidSignatureException, where ExtendDB authenticated it. The status stays 400 for the refused requests.


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 skipped a part of the Authorization header that holds no '='.
It then answered with the next check's text, such as "Authorization
header requires 'Credential' parameter".

DynamoDB answers IncompleteSignatureException with this text:

    Invalid key=value pair (missing equal-sign) in Authorization header
    (hashed with SHA-256 and encoded with Base64): '<hash>'.

<hash> is the Base64 of the SHA-256 of the whole header value.
Measured in us-east-1 on 20 Nov 2026, DynamoDB gives this answer
wherever the part sits, and before it names a missing parameter. An
empty part, such as the one after a trailing comma, does not get it.

The auth crate now uses the workspace's base64 crate to encode the hash.
Other crates already depend on it, so the lock file gains no new package.

Fixes #1264.
#1009 replaced the `axum` dependency of `extenddb-auth` with `http`. The
merge takes main's `Cargo.lock` and keeps this branch's `base64`
dependency of `extenddb-auth`.
@demohan demohan self-assigned this Nov 29, 2026

@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 missing-equal-sign rule matches the service for the table operations at 2e51215, but not for the item operations. With 207 header shapes signed by hand, sent twice to us-east-1 and to this head and main on SQLite and PostgreSQL: on DescribeTable, ListTables, CreateTable, DeleteTable, UpdateTable, BatchWriteItem and ExecuteStatement, this head answers the missing-equal-sign text in every position the service does, ahead of the credential format, a missing or stale date, the region, an unknown key and a wrong signature, with the service's hash, spaces and tabs included, while the checks before authentication still run first and empty parts and repeated commas still authenticate. No shape authenticates here that main refused, and of the 58 headers main accepted that the service refuses, this head refuses 57. The new wire test fails 5 rows on main, every unit and wire mutation fails as it should, fmt, clippy (both configurations and wasm) and the 1.91.1 check are clean, CI is green on 65 of 65, and the branch merges with main at 222d80a, where it builds, passes the 1.94.0 check and the auth tests, and answers all 207 shapes as this head does.

On PutItem, GetItem, DeleteItem, UpdateItem, Query, Scan, BatchGetItem, TransactGetItems and TransactWriteItems, the service gives this text only in some positions (below), and the tests send DescribeTable alone. Separately, and on main too, CRED, SH, SIG, = with a valid signature authenticates, where the service refuses it with Invalid key=value pair (missing key); #1270 could take it.

I will approve once the item operations answer as the service does, with rows for them in the tests.

Comment thread crates/auth/src/sigv4/parse.rs Outdated
signed_headers = Some(val);
} else if let Some(val) = part.strip_prefix("Signature=") {
signature = Some(val);
} else if !part.is_empty() && !part.contains('=') {

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.

On the nine item operations, CRED, SH, <wrong Signature>, garbage gets InvalidSignatureException from the service and from main, and IncompleteSignatureException with this text here, on all nine, twice, on both backends. The service also answers otherwise than this text for garbage, CRED, SH, SIG, CRED, garbage, SH, SIG, CRED, garbage, SIG, CRED, SH, garbage, SIG, CRED, Credential, SH, SIG (the requires-parameter texts or the missing-date text) and CRED, SH, SIG, garbage with a valid signature (InvalidSignatureException), and the same without X-Amz-Date. Main authenticated six of those, so refusing them is right; only the class and text differ. The handler knows the operation before authenticate, so the answer could follow it, and the comment's "wherever it sits" would then name the table operations. PutItem rows in the unit and wire tests would hold it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

798d9ee reads the parts by position on PutItem, GetItem, DeleteItem, UpdateItem, Query, Scan, BatchGetItem, TransactGetItems and TransactWriteItems. authenticate takes the operation from X-Amz-Target (crates/auth/src/lib.rs), and the other operations read the parts by key as before.

On the nine operations the first part is Credential, the second is SignedHeaders, and the rest of the value is Signature. So CRED, SH, <wrong Signature>, garbage now gets InvalidSignatureException. The missing-equal-sign text answers only when a parameter is missing and the last of the three parts has no =. Otherwise the parse names the missing parameter.

I measured this in us-east-1 on 2 and 3 Dec, each request twice. garbage, CRED, SH, SIG went to all nine operations. CRED, garbage, SH, other, CRED, SH, garbage, garbage, CRED, other and CRED, SH, SIG, garbage with a valid signature went to PutItem. The comment at parse.rs:95 names the other operations for "wherever it sits".

PutItem rows are in part_without_equal_sign, the_item_operations_read_the_parts_by_position and the wire test test_authorization_part_without_equal_sign. Without the read by position, 3 unit tests and 3 wire tests fail. The missing date sentence for the same shapes without X-Amz-Date comes with #1295.

DynamoDB reads the Authorization header of PutItem, GetItem, DeleteItem,
UpdateItem, Query, Scan, BatchGetItem, TransactGetItems and
TransactWriteItems by position. The first part is Credential, the second
part is SignedHeaders, and the rest of the value is Signature. On these
operations, DynamoDB checks only the last of the three parts for a
missing '='. It does so only when a parameter is missing.

Before this change, such a part got that text on every operation. A
valid request with a part after the signature authenticated on these
operations.

Measured in us-east-1 on 2 and 3 Dec 2026, each request twice. On the
nine operations, `garbage, CRED, SH, SIG` names the missing parameters.
On PutItem, `CRED, garbage, SH, other` names them too. With a valid
signature, `CRED, SH, SIG, garbage` gets InvalidSignatureException.
BatchWriteItem and DescribeTable read the parts by key, as before.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@demohan

  1. The item operations: 798d9ee reads their parts by position, with PutItem rows in the unit and wire tests. The reply in the thread on parse.rs gives the measurements.
  2. CRED, SH, SIG, = with a valid signature: on DescribeTable and the other operations that read the parts by key, fix(auth): name every missing Authorization parameter as DynamoDB does #1295 (for Other malformed Authorization headers get other IncompleteSignatureException texts than DynamoDB's #1270) refuses it with Invalid key=value pair (missing key). On the item operations, the = is part of the signature, which then does not match. DynamoDB answered InvalidSignatureException on PutItem on 2 Dec, twice.
  3. 01f6767 merges main at 01556cf with no conflict. The head 798d9ee also merges with main at b3510a9 with no conflict.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed at 798d9ee. 1 finding: 1 Important.

The change makes the parse of the Authorization header answer DynamoDB's missing-equal-sign text, reading the parts by position on nine item operations and by key elsewhere. Confirmed: against the live service, the nine item operations plus DescribeTable, ListTables, BatchWriteItem and ExecuteStatement answer as the head's table does for a valid body (positional on the nine, by key on BatchWriteItem and the rest); the 15 test_authorization_part_without_equal_sign wire cases pass on SQLite; reverting by_position to false, replacing splitn(3) with split, and removing the by-key branch each fail the parse tests; the head merged with the current main tip builds and passes the auth crate tests (542 lib, 14 differential, 3 doc).

  • Important crates/auth/src/lib.rs:147 — by_position is chosen from X-Amz-Target alone, but the service reads the parts by position only when the body is a valid request for that operation; with an invalid body it answers the missing-equal-sign text, as ExtendDB no longer does.

Comment thread crates/auth/src/lib.rs Outdated

// Parse Authorization header
let parsed = sigv4::parse::parse_authorization(auth_header)?;
// Parse Authorization header. Measured 2026-12-02: DynamoDB reads the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important
authenticate sets by_position from the operation name alone (lib.rs:147-166). On the service the positional read also depends on the body: with a body that lacks a required member the item operations answer by key, so the missing-equal-sign text wins, as it does for DescribeTable.

What the caller sees: for Authorization: AWS4-HMAC-SHA256 garbage, CRED, SH, SIG the service answers Invalid key=value pair (missing equal-sign)... when the PutItem body is {} or {"TableName":"x"}, and Authorization header requires 'Credential' parameter when it is {"TableName":"x","Item":{...}}. The head answers the second text in all three cases (the committed the_item_operations_read_the_parts_by_position sends b"{}" and asserts it, tests.rs:327-349). Before this PR the head's answer for the empty body was also not the service's, so this is a remaining delta, not a regression.

Fix: either decide by_position only after the body has the operation's required members (the body is already passed to authenticate), or list the delta in docs/differences-from-dynamodb.md and narrow the wording in the PR body and the comment at lib.rs:147 ("by position on these operations"). The rows at tests.rs:327-349 and the PutItem rows at test_auth_error_fidelity.py:477-500 use bodies that decide this and would need both a valid and an empty-body row. Sibling #1295 edits the same authenticate and parse.rs hunks, so the change needs a rebase onto whichever lands second.

Evidence: live DynamoDB us-east-1, same header garbage, CRED, SH, SIG, same request otherwise: PutItem {} → Invalid key=value pair (missing equal-sign); PutItem {"TableName":"x"} → same; PutItem with TableName and Item → Authorization header requires 'Credential' parameter; GetItem, Scan, BatchGetItem {} → missing-equal-sign, with a valid body → requires 'Credential'; DescribeTable with either body → missing-equal-sign.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This reproduces. I sent your shapes and others to us-east-1 on 3 Dec, each request twice. On the nine operations, DynamoDB reads the parts by position only when the body passes a check against the input shape of the operation. Each member must have its type, and the required members must be present and not null, nested ones too. {} gets the missing-equal-sign text on all nine. So do a PutItem with "ReturnValues": 5, an Item value of {"pk": "x"}, and a BatchGetItem table entry with no Keys. A one-character TableName, an empty Item or a member PutItem does not have still read by position, and Query needs only TableName.

That check needs the input shapes of the nine operations in the auth crate, so by_position stays a choice by operation. ExtendDB checks the members only after authentication, and those checks also refuse values that pass the type check. 07ea221 lists the difference in docs/differences-from-dynamodb.md and narrows the comment at lib.rs:147. It also makes the_item_operations_read_the_parts_by_position send a PutItem body that DynamoDB reads by position. The PutItem rows of test_auth_error_fidelity.py already send TableName and Item. #1552 has the measurements and tracks the body check.

The stack merges instead of a rebase: 17b7835 merges 07ea221 into the branch of #1295.

DynamoDB reads the Authorization parts of the nine item operations by
position only when the body is a valid request (measured on 2026-12-03).
With another body, such as `{}` on each of the nine, it reads the parts by
key and answers the missing-equal-sign text. Its check covers each member
and its type, nested members too. This commit keeps the choice by
operation, lists the difference in docs/differences-from-dynamodb.md and
narrows the comments.

The unit test the_item_operations_read_the_parts_by_position now sends a
PutItem body that DynamoDB reads by position, in place of `{}`.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@LJMart11

  1. Important, crates/auth/src/lib.rs:147: the reply in its thread gives the measurements of 3 Dec. 07ea221 keeps the choice by operation, lists the difference in docs/differences-from-dynamodb.md and narrows the comments. The item operations read the Authorization parts by position whatever the body holds, where DynamoDB does so only for a valid request #1552 tracks the body check.

dc6d767 merges main at c8e66fb with no conflict.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checked at 07ea221 against the list from 798d9ee.

The follow-up lists the body-dependent positional read of the nine item operations in docs/differences-from-dynamodb.md and changes the_item_operations_read_the_parts_by_position to send a valid PutItem body. Confirmed: the live service answers the missing-equal-sign text for PutItem bodies {} and {"TableName":"x"} and the requires 'Credential' text for a valid body, which is what the new doc row says; the updated test passes, and forcing by_position to false or to true each fails it at tests.rs:351; the auth crate tests pass (542 lib); the head already contains the current base tip (c8e66fb), so there is no base movement to merge.

Previous items: 1 fixed.

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.

An Authorization header with no equal sign gets another IncompleteSignatureException text than DynamoDB's

3 participants