gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit0c8f93640c8f9364Merge branch 'sy-sync'mre0c8f9364/reports/SC-sec.md

6.6 KB

  1. # SC — calendar security audit (branch sc-sec)
  2. Method: real HTTP against a local calendar + its own ident (tests/identkit.mjs), users Alice/Bob/Carol, `tests/security.mjs` (new gate, 58 checks).
  3. Faces are called through POST /__hl/emit (the websocket calls the same handlers). No live site touched.
  4. ## AuthZ matrix (signed out / other user / owner)
  5. | face / route | signed out | other user | owner |
  6. |---|---|---|---|
  7. | 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 |
  8. | calSettingsLoad / calSettingsSave | refused | own row only | ok |
  9. | calPushSave / calPushTest / calPushOff | refused | test/off of someone else's endpoint refused | ok |
  10. | calendarLogin (junk code) | refused | – | – |
  11. | calendarLogOut | – | – | session.user cleared; same cookie is signed out |
  12. | client events (calendarSignedIn/Out) called by a peer | no effect | – | – |
  13. | / , /login/failed, /login.js, icons | public (no user data) | | |
  14. | /login/callback | exchanges a code → new session | | |
  15. | /.env, /project.hl, /lib/*, /storage/*, /.git/*, /tools/*, traversal | 404 | | |
  16. ## Results
  17. | # | check | result | severity | fixed | test (tests/security.mjs) |
  18. |---|---|---|---|---|---|
  19. | 1 | AuthZ on all faces | no hole | – | – | 21 checks "face …" |
  20. | 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` |
  21. | 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` |
  22. | 2c | header injection via `?next=`, open redirect | safe (safePath) | – | – | `login ?next=` (2) |
  23. | 2d | path traversal / source / storage served | no | – | – | `files: …` |
  24. | 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` |
  25. | 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` |
  26. | 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` |
  27. | 4c | logout really ends the session | ok | – | – | `logout: the same cookie is signed out` |
  28. | 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` |
  29. | 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` |
  30. | 4f | CSRF on /__hl/emit & ws (no Origin check) | known hl:web gap; SameSite=Lax only | MED | n (hl:web) | printed `known:` |
  31. | 4g | login code reuse | refused | – | – | `a login code works once` |
  32. | 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` |
  33. | 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`) |
  34. | 5c | secrets in logs / errors | server logs only push status lines; error answers carry ident's `error` text + status only | – | – | – |
  35. | 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) |
  36. | 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:` |
  37. ## hl:web / Hybriel-level, stopped (repro `.scratch/SC-hlweb-gaps.md`)
  38. 1. Every first GET mints a session file (anonymous disk fill) — MEDIUM.
  39. 2. Faces get no request context, so the ident-selector face `calendarLogin` cannot be rate limited per client (hybriel#25) — LOW.
  40. 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.
  41. ## Notes
  42. - 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.
  43. - 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.
  44. - 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.
  45. - No UI change → no screenshots; the browser gate's real login (button path) passes with the session rotation.
  46. ## Gates (worktree, ports 8880–8899)
  47. | gate | new | main (old) |
  48. |---|---|---|
  49. | tests/browser.mjs | 86 passed, 0 failed | 86 passed, 0 failed |
  50. | theme/check-theme.mjs | 33 files, 0 problems | – |
  51. | tests/notify-paths.mjs | 7 passed, 0 failed, 3 Hybriel gaps | – |
  52. | tests/push.mjs | 30 passed, 0 failed | 30 passed, 0 failed |
  53. | tests/dst.mjs | 13 passed, 0 failed | – |
  54. | 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) |
  55. ## deploy.sh
  56. Add 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).
  57. ## Open
  58. - hl:web items above; CSP/XFO on pages; Origin check on emit.
  59. - face login rate limit; selector-login session fixation.

Branches

Latest commits

  • 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
  • df2e4fa0calendar#12: test push rate limit (1 per 30 s per device), owner-only gate checksmre
  • acb957cfcalendar#12: Send a test notification on a subscribed device (one push in ~10 s, owner's own device), push gate part 4mre
  • 0b222eb8tests: e2e-theme CDP port default from E2E_THEME_CDP_PORT (8756 unchanged)mre
  • 8b8a5abare-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