feat/wave-16-on-main #3

Merged
m.mabrey merged 8 commits from feat/wave-16-on-main into main 2026-10-06 22:40:22 +00:00
Collaborator

Wave 16 — Urgent security fixes (D19, D20, D21)

From the security review of 2026-10-01. Decision record: docs/waves/decisions-2026-10-02.md.
Task breakdown and verification record: docs/waves/wave-16.md.

Built on main, so this PR carries no wave 11 or T13.1 code. Six files change outside docs/.

Changes

Task Item Change
T16.1 D21 Session decode fails closed on any error and on cookies over 4096 characters. Requires exp and sub. PyJWT 2.13.0 → 2.15.1.
T16.2 D19 Uploaded files download safely. PDF and raster images open inline, as before. All other types, SVG included, download as an attachment with Content-Security-Policy: sandbox. File names use an ASCII fallback plus RFC 5987 filename*. SVG uploads stay accepted.
T16.3 D20 One SOP per project, at the id sop__<project_id>. A second SOP is refused (400). While a project has a complete SOP, writing another complete one needs Project Admin. All baseline readers prefer the canonical SOP. Existing rows under other ids stay.
T16.4 — Verification record. tests/cdp.py starts the browser from an elevated shell (--do-not-de-elevate). tests/security_check.py skips the D18 refresh check where D18 is absent.

Verification

  • tests/security_check.py (new, no browser): 36/36. Against main before the change: 16 checks fail; those are the findings.
  • server/smoketest.py: 27/27.
  • Browser probes on Edge: files_check.py 36/36, sample_check.py 10/10, critical_reopen_check.py 11/11.
  • pip-audit -r server/requirements.txt: no known vulnerabilities.
  • Production check for D20: no project has more than one complete SOP (0 rows).
  • Merged with wave 12 in a scratch copy, in both orders: no conflicts; both suites pass.

Deploy

  • Rebuild the api image (PyJWT changes). No database migration.
  • After deploy: sign in through Okta; an SVG drawing downloads; a PDF still opens inline;
    python -c "import jwt; print(jwt.__version__)" in the api container prints 2.15.1.
  • Rollback: redeploy the previous image. No data changes to undo.

Notes

  • Supersedes the branch feat/wave-16-security (same seven commits, built on feat/waves-11-13). Delete that branch after this merges.
## Wave 16 — Urgent security fixes (D19, D20, D21) From the security review of 2026-10-01. Decision record: `docs/waves/decisions-2026-10-02.md`. Task breakdown and verification record: `docs/waves/wave-16.md`. Built on `main`, so this PR carries no wave 11 or T13.1 code. Six files change outside `docs/`. ### Changes | Task | Item | Change | |---|---|---| | T16.1 | D21 | Session decode fails closed on any error and on cookies over 4096 characters. Requires `exp` and `sub`. PyJWT 2.13.0 → 2.15.1. | | T16.2 | D19 | Uploaded files download safely. PDF and raster images open inline, as before. All other types, SVG included, download as an attachment with `Content-Security-Policy: sandbox`. File names use an ASCII fallback plus RFC 5987 `filename*`. SVG uploads stay accepted. | | T16.3 | D20 | One SOP per project, at the id `sop__<project_id>`. A second SOP is refused (400). While a project has a complete SOP, writing another complete one needs Project Admin. All baseline readers prefer the canonical SOP. Existing rows under other ids stay. | | T16.4 | — | Verification record. `tests/cdp.py` starts the browser from an elevated shell (`--do-not-de-elevate`). `tests/security_check.py` skips the D18 refresh check where D18 is absent. | ### Verification - `tests/security_check.py` (new, no browser): 36/36. Against `main` before the change: 16 checks fail; those are the findings. - `server/smoketest.py`: 27/27. - Browser probes on Edge: `files_check.py` 36/36, `sample_check.py` 10/10, `critical_reopen_check.py` 11/11. - `pip-audit -r server/requirements.txt`: no known vulnerabilities. - Production check for D20: no project has more than one complete SOP (0 rows). - Merged with wave 12 in a scratch copy, in both orders: no conflicts; both suites pass. ### Deploy - Rebuild the `api` image (PyJWT changes). No database migration. - After deploy: sign in through Okta; an SVG drawing downloads; a PDF still opens inline; `python -c "import jwt; print(jwt.__version__)"` in the api container prints `2.15.1`. - Rollback: redeploy the previous image. No data changes to undo. ### Notes - Supersedes the branch `feat/wave-16-security` (same seven commits, built on `feat/waves-11-13`). Delete that branch after this merges.
m.mabrey added 8 commits 2026-10-06 22:39:27 +00:00
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)
decode_token treats any decode failure, and any cookie over 4096 chars,
as not signed in, and requires exp and sub. PyJWT 2.13.0 -> 2.15.1
(pip-audit: 13 advisories -> none).

