Repository navigation
fix(file_send): deliver every binary type to the owner as a download - #34159
LucaButBoring wants to merge 2 commits into
Conversation
|
This PR changes |
a895f81 to
146d52e
Compare
146d52e to
5b1cb6f
Compare
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR drops the binary-MIME allowlist gate on the owner's own surfaces (file_send, outbox notify, and the owner's outbox download). Unlisted types go to the owner only as attachment + nosniff, the same pattern /api/file-download already uses for the owner. Non-owner download still gets the 403 type refusal before the content scan. The Slack and channel upload legs are untouched. Compressed files (.pdf.gz) are now served as octet-stream instead of an inline inner type. Tests cover each changed path and the inverted ones were updated. Docs, tool description and error-code baseline match the code. No regression or trust-boundary weakening found. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
5b1cb6f to
244bd49
Compare
244bd49 to
aeaed77
Compare
aeaed77 to
52af3b3
Compare
…r type mimetypes.guess_type reads report.pdf.gz as application/pdf with a gzip encoding, and the download served the gzip bytes inline as a PDF. A guess that carries an encoding now falls back to application/octet-stream, which the owner gets as an attachment and a non-owner gets refused with a 403.
52af3b3 to
4d759bd
Compare
Problem / Motivation
Goal:
file_senddelivers a zip, a tarball, an Office document or any other binary file to the owner's dashboard as a download.file_sendrefuses every binary (non-UTF-8) file whose MIME type is not inBINARY_MIME_ALLOWLIST, a list of audio, video, image and PDF types. The outbox routes repeat the check:POST /api/outbox/notifyanswers 400 andGET /api/outbox/{filename}answers 403. An agent that packages its output asexport.zipgetsError: binary file type not allowed: application/zip, and the tool description tells it to give the user a path instead.Why it matters
Agents often produce archives, tarballs and Office documents, and the dashboard delivers none of them to the owner today. The owner has to copy the file off the host by its path, which needs shell or file access to that host.
The refusal on these surfaces does not address the risk that the allowlist exists for. The allowlist's comment says the listed types are safe to render on the dashboard origin and that SVG is left out because it can carry scripts, so the risk it covers is inline rendering. A browser does not render a response served as
Content-Disposition: attachmentwithX-Content-Type-Options: nosniff, andGET /api/file-downloadalready serves every binary type to the owner with those headers.Not a goal
_gate_upload_filerefuses types outside the allowlist and runs the binary credential scan.!dashboard. That caller still gets only allow-listed binary types, after the credential scan.What changed (motivation → approach → change)
With this PR, the allowlist selects the binary types that the dashboard serves inline, and it no longer controls the owner's access to a binary file.
file_sendPOST /api/outbox/notifyGET /api/outbox/{filename}, ownerattachment,nosniffGET /api/outbox/{filename}, any other callerThe download serves an unlisted type as an attachment even when the route serves its prefix inline, as for
image/tiff. A compressed file such asreport.pdf.gzholds gzip bytes and goes out asapplication/octet-stream. The owner receives it. Any other caller gets a 403, since the credential scan cannot read compressed bytes. The filename check, the SVG and text attachment rules and the non-owner content scan stay in place. Thefile_senddescription says that the dashboard previews media, opens a PDF and offers other binary formats as a download that Slack and channel uploads refuse. The allowlist's comment indisplay_safety.pyand the Binary File Handling section ofdocs/system-specs/modules/security.mddescribe the allowlist as the inline-render list, anderror-code-baseline.jsondrops the removed notify 400.The initial import added the allowlist, and a later commit extended it to the Slack upload leg. PR #24792 removed the content scan from the owner's surfaces and kept the allowlist on them without a stated reason. The tool description has stated the refusal since PR #17171, which answered #15433, and this PR replaces that text.
Backwards compatibility
Compatible: Every file that main delivers keeps its status,
Content-Typeand disposition, except a compressed file such asreport.pdf.gz. Main served that file under its inner type, inline to the owner and after the scan to any other caller. The PR adds deliveries to the owner for files that main refuses.Removes nothing: The owner-side refusal is the code that the diff deletes, and its readers were the tests that this PR updates.
Tests
test/test_mcp_core_coverage.py:file_sendcopies a zip to the outbox and notifies the dashboard. When the Slack leg refuses the zip, the result reports the refusal and the file stays in the outbox.test/test_outbox_binary.py: Notify posts a card for a zip. The owner downloads a zip and a.tifffile asattachmentwithnosniff, and any other caller still gets a 403 for an.exefile, before the content scan. The owner downloadsreport.pdf.gzas anapplication/octet-streamattachment, and any other caller gets a 403 for it.test/test_file_send_skip_reason.py: The description lists each allowlist category and the download outcome.test/test_dashboard_files_composition_contract.py: The per-file error-code sum drops by the removed notify 400.Proof: PROVEN test/test_dashboard_files_composition_contract.py::test_the_error_code_rows_match_each_owner, test/test_file_send_skip_reason.py::TestToolDescriptionMatchesBehaviour::test_the_description_names_the_types_the_dashboard_renders, test/test_mcp_core_coverage.py::TestFileSend::test_a_zip_is_copied_to_the_outbox_and_notified, test/test_mcp_core_coverage.py::TestFileSend::test_a_zip_the_slack_leg_refuses_stays_in_the_outbox, test/test_outbox_binary.py::TestOutboxNotifyBinary::test_binary_outside_the_allowlist_accepted (head a895f81)
Determinism: The 126 tests in the changed test classes passed in 3 repeated runs and in a run in shuffled order.
Manual verification
N/A: The tests drive the real
file_sendhandler and the real outbox routes through aiohttp's test server. The dashboard file card renders a type other than audio, video or an image as a download link on main, and this PR leaves the card unchanged.Related Issues
Closes #34158
Sibling sweep
Swept:
git grep -n "BINARY_MIME_ALLOWLIST" -- src/Sibling: src/kiro_crew/dashboard/file_api/channel_upload.py -- not affected -- the upload legs still refuse types outside the allowlist, as Not a goal states
Sibling: src/kiro_crew/wecom/transport.py -- not affected -- it mentions the upload gate's allowlist in comments only
Sibling: src/kiro_crew/dashboard/handlers/files.py -- not affected -- it re-exports the constant for the outbox and upload routes
Pattern harvest
Not generalizable: A single constant served both as the inline-render list and as a delivery gate, and the gate role had no stated requirement behind it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)