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
- b37cc1da|||PR Vendor Hybriel day59Atlas
- 05665102Merge branch 'vendor-day56' into mainAtlas
- 687296fb|||PR Vendor Hybriel day56Atlas
- a6166d4eMerge branch 'hl-standard-3' into mainAtlas
- 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
- add4b499|||PR Make calendar day actions keyboard accessibleAtlas
- 79e49b4dMerge branch 'hl-standard' into mainAtlas
- e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas
- eff166a4Re-vendor complete Hybriel plugins and runtime to day44mre
- cef81394Wait for the DST fixture page instead of an unused socketmre
- 42434f47Check lazy-session cookies after login with a stored anonymous fixturemre
- 728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre
- cbd7ff43Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 59d1da0acalendar: plain declarations instead of needless let in 9 files (calendar#17): 49 declarations that are never reassigned; reassigned ones and the timer closure's p stay letmre
- f5415cf9calendar: the Style blocks in the language's nested form (calendar#16): rules named after the View's own elements with their children nested, pseudo-classes and @media nested, merged duplicate select rule; same CSS, shots identical in Chrome at 4 sizesmre
- edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
- bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre
- 5d8579d7README: login.js stays by caramboleyo's explicit rulemre
- cc759328Merge sb3-standby: calendar deploys through its standbymre
- f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre