calendar
All repositories: gitoria
6.6 KB
# SC — calendar security audit (branch sc-sec)Method: real HTTP against a local calendar + its own ident (tests/identkit.mjs), users Alice/Bob/Carol, `tests/security.mjs` (new gate, 58 checks).Faces are called through POST /__hl/emit (the websocket calls the same handlers). No live site touched.## AuthZ matrix (signed out / other user / owner)| face / route | signed out | other user | owner ||---|---|---|---|| calLoad / calSave / calSaveQueued / calDelete | refused (error, nothing leaks) | sees nothing; change/delete by id and by `local-…` ref → "no such event" / own new event | ok || calSettingsLoad / calSettingsSave | refused | own row only | ok || calPushSave / calPushTest / calPushOff | refused | test/off of someone else's endpoint refused | ok || calendarLogin (junk code) | refused | – | – || calendarLogOut | – | – | session.user cleared; same cookie is signed out || client events (calendarSignedIn/Out) called by a peer | no effect | – | – || / , /login/failed, /login.js, icons | public (no user data) | | || /login/callback | exchanges a code → new session | | || /.env, /project.hl, /lib/*, /storage/*, /.git/*, /tools/*, traversal | 404 | | |## Results| # | check | result | severity | fixed | test (tests/security.mjs) ||---|---|---|---|---|---|| 1 | AuthZ on all faces | no hole | – | – | 21 checks "face …" || 2a | push endpoint = server-side POST target: any https URL incl. 127.0.0.1, localhost, 10.x, 169.254.169.254, [::1], decimal/hex IPs, userinfo, any port (blind SSRF) | BUG | MEDIUM | y (lib/push-guard.hl, 1 line in lib/push.hl) | `face calPushSave: no internal / IP-literal / non-443 / userinfo endpoint`, `a real push service address is still accepted` || 2b | XSS: title/place/notes/URLs rendered as HTML | none (hl:web escapes; no markdown, no user hrefs, no filenames); page seed cannot close script | – | – | `page: no event text lands as HTML`, `seed cannot close its script tag` || 2c | header injection via `?next=`, open redirect | safe (safePath) | – | – | `login ?next=` (2) || 2d | path traversal / source / storage served | no | – | – | `files: …` || 3 | uploads: /__hl/upload open to anyone, 900 MB announced by a signed-out visitor, held in memory | BUG | MEDIUM | y (`uploadMax = 0`, no face takes a file) | `/__hl/upload … → 413` || 4a | cookie flags | HttpOnly, SameSite=Lax, Path=/, Max-Age 14 d ok; **no Secure** behind https | LOW-MED | y (`sessionSecure` from CALENDAR_PUBLIC_URL) | `cookie: Secure when the public address is https` || 4b | session fixation on /login/callback (login kept the cookie's session id) | BUG | LOW-MED | y (new session per login, old one logged out) | `login rotates the session id`, `the pre-login cookie does not act as the user` || 4c | logout really ends the session | ok | – | – | `logout: the same cookie is signed out` || 4d | no rate limit on /login/callback (each call = outbound exchange to ident, 10 s timeout) | BUG | LOW | y per X-Client-IP (lib/login-limit.hl, 20 / 10 min, env CALENDAR_LOGIN_LIMIT/WINDOW) | `/login/callback is rate limited per client`, `another client is not limited` || 4e | unlimited events per user (disk fill by a signed-in user) | BUG | LOW | y (maxEvents 20000, CALENDAR_MAX_EVENTS) | `events per user are capped` || 4f | CSRF on /__hl/emit & ws (no Origin check) | known hl:web gap; SameSite=Lax only | MED | n (hl:web) | printed `known:` || 4g | login code reuse | refused | – | – | `a login code works once` || 5 | secrets in pages, page seed, client modules, sw, manifest (VAPID private key, ident secret, session id, identity) | none | – | – | `pages, client modules, service worker hold no secret` || 5b | secrets in git history of the repo | none found (only names of env vars and generated test keys); .env/storage/.sessions ignored and never tracked | – | – | (manual grep of `git log --all -p`) || 5c | secrets in logs / errors | server logs only push status lines; error answers carry ident's `error` text + status only | – | – | – || 6 | headers: function + file routes had no nosniff | LOW | y (nosniff on /login/callback, /login.js, icons; Referrer-Policy no-referrer on callback) | `X-Content-Type-Options: nosniff — …` (5) || 6b | CSP, X-Frame-Options/frame-ancestors, Referrer-Policy, nosniff on **pages**, 404 reflected XSS | known hl:web gaps | MED/HIGH | n (hl:web) | printed `known:` |## hl:web / Hybriel-level, stopped (repro `.scratch/SC-hlweb-gaps.md`)1. Every first GET mints a session file (anonymous disk fill) — MEDIUM.2. Faces get no request context, so the ident-selector face `calendarLogin` cannot be rate limited per client (hybriel#25) — LOW.Known and not re-reported: 404 XSS, no page-header hook, emit/ws Origin, face session rotate (the selector-login face keeps the cookie's session id — fixation remains on that path), upload/body caps.## Notes- lib/push.hl was touched (SECURITY FIX only): +1 import, +1 line in savePush; the guard lives in the new lib/push-guard.hl so a merge with p1-twice stays trivial. Behaviour for real push services (fcm.googleapis.com, updates.push.services.mozilla.com, *.push.apple.com, *.notify.windows.com) unchanged (checked). The gates' fake push service (http, CALENDAR_PUSH_ALLOW_HTTP=1) still works.- Residual: a public NAME whose DNS points inside is not caught (no resolver in hl). Per-IP limit needs nginx to send X-Client-IP on the calendar vhost (Atlas: confirm; without it all clients share the 'direct' bucket of 20 / 10 min). IPv6 is bucketed per address, not /64.- Deploy: `sessionSecure` makes the cookie Secure: live CALENDAR_PUBLIC_URL must be https://calendar.worldapi.org (default is). Existing sessions keep working. A new `storage/mpackdb/logins.db` appears.- No UI change → no screenshots; the browser gate's real login (button path) passes with the session rotation.## Gates (worktree, ports 8880–8899)| gate | new | main (old) ||---|---|---|| tests/browser.mjs | 86 passed, 0 failed | 86 passed, 0 failed || theme/check-theme.mjs | 33 files, 0 problems | – || tests/notify-paths.mjs | 7 passed, 0 failed, 3 Hybriel gaps | – || tests/push.mjs | 30 passed, 0 failed | 30 passed, 0 failed || tests/dst.mjs | 13 passed, 0 failed | – || tests/security.mjs (NEW) | 58 passed, 0 failed | 45 passed, **13 failed** (SSRF ×2, event cap, Secure cookie, session rotation ×2, rate limit, upload, nosniff ×5) |## deploy.shAdd to GATES: `"node tests/security.mjs" # ports: CALENDAR_SEC_PORT (app; +1 https app; +2 ident), CALENDAR_SEC_SCRATCH` and in deploy-init.sh calendar env: `CALENDAR_SEC_PORT=8767` (uses 8767–8769, no Chrome).## Open- hl:web items above; CSP/XFO on pages; Origin check on emit.- face login rate limit; selector-login session fixation.
Branches
Latest commits
- 490c658aident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- 18095868calendar: Reminder settings button opens its dialog again (the dialog's open handler still closed the removed user menu and stopped); old e2e and gate scripts use the new headermre
- 6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre
- 0b909decident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- 0c8f9364Merge branch 'sy-sync'mre
- 9fab1c8fsync components.hybriel 4922f9c into the month view: prev / next 44 px targets, names formatted in UTC (a UTC+12 zone showed the wrong first weekday); the calendar keeps its own language handling (Accept-Language / browser) and the P1/C13 reminder code; gate: 44 px check (SY)mre
- 27d3e294theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
- 2ac9c1bbdeploy: security gate (tests/security.mjs)mre
- 6b0a2571merge sc-sec (calendar security) with 99-year sessionsmre
- 92001e52sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
- 0f76c99dSecurity audit SC: push endpoint SSRF guard, uploadMax 0, Secure cookie, login session rotation + rate limit, event cap, nosniff, security gatemre
- 2dd53dccP1: one reminder shows once: arm() one at a time, the page skips reminders the server already pushed; push-twice gatemre
- 3a29760aC13 report (handoff)mre
- 33ab66ffCalendar: notification controls move from the month view into Reminder settings (user menu), one consistent state, state read when the dialog opensmre
- 682a5b43reports: calendar gate countsmre
- 876d22b2reports/H1-hydrate.mdmre
- ef0cae45tests/dst.mjs: wait for hydration instead of a fixed 2.5 s sleep before clicking #gomre
- d9cadecatests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- efa61227re-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
- 7808adbecalendar#12: report 011, LOG, STATUS, push-shots-testmre