diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index c5fd9369..312d32ff 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -289,7 +289,14 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo - [x] R4.11b (7a7b71c) `cargo update -p rustls-webpki -p webpki-roots` (Cargo.lock only) - [x] R4.11c (c9dab63) react-router-dom ^7.18.4 (apps/app/package.json + lockfile) - [x] R4.11d (a604c07) worker TLS test: an in-process rustls server with a self-signed certificate (rcgen, dev-dependency) must be refused by `HttpBackend` (certificate validation active); honest limit: proves validation, not the emSign distrust itself - - [ ] R4.11g owner decisions on the Context7 review (`.claude/audits/CONTEXT7-2026-10-21.md`: distroless debian13, Tailwind outline-hidden, safeNextPath dot segments, dead coverage block, jest-dom entry, tseslint defineConfig, forwardRef, DEPLOY http2, reduced motion) → nothing changed until decided + - [x] R4.11g owner decisions on the Context7 review (2026-10-21): D1 distroless debian13 now, D3 safeNextPath now, D6 DEPLOY http2 now; D2 outline-hidden + D5 MotionConfig reducedMotion → accessibility chantier (not in R4); D4 config chores → maintenance backlog (below); no major upgrade + - [ ] R4.12 pre-merge fixes D1 / D3 / D6 (one commit each; owner 2026-10-21; then STOP at the pre-merge checkpoint) + - [x] R4.12a (51a5a80) D3 `safeNextPath`: the returned value is resolved again against the sentinel origin and must stay same-origin and not start with `//` (dot segments `/..//`, `/%2e%2e//`, `/..\\`, tab inside `..`), else fallback; tests: dot segments, double slashes, backslashes, schemes, encodings, valid destinations unchanged; consumer test through LoginRoute (MemoryRouter) with `next=/..//evil.test` → /app + - [x] R4.12b (49b1849; e2e:avatar 5/5 on the new image) D1 worker runtime `gcr.io/distroless/static-debian13:nonroot` (provenance: GoogleContainerTools distroless, cosign-signed; same user 65532, no shell, static); worker:test, worker:image `run --check`, sandbox tests; Dockerfile only + - [x] R4.12c (60faac8; nginx 1.24 rejects `http2 on`: both forms documented, nginx -t on 1.24 and 1.31) D6 DEPLOY.md: `listen 443 ssl http2;` → `listen 443 ssl;` + `http2 on;` (nginx ≥ 1.25.1 noted); nothing else in the runbook + - [ ] R4.12d gates: check:all on the final state, pnpm audit --prod, cargo deny, worker tests, navigation suites, goldens/oracles unchanged; contract + fresh verifier + security gate; RUST.md §10.14, CHANGELOG, memory → STOP pre-merge checkpoint + - [ ] accessibility chantier (owner 2026-10-21, after R4, needs a visual recette): D2 `focus-visible:outline-none` → `outline-hidden` in the 13 files listed in `.claude/audits/CONTEXT7-2026-10-21.md` (keyboard focus, forced-colors, graphic coherence); D5 `` at the root (Dialog scale, ObservationCard height animations, transitions) + - [ ] maintenance backlog (owner D4, accepted in principle, not scheduled): apps/app/vitest.config.ts dead `coverage` block (no @vitest/coverage-v8); tests/setup.ts → `@testing-library/jest-dom/vitest`; eslint.config.js `tseslint.config` → `defineConfig`; ui/Input, Select, Textarea `forwardRef` → ref prop (React 19); authStore.ts:95-97 stale deadlock comment; no major upgrade (react-router 8, zod 4, TS 7, vite 8 + vitest 4, ESLint 10, PGlite 0.5 stay out) (`.claude/audits/CONTEXT7-2026-10-21.md`: distroless debian13, Tailwind outline-hidden, safeNextPath dot segments, dead coverage block, jest-dom entry, tseslint defineConfig, forwardRef, DEPLOY http2, reduced motion) → nothing changed until decided - [x] R4.11e checks (rust-check, deny advisories ok, audit --prod clean, app 429, check:all green 17:27:54, goldens untouched, criterion 11 generic; gates dispatched): rust-check, `cargo deny check advisories` clean, `pnpm audit --prod` clean, app suite (routing, auth, redirects), check:all (images, sandbox), goldens and oracles unchanged (git status), contract + fresh verifier + targeted security gate; contract criterion 11 regex made generic (owner §6) - [x] R4.11f docs (RUST.md §10.13, CHANGELOG, contract 1700): RUST.md §10.13 table (advisory, old, new, audit, residual), CHANGELOG, DEPLOY if the TLS note changes; memory; checkpoint table → wait for the owner's signal - [ ] R4.10m security reserves found by the R4.10l checks, pre-existing, not fixed (dependency upgrades = owner decision, outside R4.10 scope): RUSTSEC-2026-0382 rustls-webpki 0.103.15 + RUSTSEC-2026-0381 webpki-roots 1.0.9 (worker → ureq; `cargo update -p rustls-webpki -p webpki-roots`; advisories warn-only in check:all, release gate blocks); `pnpm audit --prod` 5 (react-router <7.18.2: 2 high, 3 moderate; several RSC/framework-mode only, open-redirect GHSA-wrjc-x8rr-h8h6 applies to ``/`useNavigate`); full audit 57 incl. 2 critical tinypool (vitest, dev only); gitleaks history 561 commits clean, working tree 1 jwt in git-ignored `.env.worker` (never committed) diff --git a/.claude/tasks/contracts/2026-10-21-rust-r4-premerge-1830.md b/.claude/tasks/contracts/2026-10-21-rust-r4-premerge-1830.md new file mode 100644 index 00000000..1f30e143 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-21-rust-r4-premerge-1830.md @@ -0,0 +1,42 @@ +# Contract: R4.12 pre-merge fixes D1 / D3 / D6 + +Base: ff122d1 on `feature/rust-r4-pdf-core` (« chore(memory): Context7 documentation review report, TODO R4.11 checkpoint »). Range: `ff122d1..HEAD`; `` below is ff122d1. Date: 2026-10-21. + +## REQUEST (verbatim, owner, « Validation R4.11 et derniers ajustements avant recette Safari ») + +« D1 — Distroless Debian 13 : autorisé maintenant. Migrer l'image de base du worker de static-debian12 vers la variante Debian 13 officiellement maintenue. Vérifier la provenance et la compatibilité de l'image avant modification. Conserver l'exécution non-root, les protections sandbox, les contraintes de ressources et le comportement HTTPS. Valider avec worker:test, worker:image, les tests de sandbox et les vérifications pertinentes du worker réel. Ne pas modifier l'architecture ni assouplir les restrictions de sécurité. » + +« D3 — safeNextPath : correction obligatoire maintenant. Corriger la faille logique permettant à une valeur telle que /..//evil.com d'aboutir à //evil.com. La fonction doit garantir que sa valeur retournée est un chemin interne sûr, y compris après normalisation. Ajouter des tests ciblant les segments de parcours, les doubles slashs, antislashs, schémas externes, encodages pertinents et destinations déjà valides. Ne pas casser les redirections internes légitimes. Vérifier les consommateurs et le comportement réel de React Router sans supposer que sa protection actuelle dispense de sécuriser notre propre contrat. » + +« D6 — DEPLOY.md : correction autorisée maintenant. Mettre à jour la syntaxe Nginx obsolète vers http2 on; dans le runbook. Préserver les autres directives et le comportement documenté. Ne modifier aucun serveur de production. » + +« D2 […] ne réalise pas maintenant un remplacement global des 13 fichiers. […] D4 — Ménages de configuration : différés. […] D5 — MotionConfig […] Ne l'implémente pas dans ce dernier lot R4. » + +« Séparer clairement les commits des corrections D1, D3 et D6. Exécuter pnpm check:all sur l'état final, les audits de sécurité, les tests du worker et les tests ciblés de navigation. Conserver les oracles et goldens PDF inchangés. Faire vérifier indépendamment les corrections réalisées. Signaler toute régression ou incompatibilité réelle plutôt que d'ajouter une exception. Ne pas modifier le comportement du moteur PDF en l'absence de défaut démontré. […] Après les trois corrections ciblées et leurs vérifications, arrête-toi au checkpoint de pré-fusion. » + +## FILE SCOPE + +- D3: `apps/app/src/auth/redirects.ts`, `apps/app/tests/unit/auth.validation.test.ts`, `apps/app/tests/unit/routes.LoginRoute.test.tsx` +- D1: `crates/worker/Dockerfile` (the runtime `FROM` line and its comment) +- D6: `DEPLOY.md` (the host nginx `listen 443` lines of Option A) +- Docs: `docs/development/RUST.md` §10.14 (new), `CHANGELOG.md` (Unreleased, Fixed 2026-10-21) +- `.claude/tasks/contracts/2026-10-21-rust-r4-premerge-1830.md` (this contract), `.claude/tasks/TODO.md`, `.claude/memory/{journal,learnings,decisions}.md` + +Out of scope: every other file, in particular the 13 files of D2 (`outline-none` stays), `MotionConfig`, the D4 files (`apps/app/vitest.config.ts`, `apps/app/tests/setup.ts`, `apps/app/eslint.config.js`, `ui/{Input,Select,Textarea}.tsx`, `state/authStore.ts`), `crates/**/src`, `crates/core/tests`, `apps/app/tests/fixtures`, `packages/**`, package manifests and lockfiles; any deletion. + +## ACCEPTANCE CRITERIA + +1. Three code/doc commits, one per decision: `git log --oneline ..HEAD -- apps/app/src/auth/redirects.ts` = one commit (D3); `-- crates/worker/Dockerfile` = one other commit (D1); `-- DEPLOY.md` = one third commit (D6); none of the three commits touches another decision's files (`git show --stat `). +2. D3 contract: for every input in `['/..//evil.test','/.//evil.test','/a/..//evil.test','/a/b/../..//evil.test','/..\\\\evil.test','/x/..\\/evil.test','/%2e%2e//evil.test','/%2E%2E//evil.test','/.%2e//evil.test','/a/%2e%2e//evil.test','/.\t.//evil.test','///evil.test','//evil.test','/\\evil.test','https://evil.test/','javascript:alert(1)','']` the returned value does not start with `//` and resolves to the same origin as a probe origin (check by a node one-liner importing the compiled logic, or read through the test file's cases); legitimate paths unchanged: `/app/account?tab=x#s`, `/editor`, `/app//account`, `/%2F%2Fevil.test` (literal), `/app/account?next=//evil.test`; `/app/../app/account` → `/app/account`. +3. D3 tests: `apps/app/tests/unit/auth.validation.test.ts` has the four new `safeNextPath` cases (dot segments, schemes and escapes, encoded and legitimate paths, idempotence) and `routes.LoginRoute.test.tsx` the `next=/..//evil.test/app/account` → dashboard case; they pass (`cd apps/app && ./node_modules/.bin/vitest run tests/unit/auth.validation.test.ts tests/unit/routes.LoginRoute.test.tsx tests/unit/guards.RequireAuth.test.tsx`); at least the dot-segment case and the LoginRoute case fail on the pre-fix function (`git show :apps/app/src/auth/redirects.ts`), proven by the orchestrator's run: « × safeNextPath > refuses dot segments that normalise into a protocol-relative path », « × safeNextPath > keeps encoded slashes literal and legitimate internal paths unchanged », « × LoginRoute > lands on the dashboard when next normalises into another host (R4.12) », « Tests 3 failed | 16 passed (19) »; the verifier checks by reading that the old function returns `//evil.test` for `/..//evil.test` (node one-liner on `new URL('/..//evil.test','http://next.invalid').pathname`). +4. D1: `crates/worker/Dockerfile` runtime stage is `FROM gcr.io/distroless/static-debian13:nonroot AS runtime`, still followed by `COPY --from=build /faunosteo-worker /faunosteo-worker`, `USER nonroot`, `ENTRYPOINT ["/faunosteo-worker"]`, `CMD ["run", "--check"]`; the build and test stages unchanged (`git diff -- crates/worker/Dockerfile` touches only the runtime `FROM` and two comment lines); `docker image inspect faunosteo_worker:dev` shows user `nonroot`, entrypoint `/faunosteo-worker`, cmd `run --check`; `docker run --rm --network none --entrypoint /bin/sh faunosteo_worker:dev -c true` fails (no shell). +5. D1 proofs in the check:all log (`/checkall-r412.log`, path in the verifier's brief): `gcr.io/distroless/static-debian13:nonroot@sha256:d62067879de890a1def9da0e7766b7d20810a5e5555cef8506b752437d7a3e88` resolved for the runtime, the worker test stage `test result: ok` lines including `tests/tls.rs`, the seccomp derivation, the runtime `run --check` output; and `pnpm e2e:avatar` 5/5 on this image (`/e2e-d1.log`). Read the logs, do not re-run Docker builds or the stack. +6. D6: `DEPLOY.md` Option A server block reads `listen 443 ssl;`, `listen [::]:443 ssl;`, `http2 on;` with a comment naming nginx >= 1.25.1, the 1.24 form (`listen 443 ssl http2;`) and `nginx -v`; no other DEPLOY.md line changed (`git diff -- DEPLOY.md`: 6 insertions, 2 deletions); the incompatibility (nginx 1.24 rejects `http2 on`) recorded in RUST.md §10.14. +7. Scope held: `git diff --stat -- apps/app/src` lists `auth/redirects.ts` only; no `outline-none`, `MotionConfig`, vitest/jest-dom/eslint/forwardRef/authStore change; `git diff --stat -- crates/core crates/wasm crates/worker/src apps/app/tests/fixtures crates/core/tests packages Cargo.lock pnpm-lock.yaml` empty; no deletion (`git diff --diff-filter=D --name-only ` empty). +8. Suites: `pnpm check:all` exit 0 on the final code state (log `/checkall-r412.log` ending `== all checks passed`, apps/app 59 files / 434 cases); `pnpm audit --prod` clean; `cargo deny check` ok; `pnpm typecheck`, `pnpm lint` exit 0; `git status --short` empty. +9. Docs: RUST.md §10.14 covers D3 (cases, consumers, react-router behaviour read in the installed package, negative run), D1 (provenance and digest, cosign not checked, contents, proofs, e2e), D6 (the 1.24 incompatibility and the nginx -t runs); CHANGELOG Unreleased has the line; TODO carries the accessibility chantier (D2, D5) and the maintenance backlog (D4) without doing them. + +## CLARIFICATIONS + +Q: D6 says « vers http2 on; »; the live VPS runs nginx 1.24, which rejects it. Replace blindly? / A: no: the owner asked to report a real incompatibility rather than work around it silently; the runbook gives the new form for >= 1.25.1 and names the 1.24 form, both proven with `nginx -t`. [gated 2026-10-21, owner « Signaler toute régression ou incompatibilité réelle »] +Q: the worker's real check without the managed Supabase? / A: `pnpm e2e:avatar` on the local stack (the documented real-stack test, plain HTTP on the Docker network); the HTTPS path is the R4.11 TLS test, unchanged and run in the image's test stage. [gated 2026-10-21, owner D1 « vérifications pertinentes du worker réel »] diff --git a/CHANGELOG.md b/CHANGELOG.md index 42ce80b2..e5e8d024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Versions follow [Semantic Versioning](https://semver.org/). ### Fixed (2026-10-21, on `feature/rust-r4-pdf-core`, not merged) +- Sign-in redirects: a `next` value whose dot segments normalise into `//host` (`/..//host`, `/%2e%2e//host`) now falls back to the dashboard instead of being returned as a protocol-relative path. The worker image runs on `distroless/static-debian13:nonroot` (the Debian 12 tags are no longer updated). DEPLOY.md shows `http2 on;` for nginx 1.25.1 and later and keeps the `listen ... http2` form for nginx 1.24 (`docs/development/RUST.md` §10.14). - Dependencies: `rustls-webpki` 0.103.16 and `webpki-roots` 1.0.10 (RUSTSEC-2026-0382, RUSTSEC-2026-0381; the worker's TLS client), `react-router-dom` 7.18.4 (GHSA-wrjc-x8rr-h8h6, GHSA-chx6-hx7r-mcp5 and three RSC / SSR advisories the application does not reach). A worker test proves the HTTPS client refuses an untrusted server certificate (`docs/development/RUST.md` §10.13). - The footer's « Propulsé par ZenQuality » logo is bundled with the application instead of loaded from zenquality.fr: the documented production CSP (`img-src 'self' data: blob:`) refused the external image and showed the alt text in its place. Same picture, no policy change; the exported PDF never depended on it. diff --git a/docs/development/RUST.md b/docs/development/RUST.md index b9735d70..5c2243f3 100644 --- a/docs/development/RUST.md +++ b/docs/development/RUST.md @@ -2436,3 +2436,63 @@ apps/app/tests/fixtures crates/core/tests` empty). Nothing is called fixed because it compiles: the Rust ids are gone from the advisory check and the npm ones from the production audit, and the two reachable behaviours (certificate validation, `next` redirection) have a test each. + +### 10.14 R4.12: the three pre-merge fixes of the Context7 review (2026-10-21) + +Owner decisions on `.claude/audits/CONTEXT7-2026-10-21.md`: D1, D3 and D6 +now, one commit each; D2 (Tailwind `outline-hidden`) and D5 (`MotionConfig +reducedMotion="user"`) for a separate accessibility chantier with a visual +recette; D4 (vitest coverage block, jest-dom entry, `defineConfig`, +`forwardRef`, the authStore comment) in the maintenance backlog; no major +upgrade. + +**D3, `safeNextPath` (51a5a80).** The URL parser's own normalisation turned +`/..//evil.test`, `/.//`, `/a/..//`, `/%2e%2e//`, `/.%2e//`, `/..\\` and a +tab inside `..` into `//evil.test`: same origin for the sentinel, yet a +protocol-relative path once returned. The rebuilt value is now refused when +it starts with `//` or no longer resolves to the sentinel origin, so the +function's contract holds by itself. Consumers (`LoginRoute`, +`RedirectIfSignedIn`, `AuthCallbackRoute`) were not exposed in practice: +react-router 7.18.4's `useNavigate` throws « External navigation is not +allowed » on such a target and `` collapses the slashes +(`resolvePath('//evil.test/app/account')` = `/evil.test/app/account`, a +not-found page), read in the installed package; the fix does not rely on +it. Tests: 4 new `safeNextPath` cases (12 dot-segment spellings, external +schemes and escapes, encoded slashes kept literal and legitimate paths +unchanged, idempotence) and a `LoginRoute` case through the real router +(`next=/..//evil.test/app/account` lands on the dashboard); on the old +function, 3 of them fail. + +**D1, worker runtime image (49b1849).** `gcr.io/distroless/static-debian12` +→ `static-debian13:nonroot` (the distroless README: only the Debian 13 +tags are still published and updated). Provenance: the official +`gcr.io/distroless` registry, digest +`sha256:d62067879de890a1def9da0e7766b7d20810a5e5555cef8506b752437d7a3e88` +at the build; its cosign signature was not checked (no cosign on this +machine). Same contents for the worker: user `nonroot` 65532, no shell +(`/bin/sh` absent), CA bundle at `/etc/ssl/certs` (the worker's TLS uses +the bundled webpki roots, not the system store). The build, the sandbox +and seccomp `test` stage and the binary are unchanged. Proofs: +`pnpm worker:test` (sandbox tests 11 + 16, TLS 1, seccomp derivation), +`pnpm worker:image` (user nonroot, `run --check`, 12.1 MB), `run --check` +under `--read-only --cap-drop ALL --network none`, and `pnpm e2e:avatar` +against the local Supabase stack with this image: 5/5 (clean upload, +replacement and purge, signed-URL leftovers, hostile and corrupted uploads +refused with closed codes, removal); the stack was stopped afterwards +(volumes kept). + +**D6, DEPLOY.md host nginx (60faac8).** `listen 443 ssl http2;` → +`listen 443 ssl;` + `http2 on;`. Incompatibility found and kept visible: +faunosteo.com answers `Server: nginx/1.24.0 (Ubuntu)`, and nginx 1.24 does +not know `http2 on` (`nginx -t` in a throwaway `nginx:1.24-alpine`: +`unknown directive "http2"`), while nginx 1.31 accepts it and warns that +`listen ... http2` is deprecated. The runbook gives the new form for +nginx >= 1.25.1 and names the old one for 1.24, with `nginx -v` to choose; +no other directive changed, no server touched. + +Checks on 60faac8: `pnpm check:all` green (18:55:30; apps/app 59 files, +434 cases; the worker image on the Debian 13 digest; the TLS test native +and in the musl stage); `pnpm audit --prod` clean; `cargo deny check` +(all four) ok; the goldens, oracles and the PDF engine untouched +(`git diff --stat 8943bf3 -- apps/app/tests/fixtures crates/core/tests +crates/core/src` empty).