gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainf9b8f918Merge branch 'calendar-vendor-day61' into mainAtlasmain/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

  • f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
  • 66341793|||PR Vendor Hybriel day61Atlas
  • 36fc596bMerge branch 'vendor-day59' into mainAtlas
  • 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