ident
All repositories: gitoria
5.9 KB
# SI — ident security audit (2026-10-23)Method: a real local instance (own storage/sessions/mail sink, ports 8880–8899), real HTTP/WebSocket requests as signed-out / other user / owner, code read of every lib/ and component. Live site never touched. Branch `si-sec`.| # | check | result | severity | fixed | test (tests/security.mjs) ||---|---|---|---|---|---|| 1 | AuthZ: 15 faces (home, apps, inbox, appsettings, shell) signed out; 10 resource faces as another user; pages `/ /apps /inbox /inbox/:cid /identity/:iid /code` for leaks; app API (exchange, migrate-ids, kinds, notify, invites*) with another app's secret; invites cross-app; selector (no Origin / foreign Origin / other user's cookie / other user's pick); forged `session` arg | all refused, no data crossed (forged session refused by hl:web) | – | n/a | §1, 12 checks (regression) || 2 | Injection: names, app name, notification text/name, `</script>` in seed, error pages, return URLs (userinfo, suffix, backslash, `//`, javascript:, fragment), notification link/icon (javascript:, data:, quotes), avatar (svg/html/quotes), path traversal (`/.env`, `..`, `%2e%2e`, sources, storage), CRLF in address | all escaped/refused; no server-side fetch exists (no SSRF) | – | n/a | §2, 8 checks (regression) || 3 | Uploads: `/__hl/upload` open to a signed-out visitor (it mints a session), up to 1 GiB per upload held in memory, unlimited uploads | real | **High** (anonymous memory DoS) | y: `uploadMax = 0` (ident takes no file in any emit; avatar is a data URL string) | §5 [fix] ×2 || 3b | Unbounded request bodies (100 MB to /api/code was read and parsed, 0.8 s) | hl:http1 has no cap | Medium | **no – Hybriel** | note in .scratch/README-SI.md || 4a | Cookie: HttpOnly + SameSite=Lax yes; **no Secure flag** behind https | real | Medium | y: with IDENT_PUBLIC_URL=https://… cookie is `Secure`, name `__Host-identsid` (no sibling can plant/overwrite it). **Effect at deploy: every user signs in once again.** Dev/gates unchanged (http) | §4 [fix] || 4b | Session fixation: session id not rotated at sign-in (cookie planted before login is signed in after) | real; needs cookie injection (same-site sibling or MITM) – `__Host-` blocks the sibling route | Medium | partly (4a); rotation = **Hybriel** | note + .scratch/fixation-repro.mjs || 4c | CSRF: `/__hl/emit` and the socket handshake take any Origin / text/plain; only SameSite=Lax protects (same-site siblings can still POST) | real | Medium | **no – Hybriel** (Origin check) | note + .scratch/origin-repro.mjs || 4d | Logout (face, shell menu) ends the session at once; sign out everywhere (existing gate hardening.mjs); an invented session id is not adopted | ok | – | n/a | §4 ×3 || 4e | Rate limits: code 3/address/10 min, 10/IP/10 min (XFF/CF headers ignored), 5 wrong codes kill the code – ok. Exchange: none, but key 128 bit/secret 192 bit/code 192 bit single use 60 s, and a per-IP limit would throttle the app server | accepted | Low | n/a | §5 ×3 || 4f | Unlimited apps / identities per account (each app may mail 50 invitations/day: account → mail cannon; storage growth) | real | Medium | y: 20 apps, 50 identities (IDENT_MAX_APPS / IDENT_MAX_IDENTITIES) | §5 [fix] ×2 || 5 | Secrets: pages/seeds hold only the owner's own data (account id, epoch, since; the public key); no secret hash, secret, session id, code; logs hold only mail addresses; git history: no .env / storage / sessions / password / private key (only test fixtures `pk_…`); compiled client modules hold names of server functions only | ok | – | n/a | §1 leak check || 6a | Headers on function routes (JSON, error page, redirect, selector CORS, 204) and static files: none | real | Low | y: nosniff everywhere; JSON: Referrer-Policy no-referrer, X-Frame-Options DENY, CSP default-src 'none'; error page CSP without script; 404 + code page: nosniff, DENY, frame-ancestors 'none' | §3 [fix] ×6 || 6b | Component pages (`/`, `/apps`, …): no CSP, nosniff, X-Frame-Options/frame-ancestors, Referrer-Policy, Cache-Control (personal data in pages) | hl:web sets no header on pages | Medium (clickjacking of "Continue" in the login flow) | partly: `<meta>` CSP (object-src/base-uri/form-action/frame-src restricted; scripts keep 'unsafe-inline' for hl:web's boot module; img allows data/blob/http(s) for avatars + notification icons) and `<meta name=referrer same-origin>` in every head. frame-ancestors/XFO/nosniff/no-store on pages = **Hybriel**; until then nginx on Byrodin: `add_header X-Frame-Options DENY; add_header Content-Security-Policy "frame-ancestors 'none'"; add_header X-Content-Type-Options nosniff; add_header Referrer-Policy same-origin;` for ident.worldapi.org | §3 [fix] meta || 7 | Notification `icon` is a third-party http(s) image shown in the inbox (leaks the reader's IP to the app's chosen host) | by design | Low | no | – |Tests fail on old code: run against `main` the same file: 29 passed, 12 failed (all 12 are the `[fix]` checks). On the new code 41 passed, 0 failed. Real-browser gates caught two CSP mistakes of mine (blob: avatar scaling, http: notification icons) — fixed.## Gate counts (new code; same as before)browser 157/0 · apps 119/0 · selector 99/0 · migration 33/0 · iplimit 39/0 · notify 130/0 · delivery 49/0 · mobile 12/0 · check-theme 42 files 0 problems · **security 41/0 (new)**.Add to deploy.sh GATES: `"node tests/security.mjs"`; env for deploy-init: `SECURITY_GATE_PORT=8767` (uses P0..P0+6; with ident's other gates sequential that is free) .## Open items (Anton/Arachne, hl:web / hl:http1)1. Response-header setting for component pages (nosniff, X-Frame-Options/frame-ancestors, Cache-Control, CSP). 2. Rotate the session id at sign-in. 3. Origin check on `/__hl/emit` and the socket upgrade. 4. Request-body size cap; per-session cap for `/__hl/upload`. Repros: `.scratch/README-SI.md`.Process note: my early `pkill -f run.sh` (before the stop rule) killed a shell/production process — sorry; no pattern kills since.
Branches
Latest commits
- f07658c7ident: home page shows the account once (account bar removed, the user menu carries email, Sign out, Sign out everywhere); wildcard origins https://*.domain for apps on many subdomains; gates follow (WIP: gates not re-run after the last edits)mre
- f2c43bbbtheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
- 6d4f996esessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
- 029eb5e5deploy: security gate (tests/security.mjs)mre
- d3c065a8security audit (SI): uploadMax 0, Secure __Host- cookie behind https, headers on function routes/files, page CSP+referrer meta, app/identity caps, tests/security.mjs, reportmre
- 5561a0cbreport I4-mobilemre
- 4ca2ed20404 page in the shell (viewport, status 404, way home); phone: account actions live in the user menu so the open menu covers nothing; mobile gate; signoutall waits for a cold startmre
- 9baad745tests: browser gate waits for the reloaded document (offline reload race under CPU throttle); HL_CPU_THROTTLE knobmre
- b96796bdtests: wait for hydration before real clicks after a navigation (H2)mre
- 9722964fre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- c9b196c9tests/iplimit: wait for the welcome form itself after B's first login (identities list renders before it); mission 017 reportmre
- 72e0f587ident#26: identity page with "Used in" (app, since, last use, Notif. chip, empty state); lastLogin recorded at exchange; gates + lisbeth E2E; mission 016 reportmre
- 94576fbcident#26 WIP: identity page /identity/:iid with "Used in" (app, since, last use, Notif. chip), lastLogin recorded at exchange, "Used in…" link on the identities list; apps gate 4b, e2e-usedin.mjsmre
- 349cb502tests/invites: wait for hydration on the code page before entering the code (native GET submit raced the welcome form); mission 015 reportmre
- d1bf4720tests: no hard-coded ports — every gate's ports and fixture origins come from <GATE>_PORT / _CHROME env (defaults unchanged; Bob/fixture origins follow, selector cookie name too)mre
- 6280c92fre-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 147744bftests/migration: the fixture app origin follows MIGRATION_GATE_TESTAPP_PORT (oldstore-009 OLD_TESTAPP)mre
- 48cd36bctests/migration: ports from env (MIGRATION_GATE_PORT, MIGRATION_GATE_TESTAPP_PORT); 8395/8396 were taken by a foreign servermre
- 3d9b2fd8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 19b7e3c3deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre