Skip to content

fix(s3): HeadObject 403 when proxies rewrite HEAD to GET - #13744

Merged
TorstenDittmann merged 3 commits into
mainfrom
torsten/fix-s3-head-object-80a2
Sep 18, 2026
Merged

TorstenDittmann merged 3 commits into
mainfrom
torsten/fix-s3-head-object-80a2

Conversation

@TorstenDittmann

@TorstenDittmann TorstenDittmann commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

HeadObject was documented as supported, but boto3 and the AWS CLI get a generic 403 Forbidden. Cloud (Fastly) can rewrite the SDK's HEAD into a GET while forwarding the HEAD SigV4 signature and x-id=HeadObject. Verification used the request method as-is, so the canonical request no longer matched (AccessDenied).

If a GET signature does not match, retry as HEAD only when x-id is HeadObject or HeadBucket. Those operations are then handled as HEAD so a presigned HEAD URL cannot be replayed as GetObject.

Test Plan

  • testVerifiesHeadObjectSignatureAfterProxyRewritesToGet — HEAD signature on a GET with x-id=HeadObject
  • testRejectsHeadSignatureReplayedAsGetObject — HEAD signature on a GET without x-id is rejected
vendor/bin/phpunit tests/unit/Platform/Modules/S3/Auth/SignatureV4Test.php --filter=HeadObject

Related PRs and Issues

  • HeadObject 403 with boto3 / AWS CLI against the S3-compatible API

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web Open in Cursor 

Proxies in front of Cloud may convert HeadObject to GET while forwarding
the HEAD signature and x-id. Verify GET/HEAD interchangeably, treat
x-id=HeadObject|HeadBucket as HEAD, and keep the empty body.

Co-authored-by: Torsten Dittmann <[email protected]>
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → torsten/fix-s3-head-object-80a2 (after).

Metric Before After Change
🚀 Requests/sec 274.78 285.41 ⚪ +3.9%
⏱️ Latency P50 63.87 ms 61.39 ms ⚪ -3.9%
⏱️ Latency P95 148.9 ms 141.04 ms 🟢 -5.3%
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 61.39 141.04 17,613 285.41 -7.85
Account 113.17 227.29 927 15.39 -8.19
TablesDB 59.7 110.22 9,579 157.19 -6.48
Storage 55.6 129.96 4,635 78.03 -5.58
Functions 86.76 166.11 2,472 42.24 -12.68

Top API waits (after)

API request Max wait (ms)
functions.variables.create 459.88
account.name.update 408.98
functions.delete 343.94
tablesdb.rows.decrement 342.48
account.get 316.7

… GET

Cloud may rewrite HeadObject to GET while forwarding the HEAD signature.
Keep the change to signature verification only.

Co-authored-by: Torsten Dittmann <[email protected]>
@TorstenDittmann
TorstenDittmann marked this pull request as ready for review September 17, 2026 15:08
@greptile-apps

greptile-apps Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the previous HEAD-signature replay vulnerability is now constrained by the signed operation identifier and HEAD-style response routing.

Fix All in Claude CodeFindings

  1. P1 Security HEAD signatures authorize GETs ▶
Fix with agent prompt
### Issue 1
src/Appwrite/Platform/Modules/S3/Auth/SignatureV4.php:101-103
This fallback accepts a HEAD-bound signature for every incoming GET, not only requests known to have been rewritten by Fastly. A recipient of a presigned HEAD URL can replay it as GET: verification succeeds against the HEAD canonical request, but routing follows the actual GET method and returns the object's bytes. This turns metadata-only delegated access into content access. Restrict the fallback to requests authenticated as trusted proxy rewrites rather than weakening method binding for all GETs.

**How this was verified:** The verifier retries every GET with a HEAD canonical method, while the object route uses the incoming GET method to send the full object body.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR restores S3 HeadObject and HeadBucket compatibility when a proxy rewrites HEAD requests to GET while preserving the original SigV4 signature.

  • Limits GET-to-HEAD signature fallback to requests labeled HeadObject or HeadBucket.
  • Routes those rewritten requests through HEAD-style response handling so object bytes are not returned.
  • Adds unit coverage for the proxy-rewrite case and rejection of an unlabeled HEAD-signature replay.

Reviews (2) · Last reviewed commit: "fix(s3): only accept rewritten HeadObjec..."

Limit the HEAD fallback to SDK HeadObject/HeadBucket requests (x-id) so a
presigned HEAD URL cannot be replayed as GetObject. Treat those operations
as HEAD so the object body is not returned.

Co-authored-by: Torsten Dittmann <[email protected]>
@TorstenDittmann
TorstenDittmann merged commit a6943e0 into main Sep 18, 2026
49 checks passed
@TorstenDittmann
TorstenDittmann deleted the torsten/fix-s3-head-object-80a2 branch September 18, 2026 09:39
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