# Wave 16 — Urgent security fixes **Items:** `D19`, `D20`, `D21` **Depends on:** nothing. Independent of waves 12 to 15 (see the decision record). **Decision record:** `docs/waves/decisions-2026-10-02.md` **Background:** `docs/reference/security-review-2026-10-01.md` Four tasks, in build order. All server-side. No page markup or stylesheet changes, so the 390px / 1440px screenshot rule does not apply; the browser probes that read files and SOPs are still listed for a run on a machine with Edge. New check for this wave: `tests/security_check.py`. It is self-contained (its own SQLite database, in-process, no browser), so it runs anywhere. --- ### T16.1 — D21: session decode fails closed; PyJWT 2.15.1 - **Items:** `D21` - **Depends on:** nothing (first task) - **Blocks:** T16.4 - **Surface:** `server/` - **Files:** `server/requirements.txt`, `server/auth.py` (`decode_token`), `tests/security_check.py` (new) **Do:** pin `PyJWT==2.15.1`. In `decode_token`, return `None` for an empty or over-long token (over 4096 characters) and for any exception from `jwt.decode`. Require the `exp` and `sub` claims. **Do not:** change token contents, the cookie, or the D18 refresh. **Done when:** - [ ] the crafted-cookie request returns 401, not 500 - [ ] a valid session still works, and the D18 refresh still reissues - [ ] `pip-audit -r server/requirements.txt` reports no PyJWT advisory - [ ] smoke test 27/27 --- ### T16.2 — D19: uploaded files download safely - **Items:** `D19` - **Depends on:** nothing - **Blocks:** T16.4 - **Surface:** `server/` - **Files:** `server/files_http.py` (new), `server/app.py` (`get_wp_file`), `tests/security_check.py` **Do:** serve PDF and raster images inline as today. Serve every other type, SVG included, as an attachment with `Content-Security-Policy: sandbox; default-src 'none'`. Send `X-Content-Type-Options: nosniff` from the API too (NGINX already does; the dev server does not). Build `Content-Disposition` with an ASCII fallback and an RFC 5987 `filename*`. Reference code: `docs/reference/architecture-review/proposals/server/files_http.py` (P-6). **Do not:** refuse SVG uploads (decided: accept, download only). Do not change `Cache-Control`. **Done when:** - [ ] an SVG downloads as an attachment with the sandbox header - [ ] PNG, JPEG and PDF still open inline - [ ] `Plan é.pdf` downloads (was 500) - [ ] a name with CR/LF produces a valid header - [ ] `tests/files_check.py` passes on a machine with Edge (CR-007 offline drawings) --- ### T16.3 — D20: one SOP per project - **Items:** `D20` - **Depends on:** nothing - **Blocks:** T16.4 - **Surface:** `server/` - **Files:** `server/app.py` (`upsert_sop`, `latest_sop`, `project_summary`, `project_sop_team`, `project_qa_group`), `tests/security_check.py` **Do:** the four rules in D20. One helper picks the project's baseline SOP (canonical row if complete, else latest complete) and every baseline reader uses it. **Do not:** delete or rename existing SOP rows. Do not change any response shape. **Done when:** - [ ] a `project_user` cannot create a second SOP on a project (400) or post `complete: true` while a complete SOP exists (403) - [ ] a `project_user` can still draft and complete the first SOP of a project - [ ] a Project Admin can still change the completed SOP - [ ] POST without an id lands on `sop__` - [ ] a rogue complete SOP made before the fix no longer drives the baseline or the QA and PM/CM recipients - [ ] `tests/sample_check.py` and `tests/critical_reopen_check.py` pass on a machine with Edge --- ### T16.4 — D19, D20, D21: verification - **Items:** `D19`, `D20`, `D21` - **Depends on:** T16.1 to T16.3 - **Surface:** verification - **Files:** this file (verification record) **Done when:** - [ ] `tests/security_check.py` passes - [ ] `docs/reference/security-review/sec_probe.py`: S3 and S12 change as expected; every other line is unchanged - [ ] the architecture review `equivalence_check.py` (current branch vs wave 16) is IDENTICAL: the scenario does not use these paths, so it proves the rest of the work-package flow did not move - [ ] smoke test 27/27 - [ ] the browser probes named in T16.2 and T16.3 are listed for a run on a machine with Edge (not available in the build sandbox) ## Verification record (filled in at T16.4)