D19 - uploaded files download safely (SEC-01, SEC-15e)
D20 - one SOP per project (SEC-02)
D21 - session decode fails closed, PyJWT 2.15.1 (SEC-07)
From the security review of 2026-10-01. Decision record and task
breakdown only in this commit - no code yet.
(cherry picked from commit 1c221a122e)
4.4 KiB
4.4 KiB
Decisions — October 2, 2026
Three items, from the security review of 2026-10-01
(docs/reference/security-review-2026-10-01.md). They get D ids because they
are internal security calls made mid-build, the same category as D15 and
D18, not features a user asked for.
Decided by Matt Mabrey, 2026-10-02.
| Item | Title | Review finding | Task |
|---|---|---|---|
D19 |
Uploaded files download safely | SEC-01, SEC-15e (BL-035, BL-036) | T16.2 |
D20 |
One SOP per project | SEC-02 (BL-048) | T16.3 |
D21 |
Session decode fails closed; PyJWT upgraded | SEC-07 (BL-052) | T16.1 |
Schedule: wave 16. It is independent of waves 12 to 15: it touches
server/ only, and no file in it is changed by a task in those waves except
server/app.py, in functions they do not touch (get_wp_file, upsert_sop,
the SOP baseline readers). Wave 16 may merge before wave 12.
Out of this round, by decision: SEC-06 (session revocation) waits for the
AWS work. All other SEC findings stay as backlog drafts in
docs/reference/security-review/backlog-drafts.md.
D19 — Uploaded files download safely
- Problem: an SVG drawing can carry a script. The server sends it back
inlinewith its own content type, on the app's origin, so the script runs as whoever opens it (SEC-01). Separately, a file name that is not Latin-1 (for examplePlan é.pdf) makes the download fail with 500, and CR/LF in a name reaches the response header (SEC-15e). - Decision: SVG uploads stay accepted, but every file that is not a
PDF or a raster image downloads as an attachment inside a sandbox:
Content-Disposition: attachmentandContent-Security-Policy: sandbox; default-src 'none'. PDF and raster images (PNG, JPEG, GIF, WebP, BMP, AVIF) keep opening inline. Every file name goes out in the RFC 6266 / RFC 5987 form (ASCII fallback plusfilename*). - Why accept SVG instead of refusing it: no change for the person who uploads, and no migration for SVGs already stored. The protection is on the way out, which also covers any SVG already in the database.
- Must not change: inline preview of PDF and images (CR-007), the
Cache-Controlthe offline drawing cache relies on, the D8 limits, and the upload API.
D20 — One SOP per project
- Problem: the rule "changing a completed SOP is a Project Admin action"
checks only the SOP row being posted. A
project_usercan post a NEW SOP id withcomplete: true. Every reader picks "the latest complete SOP", so that row becomes the baseline every page loads and the source of PM, CM and QA mail routing (SEC-02, probe S3). - Decision:
- A project has one SOP, with the id
sop__<project_id>. The browser has always written that id (pushSOPinproject-data.js). A request with no id gets it. A request that would CREATE a SOP with any other id on a project is refused with 400. - Existing SOP rows with other ids (for example rows
seed_demo.pymade) stay. They can still be updated under the old rules. Nothing is deleted. - While a project has a complete SOP, writing any SOP on that project with
complete: true, and changing a complete SOP, needs Project Admin on the project. - The readers prefer the canonical row:
project_sop_team,project_qa_group,project_summaryandGET /api/sops/latestwithcomplete=true&project_id=readsop__<project_id>when it is complete, and fall back to "latest complete" only when it is not. So a rogue row made before this fix cannot stay the baseline.
- A project has one SOP, with the id
- Must not change: a project member drafting the SOP and completing it the first time (allowed today, allowed after); admin access to project-less SOPs; the response shape of every SOP route.
D21 — Session decode fails closed; PyJWT upgraded
- Problem: a crafted 1.6 KB cookie makes PyJWT 2.13.0 raise an error that
decode_tokendoes not catch, so an unauthenticated request gets a 500 and a stack trace in the log (SEC-07, probe S12).pip-auditlists 13 advisories for 2.13.0. - Decision: pin PyJWT 2.15.1 (
pip-audit: no known vulnerabilities on 2026-10-02).decode_tokentreats ANY decode failure, and any cookie longer than 4096 characters, as "not signed in" (401). It also requires theexpandsubclaims, which every token this app issues carries. - Must not change: every valid session, the D18 sliding refresh and ceiling, and the fake Okta test seam.