tracker
All repositories: gitoria
11.5 KB
# SK — security audit of tracker.worldapi.org (branch sk-sec, from main f0f26c5)Method: a real running tracker (own throw-away ident, fake TMDB, fixture storage with an adult title, XSS text in every field), real HTTP(`fetch` / `POST /__hl/emit` exactly as the browser's client does), three callers — anon, bob (another user), alice (owner + editor).Probes were first run by hand (scratch `s/probe1..4.mjs`), then written into the gate `tests/security.mjs` (fixture `tests/seckit.mjs`,`tests/seed-xss.hl`). **The checks marked FIX (18 failures on old code incl. dependants) fail on the old code (main f0f26c5: `TRACKER_APP_DIR=<old tree> node tests/security.mjs` → 37 passed / 18 failed, all pass on the new code.** Never touched the live site.## Results| # | check | result | severity | fixed | test (tests/security.mjs) ||---|---|---|---|---|---|| 1 | AuthZ, 15 pages × anon/bob/alice | all 200; `/my/*` data (watches, follows, adult title) only for its owner; the adult title's page names the title for its follower only | – | ok | "authz pages", "adult title's page", "/my/unwatched" || 1 | AuthZ, faces signed out (unwatchedToggle, showToggle{Episode,Season,Movie,Follow}, searchImport) | all refuse ("you are not signed in") | – | ok | "signed out is refused" ×6 || 1 | AuthZ, editor faces (fedCreate*, tedSetFranchise/Move/Remove/Add) | anon + bob refused ("only the creator"), alice works; `isEditorSession` demands a real Instance | – | ok | ×6 + "creator creates a franchise" || 1 | AuthZ, public faces (searchDb, showComplete, showSeasonEpisodes, fedFindTimelines, tedSearch, showRows) | open by design (public data); adult title: showRows refuses anon + bob | – | ok | "public faces", "showRows of the adult title" || 1 | peer-sent `session` argument (become another user) | refused by hl:web ("filled by the server, never by the peer") | – | ok | "a `session` sent by the peer is refused" || 1 | logout | ends the session: same cookie is signed out afterwards (face refused, /my page empty) | – | ok | "logout ends the session" || 1 | **bob follows alice's ADULT title by slug** (`showToggleFollow`) | was OK → bob then sees the hidden page (adult titles are followers-only) | **medium** (privacy; slugs are guessable from TMDB titles; also an enumeration oracle) | **yes** | FIX faces: bob cannot follow…; alice cannot re-follow after unfollow || 1 | **watch rows for any text / any episode**: `unwatchedToggle('junk')` stored a watch row; `showToggleEpisode` took an episode of another show or none; `showToggleSeason` a season of another show (also past the adult guard); `unwatchedToggle` ignored adult | own data only, but unbounded junk rows per user and an adult-guard bypass | low–medium | **yes** (episode must exist, belong to the show, show not adult-hidden; season must belong to the show) | FIX faces ×5 || 1 | anonymous `GET /person/tmdb/<id>` (no `?show=`, the old-link path) asks TMDB and **stores a new person** — a state-changing unauthenticated GET, usable as a cross-site `<img>` | unlimited table growth + TMDB quota | **medium** | **yes**: budget `TRACKER_GUEST_FALLBACK_PER_HOUR` (20/h in all) | FIX budget || 1 | `searchImport` (any signed-in user adds titles: TMDB request + record) | unlimited per user | low | **yes**: `TRACKER_IMPORT_PER_HOUR` (60/h/user), id must be number/text | FIX imports ×2 || 1 | `searchWeb`, `showComplete`, `personFill` anonymous → outbound TMDB requests | open by design (the search page is public); bounded by existing records except searchWeb (one TMDB search per call) | low | no (see open) | – || 2 | HTML in title, summary, tagline, cast actor/character, season/episode title+summary, person name/bio, genre, URL path and search text, on 9 pages | never raw (`<img onerror`, `<svg onload`, `</script><`, `href="javascript:`): the text is escaped, the page seed has `<` encoded | – | ok | "HTML / script … never reaches a page raw" || 2 | stored `homepage = javascript:…` | never rendered as a link; external links are built from ids onto fixed hosts (`target=_blank rel=noopener`) | – | ok | "javascript: URL is not a link" || 2 | **reflected XSS in hl:web's 404 page** (`/search/<script>…</script>` → 404 body `not found: <path>` as text/html, e.g. `/posters/..%2f..%2f.env`) | script tag comes back raw (probe: `rawScriptTag:true`) | high-ish (reflected) | no — hl:web (known, not re-reported) | – || 2 | path traversal `/posters/..%2f`, `%2e%2e`, `%00`, `\`, `/__hl/../project.hl`, `/.env`, `/storage/…`, `/lib/…`, `/tests/…` | none served; names whitelisted (letters digits `.-_`, ≤100) | – | ok | "path traversal" || 2 | header injection: `/login/callback?next=`, `/find?q=` with CR/LF, `//host`, scheme | only same-site paths from a whitelist (≤500); `/find` encodes | – | ok | "?next=", "/find?q=" || 2 | SSRF (server-side fetch) | none from user input: TMDB/TVmaze/ident hosts come from env, ids are numeric-checked (`toNumber`, `tid % 1`), poster paths are TMDB's, appended to the fixed image host; file names from `oldId` + whitelisted ext (jpg/jpeg/png/webp) | – | ok | – || 2 | wrong types to faces (list/object where text is wanted) | **500 `components/show.hl:749:40: operator '+' …`** — names source file + line; 7 faces (showComplete, searchDb, searchWeb, personFill, fedFindTimelines, tedSearch, searchImport) | low (info) | **yes** (`textArg`) | FIX input || 3 | uploads | the app has **no upload / file face**; stored poster/profile files come only from TMDB downloads, extension jpg/jpeg/png/webp. Images were served without `nosniff` and without a policy | low | **yes**: `X-Content-Type-Options: nosniff` + `Content-Security-Policy: default-src 'none'; …; sandbox` on every image/placeholder answer | FIX headers (image) || 3 | hl:web `/__hl/upload`, `/__hl/emit` body caps | known (not re-reported) | | | || 4 | session cookie flags | `trackersid=<32 hex>; Path=/; HttpOnly; SameSite=Lax; Max-Age=1209600`. **No `Secure`** (hl:web hybriel#27; behind TLS acceptable for now) | low | no — hl:web | "session cookie is HttpOnly, SameSite=Lax" || 4 | CSRF on state changes | state only changes via `POST /__hl/emit` with the cookie; SameSite=Lax blocks cross-site POST cookies in current browsers; **no Origin check** (same-site sibling apps on *.worldapi.org could post) — known hl:web gap (`/__hl/emit` + ws Origin). The only GET with a side effect was `/person/tmdb/<id>` (fixed above: budget) | low | partly | – || 4 | **session fixation**: the callback kept the browser's existing session id and signed it in | a session id planted before login became signed-in | low–medium | **yes**: a NEW session at every `/login/callback` (the face `trackerLogin` still keeps the id — hl:web "face session rotate", known) | FIX login: NEW session || 4 | **no rate limit on login** (150 bad codes in 2 s, each an outbound exchange to ident; the face 100 in a row) | none | medium | **yes**: callback 20/min per `X-Client-IP` (`TRACKER_LOGIN_PER_MINUTE`), face 20/min per session; refusal says "too many login attempts" and does not call ident | FIX login ×2 || 4 | a used / wrong login code | refused ("unknown or already used") | – | ok | "a used login code cannot be used again" || 4 | `/login/callback` by POST | failed login, no session | – | ok | "callback answers GET only" || 5 | secrets in pages, component modules, css, sw.js, manifest, login.js, for anon/alice/bob | none of: ident secret, TMDB token, any identity id, any session id, absolute path. (`pk_…` public ident key is in the login link: by design) | – | ok | "secrets: no app secret…" || 5 | secrets in the server log | none | – | ok | "none of them in the server log either" || 5 | git history (162 commits, all branches): `sk_`, JWTs, `TMDB_READ_TOKEN=`, `TRACKER_SECRET=`, private keys, `.env` files | none found (only Zig source with a variable called `password`) | – | ok | (one-off scan, not a gate) || 5 | error messages | only the source-line 500s above (fixed); ident's refusal text is shown on /login/failed (ident's own, harmless) | low | yes | – || 6 | headers on pages (CSP, X-Content-Type-Options, frame-ancestors/X-Frame-Options, Referrer-Policy) | **none at all on any page** (only content-type, set-cookie, content-encoding) — hl:web has no page header hook (known). Clickjacking of the tracker is possible | medium | no — hl:web / nginx | – || 6 | headers on the app's own answers (function routes, images) | now nosniff on every plain-text answer (404, 301/302, 400, 503) and image; images sandboxed | low | **yes** | FIX headers ×2 || – | **sessions flood (hl:web)**: every request WITHOUT a cookie (page, `/__hl/emit`, callback) mints a session FILE + Set-Cookie; 400 cookie-less requests: 3 → 403 files in `.sessions/`, no sweep seen | disk growth by any bot | medium | no — hl:web, repro `.scratch/hlweb-gaps/session-flood.mjs` | – || – | session ids are stored in clear in `.sessions/*.json` | readable by anyone with the volume | info | no | – |hl:web items STOPPED on (not worked around in JS): pages without security headers; no `Secure` cookie flag; sessions flood; no Origin check on emit/ws(known); face login keeps the session id (known).## Files`lib/security.hl` (new: request budget `allowHit`, `clientKey`, `imageHeaders`, `importPerHour`), `lib/images.hl`, `lib/users.hl` (new session + budget),`lib/people.hl` (guest budget), `lib/follows.hl` (`adultHiddenForUser`), `lib/util.hl` (`textArg`, nosniff on redirects), `lib/franchises.hl`,`components/{show,unwatched,search,person,main}.hl`, `project.hl` (nosniff on text answers). Tests: `tests/security.mjs`, `tests/seckit.mjs`,`tests/seed-xss.hl`. No hand-written JS. Env knobs: `TRACKER_LOGIN_PER_MINUTE` (20), `TRACKER_GUEST_FALLBACK_PER_HOUR` (20), `TRACKER_IMPORT_PER_HOUR` (60).## Add to deploy.sh GATES`"node tests/security.mjs"` — ports `TRACKER_GATE_PORT`, `TRACKER_GATE_IDENT_PORT`, `TRACKER_GATE_TMDB_PORT` (already in deploy-init.sh's tracker line: 8767/8768/8769, no new env needed; runs ~2 min, no Chrome).## Gate counts (new code, my ports 8900–8914; old = main f0f26c5 / T17 report)browser 382/0, kinds 32/0, franchises 53/0, pager 229/0, franchiseseed 26/0, check-theme 103 files 0 problems, person-lookup passed, warmstart 12/0,**security 55/0 (new)** — identical to old (382/32/53/229/26/theme 0/person-lookup/12). Old code on tests/security.mjs: **37 passed / 18 failed**(the checks named FIX plus their dependants). Env for the new gate: `TRACKER_GATE_PORT TRACKER_GATE_IDENT_PORT TRACKER_GATE_TMDB_PORT` (my run: 8900/8901/8902).Note (Atlas): tracker.conf on byrodin now sets X-Client-IP, which is the key the login budget uses — nothing to change.## E2ENo page or UI changed. The one behaviour a browser touches — sign-in with the new session at `/login/callback` and the header selector — is exercisedby the real-Chrome gate `tests/browser.mjs` (signs in through ident's real login flow at 390 and 1280 px, 382 checks, 0 failed). No screenshots needed/taken.## Open items1. hl:web (Anton/Arachne): security headers on pages (CSP incl. `frame-ancestors`, nosniff, Referrer-Policy) or nginx on Byrodin as a stopgap; `Secure` cookie flag; cookie-less requests must not mint session files; Origin check on emit/ws; session rotation in faces.2. `searchWeb` is an anonymous endpoint that makes one TMDB search per call — consider a global budget (kept open: a global cap lets a flood deny search to everyone).3. The login budget keys on `X-Client-IP` (tracker.conf on Byrodin sets it); without a proxy header all callers share one key ('direct').4. Adult titles stay followers-only; an existing follower who unfollows can no longer refollow by slug (by design now).
Branches
Latest commits
- d2e6d26bMerge branch 'records-park55' into mainTracker
- f567f025|||PR records: park #55, no Claude workers ruleTracker
- c21aff6bMerge branch 'records-hm55c' into mainTracker
- 9ba258d3|||PR records: HM55b resultTracker
- 64f2d300Merge branch 'records-hm55b2' into mainTracker
- ae3b80dc|||PR records: HM55b briefTracker
- 7ef3cb3bMerge branch 'records-st55' into mainTracker
- fec2e080|||PR records: STATUS HM55Tracker
- 8e174918Merge branch 'records-hm55b' into mainTracker
- b1ecee57|||PR records: HM55 stateTracker
- 28eab08cMerge branch 'records-hm55' into mainTracker
- d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
- 3059f86cMerge branch 'records-design-rule' into mainTracker
- 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
- d1390692Merge branch 'records-dp75b' into mainTracker
- a4d1a7d2|||PR records: later steps checked, branch auditTracker
- e070e16fMerge branch 'records-dp75' into mainTracker
- 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
- bfc4ea4dMerge branch 'ap62' into mainTracker
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker