Repository navigation
fix(dashboard): file-download honours the owner's file-delivery grant - #17899
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check the Settings → Security → Flagged-file delivery page tells the user the grant covers every flagged file, not just this one. The blind reader could not tell which. [UX-REVIEWED] 6886138 Description read[DESCRIPTION-READ] 655290bb0b4483bb93f8f49ecd98d236c5b33945a9a9127e61699e8ddaa70761 That sha256 names everything this verdict read: the PR description, plus the 4 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the [DESIGN-REVIEWED] 6886138 Description read[DESCRIPTION-READ] d4dc2c7a82e609c0353582f242b0ce8c334d76c9ed7671fc482a263bcdb36d44 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify before merge: without a grant, a file holding a UTF-16/UTF-32 credential used to download from this route and is now refused. What this change shipsInventory (6 items) — 6 justifiedIntent: let the dashboard owner download their own file when the credential scan flags it, by turning on the existing flagged-file delivery setting. This is a FIX (#17404).
[FIRST-PRINCIPLES-REVIEWED] 6886138 Description read[DESCRIPTION-READ] 3ddd90fa16b0a8f40d8ad39e242b713f88d10d9da5827c1ff73ef9b204698be1 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
af47c16 to
40eef6a
Compare
|
Dispositions for the review on GPT 6.1 (blocking) — fixed. UX Review (BLOCK, missing screenshot) — fixed. The description now carries a screenshot of the file viewer's Download refusal from the built SPA, showing the new copy that names Settings → Security → Flagged-file delivery. Watch items: a direct link from the error to the setting is listed under "Not a goal" (a follow-up, not needed for the fix); the screenshot shows the full English string fits in the panel's notice. Design Review (CONCERNS).
First Principles (CONCERNS) — kept, by maintainer decision. The wide pass was asked for explicitly in this item's scope ("add the wide pass the outbox route runs if it fits cleanly"). It fits as one short-circuited branch on the same grant gate. The reason it belongs with the fix: once this route honours the shared grant, it should agree with the peer gates on what "flagged" means, or the one grant releases on two different definitions. The behaviour change is stated in the description. Frontend Tests (fr spacing) — fixed. U+202F before the colon in the French copy. Backend Tests (Windows) shards 2/6/8 failed in |
40eef6a to
7cd9356
Compare
|
Dispositions for UX Review (CONCERNS) — no change in this PR.
CI reds on this head, none in this diff:
|
GET /api/file-download refused every flagged file with no owner
override, so a self-contained HTML page with inline base64 images
could not be downloaded. The route now applies the owner_dashboard
grant plus owner identity, through one helper shared with
GET /api/outbox/{filename}, and runs the same wide pass.
The redaction heuristics are unchanged. The blocked copy points at
Settings -> Security -> Flagged-file delivery.
Fixes #17404
7cd9356 to
6886138
Compare
|
Self-review (crew-pr-reviewer, read-only): HOLD for a maintainer / security owner Reviewed head |

Problem / Motivation
Goal: The dashboard owner can download their own file when the credential scan flags it, by turning on the existing flagged-file delivery setting.
A self-contained HTML page with inline
data:image/png;base64,…images cannot be downloaded from the dashboard.GET /api/file-downloadruns the credential scan; the bare-secret pass finds a key-shaped 40-char window inside the base64 run and the route returns 400content_redacted. UnlikeGET /api/outbox/{filename}, this route has no owner override at all, and the error tells the user to "remove the secret", which is not possible for an image.Why it matters
Any owner who saves or generates a self-contained HTML report, or any file whose base64 content happens to look key-shaped, hits a dead end: the file is theirs, the route is already owner-only, and nothing they can do in the product releases it.
Not a goal
redaction.py). The length cap and thedata:carve-out proposed in the issue both reopen a bypass: a real key glued to adjacent base64 chars, or padded inside adata:URI, is caught only because the window slides across the whole run.redaction_switchto downloads.test_credential_redaction_switch.pypins that admission gates do not use the owner view; that pin is untouched.What changed (motivation → approach → change)
Symptom: owner's own flagged file is refused with no way out. Root cause:
api_file_downloadnever consults theowner_dashboardfile-delivery grant, althoughfile_delivery_consent.CLASS_OWNER_DASHBOARDalready names the download route in its audience andapi_outbox_downloadalready honours it for the same owner-only audience. Change: this route asks the same gate, through one shared helper.handlers/files.py: new shared_owner_grant_releases_flagged(grant read off-loop ANDis_owner_dashboard_request),_audit_owner_grant_refusal(names which conjunct refused, and the caller on a cross-principal refusal),_audit_consented_download.api_outbox_downloadcalls them in place of its closures; its behaviour is unchanged.file_api/transfer.py: on a flagged file,api_file_downloadasks the shared helper. Refused: the same 400content_redacted, plus a consentaudit_refusalentry. Released: the SEL success entry carriessensitive_content_delivered_with_consentand a consentdeliveredentry is written. The frontrequire_owner_dashboard_requestgate is unchanged.file_api/transfer.pyalso runs the wide pass (wide_content_is_flagged) that every other owner-facing file gate runs (platform.wide_content_is_flaggeddocuments it as running at every file-delivery gate). Behaviour change: a file holding a credential written at UTF-16/UTF-32 spacing, which this route served before, is now refused with the same 400content_redactedunless the owner's grant is on. Without it, the grant gate added here would be the only owner-facing gate that releases on a narrower notion of "flagged" than its peers.file_delivery_consent.py: docstring lists/api/file-downloadin theowner_dashboardclass.en-XAregenerated.Existing grants: a grant recorded before this PR now also releases flagged files on this route. The Settings copy (
file_delivery_desc) already says the grant lets the product "hand such a file to this computer and your dashboard's Files view", and this route is the Files view's Download, serving the same owner to the same authenticated browser. The audience does not widen, so no re-consent is asked for.Backwards compatibility
Compatible: the outbox route's behaviour and every refusal response shape are unchanged; a non-owner is still stopped at the front gate (403). The one new refusal (wide-encoded credential, no grant) is listed above.
Removes nothing: no route, key, field or function main exposes is removed or renamed; the outbox closures become module helpers with the same logic.
Tests
test/test_file_download.py::TestFlaggedDownloadHonoursOwnerGrant(mocked requests, no server):content_redacteddeliveredentrynon-owner callerno grantFour of these fail on
origin/main. Structural pins intest_file_delivery_consent.pyread the shared helper and assert both routes call it;test_dashboard_files_composition_contract.pylists the three new facade definitions.PierreWorkspaceTreeImpl.test.tsxasserts the new copy names the setting.Manual verification
Ran:
test_file_download.py test_file_delivery_consent.py test_outbox_binary.py test_credential_redaction_switch.py test_dashboard_files_composition_contract.py test_security_posture.py test_owner_gate_file_readers.py test_dashboard_files_onloop_fs.py test_no_config_dir_in_async.py(all pass), and vitestsrc/i18n+PierreWorkspaceTreeImpl.test.tsx(854 pass). flake8, isort, black (non-baselined files) and the comment-history gate are clean. The screenshot below is the built SPA with the download route stubbed to its refusal.Screenshots / video
The file viewer's ⋯ → Download on a flagged file, no grant: the error now names the setting that releases it.
Related Issues
Fixes #17404
Pattern harvest
Not generalizable: the defect is one route that never read an existing grant; the class (owner-facing gates reading the grant) is now pinned by
test_the_download_gate_requires_both_conjuncts, which asserts every owner-facing download route calls the one shared helper.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.