Security review SEC-07: a crafted 1.6 KB cookie with no account gave
500 + stack trace; now 401.

New tests/security_check.py (no browser): D21 section 6/6. Against
da1325c with PyJWT 2.13.0 it fails 3 checks (crafted cookie 500,
token with no exp accepted, old pin) - the findings. The over-long
cookie and the two still-works checks pass on both.
Smoke test 27/27.

(cherry picked from commit 01ce7e941c)
New server/files_http.py; get_wp_file uses it.
- PDF and raster images (png, jpeg, gif, webp, bmp, avif) open inline,
  as before; Cache-Control unchanged for the offline drawing cache.
- Every other type, SVG included, downloads as an attachment with
  Content-Security-Policy: sandbox; default-src 'none'.
- SVG uploads stay accepted (decided 2026-10-02: accept, download only).
- Content-Disposition: ASCII fallback + RFC 5987 filename*, control
  characters and quotes replaced. nosniff from the API too.

Security review SEC-01 (stored XSS through an SVG drawing) and SEC-15e
(non-Latin-1 names gave 500; CR/LF reached the header).

security_check.py D19: 20/20 total with D21. Against da1325c: 6 fails
(the findings); every inline/cache/access check passes on both.

(cherry picked from commit 14ecb75c88)
- A SOP posted with no id lands on sop__<project_id>, the id pushSOP
  has always used. Creating (or moving in) a SOP under any other id on
  a project is refused with 400.
- While a project has a complete SOP, writing another complete one
  needs Project Admin (the existing rule only checked the posted row).
- New project_baseline_sop(): canonical row when complete, else the
  latest complete (pre-D20 rows). Used by /api/sops/latest with
  complete=true&project_id, project_summary, project_sop_team and
  project_qa_group, so a rogue row made before the fix cannot stay
  the baseline or the mail routing.
- Existing rows under other ids stay and keep their old rules.

Security review SEC-02 (a project_user took over the baseline and the
PM/CM/QA mail routing with one POST).

security_check.py: 36/36 with D19-D21. Against da1325c: 7 D20 checks
fail (the findings). Smoke test 27/27; seed_demo writes the canonical
id.

(cherry picked from commit 7bd5ab104d)
security_check.py 36/36 (da1325c: 20/36, the 16 failures are the
findings). sec_probe.py: only S3 and S12 change. equivalence_check
IDENTICAL vs da1325c (canonical SOP id in the scenario). Smoke test
27/27. pip-audit clean.

Open: files_check.py (T16.2), sample_check.py and
critical_reopen_check.py (T16.3) need a machine with Edge; those two
tasks stay not-done until they pass.

(cherry picked from commit f0750212ca)
files_check.py 36/36 (T16.2), sample_check.py 10/10 and
critical_reopen_check.py 11/11 (T16.3), run on Matt's machine with
Edge 154. T16.2 and T16.3 done; wave 16 verification complete.

tests/cdp.py: every probe first failed 'exited rc=0 without binding
the port'. The shell was elevated; Edge and Chrome de-elevate by
relaunching through Explorer and the relaunch drops the debugging
port ('Edge is running elevated: 1' in the browser log). Adds
--do-not-de-elevate on Windows and a 15 s grace for the port after an
rc=0 exit. Both inert on a normal shell and off Windows.

(cherry picked from commit f752ae3677)
(cherry picked from commit 2420c73de4)
Wave 16 rebuilt on main (feat/wave-16-on-main, 2026-10-06) so it can
ship without wave 11 and T13.1. main has no sliding refresh, so the one
D18 check now runs only when auth.maybe_refresh_token exists; on main
it instead proves a valid token near its expiry is still accepted.
security_check 36/36 on this branch; smoke 27/27.
m.mabrey merged commit 9fc2d307bb into main 2026-10-06 22:40:22 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: n.siegfried/Project-SDE-WP-Suite#3
No description provided.