Public: anyone can read this; the crew can change it.
A dropped file is always served as a download with nosniff, whatever its name or bytes #13413
Check · Review · Land · Live done — Landed and live in production.
A drop download is now always application/octet-stream with Content-Disposition: attachment and X-Content-Type-Options: nosniff, whatever the file's name or bytes. Before this, a .png, .jpg, .gif or .webp name was served with its image type, and the filename was built inline in the route.
shipped production is serving it deploy 59903fa
A drop download is now always application/octet-stream with Content-Disposition: attachment and X-Content-Type-Options: nosniff, whatever the file's name or bytes. Before this, a .png, .jpg, .gif or .webp name was served with its image type, and the filename was built inline in the route. Now those headers come from one function, downloadHeaders(name) in src/drop/store.ts.
What moved where
src/drop/store.ts: the newdownloadHeaders(name)cleans the name again before it goes in the header. Every character outside the drop's allowed set (letters, digits, space,. _ + ( ) -) becomes_, so no quote, CR/LF or non-ASCII byte gets through. The cleaned name is also sent percent-encoded infilename*=UTF-8''…, with(and)encoded too. An empty name becomesfile.src/http/api/drop.ts: the download route usesdownloadHeaders; its inline headers are gone.src/actions/drop.ts:dropFilenow returns only{ path }. The listing still reports each image's type, so the page knows to draw a thumbnail.test/drop-serve.test.ts(new):
- uploads page.html, logo.svg, a GIF/HTML polyglot and HTML bytes named trick.png, and checks that each comes back as an octet-stream attachment with nosniff and unchanged bytes;
- checks that names with a quote or a newline are refused at upload (422);
- checks that a page-cleaned name containing a Set-Cookie attempt downloads with the right filename and filename* and no Set-Cookie header;
- checks the header encoding directly on a name with a quote, CR/LF, é and an RTL override character.
What to look at: the thumbnails on the Drop page still point at this route. They now get octet-stream with nosniff and depend on the browser recognising the image from its bytes, which Chrome and Firefox do for <img>. I didn't check this in a browser. If a reviewer wants it to be certain, a separate thumbnail route that sends real image types only after checking the file's first bytes would be the follow-up; I didn't add it because the issue asks for octet-stream on every download.
Not changed: quota and upload limits, the name rules, and server.ts. Upload was already refusing quotes and newlines, so that part of the issue needed no change.
Checks: drop-serve, drop and drop-doors pass (20 tests), tsc --noEmit is clean, and scripts/gate.ts --fix rewrapped one comment, which is in the commit. scripts/fast.ts named 2,463 test files, far over its budget, so I ran only those three and the forge's check runs the full suite. I didn't run design-lint because nothing under src/web/ changed. The pre-push hook asked for a Try: line, so I added one to the commit message. The keep_plan and estimate tools weren't available to me, so this issue has no plan or estimate recorded.
Note: a hold on the desk says production is rolling. This is an ordinary pull and lands only when someone merges it.
To try it: drop an .html or .svg file on /<owner>/<app>/drop and open its link: it downloads and never renders. Or run curl -sI -H "authorization: Bearer $TOKEN" …/api/v1/repos/<owner>/<app>/drop/page.html.
🤖 Generated with Claude Code
Every drop download now goes through downloadHeaders(): octet-stream, attachment, nosniff. The name is narrowed again for the header and also sent percent-encoded as filename*. The new test covers html, svg, a polyglot, a mislabelled png, quote/newline names and the header encoding. No README change, no new dependency. Not checked: I did not load the Drop page thumbnails in a browser. They rely on the browser's image decoder with octet-stream and nosniff, which works for png, jpg, gif and webp in img. If thumbnails ever break, a separate thumbnail route that checks magic bytes is the follow-up, as mason notes.
A drop download is now always
application/octet-streamwithContent-Disposition: attachmentandX-Content-Type-Options: nosniff, whatever the file's name or bytes. Before this, a.png,.jpg,.gifor.webpname was served with its image type, and the filename was built inline in the route. Now those headers come from one function,downloadHeaders(name)insrc/drop/store.ts.What moved where
src/drop/store.ts: the newdownloadHeaders(name)cleans the name again before it goes in the header. Every character outside the drop's allowed set (letters, digits, space,. _ + ( ) -) becomes_, so no quote, CR/LF or non-ASCII byte gets through. The cleaned name is also sent percent-encoded infilename*=UTF-8''…, with(and)encoded too. An empty name becomesfile.src/http/api/drop.ts: the download route usesdownloadHeaders; its inline headers are gone.src/actions/drop.ts:dropFilenow returns only{ path }. The listing still reports each image's type, so the page knows to draw a thumbnail.test/drop-serve.test.ts(new):- uploads
page.html,logo.svg, a GIF/HTML polyglot and HTML bytes namedtrick.png, and checks that each comes back as an octet-stream attachment with nosniff and unchanged bytes; - checks that names with a quote or a newline are refused at upload (422); - checks that a page-cleaned name containing aSet-Cookieattempt downloads with the rightfilenameandfilename*and noSet-Cookieheader; - checks the header encoding directly on a name with a quote, CR/LF,éand an RTL override character.What to look at: the thumbnails on the Drop page still point at this route. They now get octet-stream with nosniff and depend on the browser recognising the image from its bytes, which Chrome and Firefox do for
<img>. I didn't check this in a browser. If a reviewer wants it to be certain, a separate thumbnail route that sends real image types only after checking the file's first bytes would be the follow-up; I didn't add it because the issue asks for octet-stream on every download.Not changed: quota and upload limits, the name rules, and
server.ts. Upload was already refusing quotes and newlines, so that part of the issue needed no change.Checks:
drop-serve,dropanddrop-doorspass (20 tests),tsc --noEmitis clean, andscripts/gate.ts --fixrewrapped one comment, which is in the commit.scripts/fast.tsnamed 2,463 test files, far over its budget, so I ran only those three and the forge's check runs the full suite. I didn't rundesign-lintbecause nothing undersrc/web/changed. The pre-push hook asked for aTry:line, so I added one to the commit message. Thekeep_planandestimatetools weren't available to me, so this issue has no plan or estimate recorded.Note: a hold on the desk says production is rolling. This is an ordinary pull and lands only when someone merges it.
To try it: drop an
.htmlor.svgfile on/<owner>/<app>/dropand open its link: it downloads and never renders. Or runcurl -sI -H "authorization: Bearer $TOKEN" …/api/v1/repos/<owner>/<app>/drop/page.html.🤖 Generated with Claude Code
Closes #13392