Files
Project-SDE-WP-Suite/docs/waves/wave-16.md

6.8 KiB

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__<project_id>
  • 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

Run 2026-10-02 in the build sandbox (Linux, Python 3.10, no browser), on branch feat/wave-16-security at T16.3.

Check Result
tests/security_check.py 36/36 (D21 6, D19 14, D20 16)
Same check against da1325c with PyJWT 2.13.0 20/36. The 16 failures are the findings (D21 3, D19 6, D20 7). The 20 passes are the "still works" checks plus three that already held (over-long cookie 401, non-member 404, SOP move refused by the existing completed-SOP rule)
docs/reference/security-review/sec_probe.py, before vs after Exactly 4 of 27 lines change: S3 (new complete SOP 200 -> 400; baseline sop_rogue -> sop__proj_a; QA group attacker -> real group) and S12 (crafted cookie 500 -> 401). All other lines identical
equivalence_check.py (architecture review), da1325c vs wave 16 IDENTICAL: 78 HTTP results, 89 audit rows, 24 notifications. The scenario's SOP id was changed from sop_eq to the canonical sop__proj_eq on both sides, because D20 refuses a non-canonical id on purpose
server/smoketest.py 27/27 after each of T16.1, T16.2, T16.3
server/seed_demo.py Seeds the demo project; its SOP lands on the canonical id
pip-audit -r server/requirements.txt No known vulnerabilities

Browser probes, run 2026-10-02 on Matt's machine (Windows, Edge 154, Python 3.12.10, .venv), one at a time:

Probe Task Result
tests/files_check.py T16.2 36/36, including the 1440px creator, 390px Field View, and the offline drawing cache with the server gone
tests/sample_check.py T16.3 10/10
tests/critical_reopen_check.py T16.3 11/11, PM + CM + assignee mail, sink-verified

T16.2 and T16.3 are done.

Production data check for D20, 2026-10-02. On the production database (wp_db, psql): projects with more than one complete SOP: 0 rows. D20 has no legacy duplicates to handle on deploy.

Harness fix needed to get there (tests/cdp.py, committed with this record). Every probe failed first with "browser would not start ... exited rc=0 without binding the port". Cause: the PowerShell session was elevated, and Edge and Chrome de-elevate by relaunching themselves through Explorer as a normal user; the relaunch drops --remote-debugging-port. Edge's log said so (Edge is running elevated: 1). No browser policy was involved (all hives checked). Two changes, both inert on a normal shell and on Linux/macOS: --do-not-de-elevate on Windows, and a 15-second grace for the port when the launched process exits rc=0. Probe results are unchanged by it; it only lets the browser start.