# 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 `inline` with 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 example `Plan é.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: attachment` and `Content-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 plus `filename*`). - **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-Control` the 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_user` can post a NEW SOP id with `complete: 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:** 1. A project has one SOP, with the id `sop__`. The browser has always written that id (`pushSOP` in `project-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. 2. Existing SOP rows with other ids (for example rows `seed_demo.py` made) stay. They can still be updated under the old rules. Nothing is deleted. 3. 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. 4. The readers prefer the canonical row: `project_sop_team`, `project_qa_group`, `project_summary` and `GET /api/sops/latest` with `complete=true&project_id=` read `sop__` 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. - **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_token` does not catch, so an unauthenticated request gets a 500 and a stack trace in the log (SEC-07, probe S12). `pip-audit` lists 13 advisories for 2.13.0. - **Decision:** pin **PyJWT 2.15.1** (`pip-audit`: no known vulnerabilities on 2026-10-02). `decode_token` treats ANY decode failure, and any cookie longer than 4096 characters, as "not signed in" (401). It also requires the `exp` and `sub` claims, 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.