Repository navigation
fix(storage): check the content of uploads with an allowed signed extension - #15546
Conversation
…ension A sniffed type in the ambiguous list skipped the content check, so an upload named with an allowed signed extension (png, pdf, ...) was accepted whatever its content. Signed extensions are images and PDFs, never containers, so the exemption is not needed there.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change closes a content-type bypass in the Storage
One residual gap was identified: the S3-compatible gateway ( Reviewed commit: ec52b68 |
🟢 Tier S · Ready to mergeThe upload content check now rejects signed image and PDF extensions when the detected MIME type is outside the bucket’s allowed signatures, including ambiguous octet-stream content. The same rule is applied to both Storage API uploads and S3 gateway writes, with regression coverage for random bytes named as PNG files. Latest changes: The latest commits remove the ambiguous-MIME exemption from S3 content validation and add an S3 regression case for random bytes uploaded as
📂 Walkthrough · 4
Reviewed the commits since |
There was a problem hiding this comment.
This PR tightens the Storage file-upload validation so files with signed extensions must sniff to an allowed MIME type, closing an ambiguous-content-type bypass covered by a new e2e test.
Key findings
- 🟡 S3 gateway still allows ambiguous-MIME bypass REST upload removed — Create.php:507
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
The S3 gateway kept the ambiguous-type exemption that the REST upload dropped, so random bytes named .png still passed there.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Follow-up to #15458. The content check skipped any upload whose sniffed type is in
formats.ambiguous, so withallowedFileExtensionsset, content that sniffs asapplication/octet-streamwas accepted under an allowed.pngor.pdfname. Every signed extension is an image or PDF, never a container, so the ambiguous exemption is dropped from that check; the later remap for container extensions is unchanged.Extends
testCreateFileRejectsDisallowedContentwith random bytes uploaded asbinary.png(400storage_file_type_unsupported).Related: appwrite-labs/cloud#6666