| Learners |
No account, no cookie, no analytics, no third-party request. The studio's cookies are scoped to /admin: the public pages never receive, read or set one. |
guard.ts |
e2e: context.cookies() empty after every anonymous journey; the editor's cookie is not sent to /programme |
| Authentication |
Passkeys only (WebAuthn, user verification required, discoverable credentials). No password. First enrolment by a one-time token produced in the server's shell; token stored as SHA-256, 30 min, single use, one live token per editor. |
src/server/auth.ts, scripts/studio.ts |
studio-auth.test.ts; e2e with a virtual authenticator |
| Sessions |
Server-side; cookie = random 256-bit token (database keeps its SHA-256); HttpOnly, SameSite=Strict, Secure on HTTPS, Path=/admin; 12 h absolute, 2 h idle; new identifier at every sign-in; revocable; die when an editor is disabled or a passkey revoked. |
auth.ts, guard.ts |
unit + e2e |
| Replay |
A WebAuthn challenge is single-use, 5 min, bound to the browser that asked (HttpOnly pre-auth cookie); a closed session's cookie and CSRF token are dead; content writes carry a revision and a stale one is refused (409). |
auth.ts, content.ts |
unit + e2e |
| Brute force |
30 auth requests/min per address; lock-out after 5 refused sign-ins per address per hour (1 min, 5 min, 1 h), derived from the audit log so it survives restarts; 240 writes/min and 3000 upload pieces/min per session. In memory, per process. |
http.ts, auth.ts |
unit + e2e |
| CSRF |
Every state-changing request: same Origin, Sec-Fetch-Site same-origin, and the session's token in x-csrf-token. |
guard.ts |
e2e: 24 write routes × foreign origin, cross-site, missing token, wrong token → 403 |
| Authorisation |
One dispatcher for the whole private API: session and permission are checked before any handler; every private page calls requireEditorPage. Roles owner / publisher / author. An anonymous caller gets 401 for any path, existing or not. |
src/lib/studio/api.ts, guard.ts |
e2e: 15 reads + 24 writes anonymous → 401; author → 403 on publish, access, export |
| Indexing, caching |
/admin/**: X-Robots-Tag: noindex, Cache-Control: private, no-store, robots metadata, Disallow: /admin, absent from the sitemap. |
next.config.ts, layouts |
e2e |
| Publication gate |
The public site is built only from immutable publications that are due, through buildView. Drafts, previews, scheduled entries, private items, solutions and quiz answers of unpublished sessions are not in the manifest the public code receives. |
publish.ts, publication.ts, content.ts |
studio-publication.test.ts; e2e by URL, search index, sitemap, API, media; pnpm leak-check (build scan + live crawl of 252 URLs) |
| Media |
A file under /media/ is served only if a live publication names it (exact files, or the directory of its HLS playlist). Each encode and each caption file has its own name; masters, uploads and scratch space are never served. |
mediaAllowed, uploads.ts, worker.ts |
unit + e2e (404 before publication and after withdrawal) |
| Uploads |
Pieces of 4 MiB, SHA-256 per piece, fingerprint and whole-file hash on assembly; type by magic bytes vs extension allow-list; size limits per purpose; file names reduced to a harmless base name; storage budget; nothing executable accepted (no html, svg, sh, exe…). Downloads are sent as attachments with nosniff and a sandboxing CSP. |
uploads.ts, magic.ts, serve.ts |
studio-media.test.ts, studio-captions.test.ts, e2e (disguised files) |
| Archives |
Own extractor for zip and tar.gz: traversal names refuse the archive; links, devices and odd names are skipped; limits on entries, per-file and total size counted on inflated bytes, compression ratio; never overwrites; encrypted and ZIP64 refused. |
archive.ts |
studio-archive.test.ts (forged archives) |
| Slides |
Built from the public web PDFs by poppler (fixed arguments, no shell, on copies); packs validated file by file (checksums, SVG inspected, names by pattern); served only for a published deck, as images under a sandboxing CSP. Speaker notes are never read; a leak test looks for them in decks, database, search index and pages. |
slides.ts, slides-serve.ts |
studio-slides.test.ts, e2e/slides.spec.ts, pnpm leak-check |
| Imported content |
Read as data: YAML core schema, size limits, confined paths, no execution, solution/ never opened; SVG rejected if active. |
importer.ts, adapter.ts |
importer.test.ts, studio-sync.test.ts |
| XSS |
Markdown rendered without raw HTML; links http(s) only; images dropped; KaTeX with trust off; highlighting by class names. Same component for the studio preview and the public page. JSON sections validated by schema and rendered by React. |
Markdown.tsx |
markdown.test.ts, e2e (script/onerror/javascript: probes) |
| SQL injection |
Parameterised statements everywhere; the only interpolated SQL is the backup path (refused if it contains a quote) and fixed placeholder lists. |
db.ts |
review |
| Path traversal |
isSafeRelPath + realpath containment (FsStorage); identifiers matched by strict patterns in the API routes. |
storage, api.ts |
e2e (encoded .. on 13 routes) |
| SSRF |
The server makes no outbound request; the link checker validates external URLs syntactically and never fetches them. |
ops.ts |
by construction |
| ffmpeg |
Started without a shell, fixed arguments, input = the stored master only; time limit, bounded concurrency, killed by PID; duration limit; output in scratch space then moved. |
transcode.ts, worker.ts |
unit |
| Secrets, logs |
No secret in the repository or the client bundle; structured logs redact tokens, cookies, CSRF, authorization, challenges; the audit log stores hashes and snapshots, never tokens. |
log.ts, audit.ts |
pnpm secret-scan, bundle scan in leak-check, unit, e2e (journal searched for the cookie, CSRF token and enrolment token) |
| Headers |
CSP default-src 'self' with no remote origin, frame-ancestors 'none', nosniff, HSTS, COOP, Referrer-Policy, Permissions-Policy. |
next.config.ts |
e2e |
| Dependencies |
Lockfile; pnpm audit (all dependencies) on 2026-11-22: no known vulnerability, after pinning KaTeX to 0.19.1 (GHSA-238p-pmpm-9mq7 in the copy rehype-katex brought). |
pnpm-workspace.yaml |
pnpm audit |
| Clean checkout |
A guard fails when a source file is git-ignored or untracked, and type-checks a git archive HEAD export. |
scripts/clean-checkout-check.sh |
pnpm clean-check |