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
Merged 19d 8h ago, 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.
-
Reviews
ApprovedEvery 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.
-
Checks
shipped production is serving it deploy 3eab8eb
-
History
- A dropped file is always served as a download with nosniff, whatever its name or bytes (#13392) ce81650
- Every empty list says what it is waiting for in one sentence, from one table (#13312) 5d854a6
- A run's log never holds a secret: tokens and keys are masked before the log is stored (#13314) c14f943
- A talk reply that proposes an action shows it as a previewed card with Do it and Not now (#13346) cee6610
- A tell from the terminal's home screen carries the screen's context and prints its receipt (#13184) 71ce7cd
- A bet refuses to start when the repository's wallet cannot cover its estimate, in one plain sentence (#13354) 3ae56cb
- The owner can see one repository's spend per day for the last 14 days as a table (#13355) b8946df
- The drop: a private place per app and per forge to dump reference material the migration crew can read (#13245) 2e31bd3
- /status answers under 6 KB and under 50 ms from a cache of at most 10 s (#13352) f021bd2
- A check run as a cluster job holds the same egress wall as one on the box (#13272) fc1f404
- A sync at one door reaches an open fork card without a reload (#13278) e8209b2
- A file nothing can render shows its size, detected type and a download, never raw bytes (#13340) 8594e14
- The owner sees every MCP OAuth grant with its client and last use, and revokes one in one tap (#13338) 97489a2
- A Markdown file's front matter shows as a small table above its body (#13336) 867ab48
- A SQLite file's table view pages by 100 rows with the schema above it and refuses writes (#13356) 290e978
- The 404 page offers the three most likely pages by edit distance to the path asked (#13351) 620d275
- A .log file opens with its error and warning lines marked and a jump to the first error (#13344) 1d0373e
- Full suite red: test/quotas-storage.test.ts (#13369) bc5c621
- Full suite red: 5 files in check run 01m7fp9b55s7vez7ewm14hg5r1 (#13359) b1c6dc4
- A template's page says what a new forge gets: its apps, their crew roles and its budget, in plain words (#13325) 7104538
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 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 a
Set-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.
- uploads
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
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):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;Set-Cookieattempt downloads with the rightfilenameandfilename*and noSet-Cookieheader;é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