Skip to content

fix(s3): require x-amz-* request headers to be signed - #14799

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/s3-signed-amz-headers
Oct 22, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/s3-signed-amz-headers

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Reject S3 requests that include an x-amz-* header omitted from SignedHeaders, for both Authorization-header and presigned-URL authentication.

Previously, the verifier checked only the headers listed by the signer. A caller could append an unsigned x-amz-copy-source to an otherwise valid PUT request and have the gateway treat it as CopyObject. The same gap applied to other operation headers, including x-amz-copy-source-range and x-amz-metadata-directive.

The gateway now rejects these requests with HTTP 403 and S3 AccessDenied before the object operation runs.

Changes

  • Check every incoming x-amz-* header against the normalized signed-header list in SignatureV4::verify().
  • Preserve the x-amz-content-sha256 exemption: header-authenticated requests bind its value through the canonical request's payload line; presigned requests use UNSIGNED-PAYLOAD and ignore this header for verification.
  • Update the S3 E2E helper to sign the x-amz-* headers it sends, with an explicit option for sending unsigned headers in negative tests.

This follows the S3 signing requirements. Clients sending unsigned x-amz-* headers, other than the exemption above, must include them in SignedHeaders.

Validation

  • Unit: unsigned x-amz-copy-source is rejected for both authentication methods; signed copy headers are accepted; a presigned request with unsigned x-amz-content-sha256 remains valid.
  • E2E: an unsigned CopyObject request returns 403 AccessDenied and leaves the destination absent. Signing the same header succeeds, and the copied bytes match the source.
  • Local focused unit run: 17 tests, 28 assertions passed using the PR's verifier and tests with installed dependencies.
  • CI passed, including the unit and dedicated S3 Storage E2E suites.

Related: appwrite-labs/cloud#6674

SigV4 requires every x-amz-* header on a request to be covered by the
signature. The gateway acted on copy and metadata-directive headers even
when they were outside SignedHeaders, so a request signed for one
operation could be extended into another. Reject such requests with
AccessDenied, matching S3. x-amz-content-sha256 stays exempt because the
canonical request's payload line already binds it.

Co-Authored-By: Claude <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This change closes an unsigned-header smuggling gap in the S3 gateway's AWS Signature V4 verification: requests carrying x-amz-* headers not listed in SignedHeaders (such as x-amz-copy-source) are now rejected with 403, with x-amz-content-sha256 intentionally exempt since it is bound into the canonical request via the payload hash line. New unit tests cover the exemption and rejection paths, and the e2e S3 suite gained a test proving an unsigned x-amz-copy-source fails while a signed one succeeds.

Files Change
src/Appwrite/Platform/Modules/S3/Auth/SignatureV4.php Adds verifySignedAmzHeaders() enforcement before signature verification, with case-insensitive header normalization.
tests/unit/Platform/Modules/S3/Auth/SignatureV4Test.php Adds unit tests for unsigned-header rejection and the x-amz-content-sha256 exemption.
tests/e2e/Services/Storage/S3CustomServerTest.php Extends the signing helper to include supplied x-amz-* headers and adds a CopyObject smuggling regression test.

Reviewed commit: 15c1c6d

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The new check is applied to both authentication modes, preserves the documented payload-hash exception, and has focused unit and E2E coverage.

The S3 SigV4 verifier now rejects requests containing unsigned x-amz-* headers, while retaining the x-amz-content-sha256 exemption. The unit and E2E coverage exercises unsigned-header rejection and valid signed requests, and the E2E helper now signs the S3 headers it sends.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
src/Appwrite/Platform/Modules/S3/Auth/SignatureV4.php Checks request headers against SignedHeaders before verifying both header-signed and presigned requests.
tests/e2e/Services/Storage/S3CustomServerTest.php Adds a CopyObject signed-header regression test and updates the request helper to sign x-amz headers.
tests/unit/Platform/Modules/S3/Auth/SignatureV4Test.php Adds verifier tests for signed and unsigned x-amz headers, including presigned requests.

Reviewed 15c1c6d · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost 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.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/s3-signed-amz-headers (after).

Metric Before After Change
🚀 Requests/sec 200.5 190.26 🔴 -5.1%
⏱️ Latency P50 86.2 ms 90.41 ms ⚪ +4.9%
⏱️ Latency P95 197.17 ms 212.03 ms 🔴 +7.5%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 90.41 212.03 12,027 190.26 +14.86
Account 171.28 312.91 633 10.48 +37.76
TablesDB 87.7 168.39 6,541 106.52 -1.71
Storage 81.87 188.59 3,165 53.12 +7.26
Functions 125.85 243.43 1,688 28.95 +28.76

Top API waits (after)

API request Max wait (ms)
account.name.update 480.58
account.prefs.update 430.36
functions.variables.update 381.24
functions.delete 372.7
tablesdb.rows.get 368.07

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k
ChiragAgg5k merged commit 151a7e9 into main Oct 22, 2026
53 of 54 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/s3-signed-amz-headers branch October 22, 2026 16:37
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…ders

fix(s3): require x-amz-* request headers to be signed

(cherry picked from commit 151a7e9)
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.

1 participant