Repository navigation
fix(s3): send the same content headers as storage view on object GET - #14634
Conversation
Object GET and HEAD now send CSP and nosniff, and force attachment for types the storage view endpoint does not render inline. Query and stored Content-Disposition overrides cannot change that. The S3 init hook applies the same baseline Server, nosniff, and HSTS headers other API routes already send. Co-authored-by: Jake Barnby <[email protected]>
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR hardens the new S3-compatible object GET endpoint so responses always carry safe content headers, and extends the e2e SigV4 helper to sign extra headers plus a test asserting the new behavior.
Reviewed commit: d17f08d |
🟢 Tier S · Ready to merge
The S3 object GET/HEAD responses now apply storage-view security headers and force downloads for SVG and MIME types outside the storage allow-list, while preserving safe-type disposition overrides. The storage view response also emits sanitized, UTF-8-compatible filenames in Content-Disposition.
📂 Walkthrough · 5
Reviewed |
There was a problem hiding this comment.
Adds a Content-Disposition/content-type enforcement layer to the S3 gateway GET path with matching e2e coverage, but the forced attachment filename is interpolated into the header unescaped.
Key findings
- 🟡 Unescaped filename in
Content-Dispositionheader — Get.php:351
Co-authored-by: Jake Barnby <[email protected]>
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Client sessions cannot update a bucket that only allows create, and the S3 gateway looks objects up by the stored name. Use the project key for the rename and assert the sanitized Content-Disposition on the storage view path. Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
A matching If-None-Match still needs Content-Disposition, CSP, and nosniff so a revalidated cached response keeps those values. Co-authored-by: Jake Barnby <[email protected]>
|
@hansi-codes review |
…content-headers-fb91 fix(s3): send the same content headers as storage view on object GET (cherry picked from commit ccaaa08)
What does this PR do?
Object GET and HEAD on the S3-compatible gateway now send the same content headers as
GET /v1/storage/buckets/{bucketId}/files/{fileId}/view:Content-Security-Policy: script-src 'none';X-Content-Type-Options: nosniffContent-Disposition: attachmentfor SVG and for any type outside the storage-mimes allow-list (the same list the view endpoint uses to decide what can be rendered inline)Stored
Content-Dispositionmetadata and theresponse-content-disposition/response-content-typequery overrides cannot switch those types to inline. Safe types (for exampleimage/png) still honorresponse-content-disposition.S3 routes stay in the
s3group so AWS clients keep the existing CORS expose list and SigV4 auth. The S3 init hook applies the same baselineServer,X-Content-Type-Options, and HSTS headers that the api/web/graphql init hook already sets. Range responses (206), ETag, and presigned URLs are unchanged aside from the extra headers.Test Plan
testGetObjectContentHeadersintests/e2e/Services/Storage/S3CustomServerTest.php:response-content-type/response-content-dispositioncannot make those objects inlineContent-Disposition: inlinefrom a COPY REPLACE cannot make SVG inlineresponse-content-disposition=inlineapplication/xhtml+xmlvia query is forced to attachmentRelated PRs and Issues
Checklist