gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite5abf7b7e5abf7b7notes header: the selector alone top right plus Log out as before the theme missions; the user icon is gonemree5abf7b7/reports/SN-sec.md

4.9 KB

  1. # SN — notes security audit (branch sn-sec)
  2. Method: real HTTP against a real local notes + throw-away ident (`tests/security.mjs`, ports 8860–8862 + ident), plus a real headless Chrome (390×844 touch DPR 3, 1280×800, ports 8870–8879) for the Markdown render. Test data only.
  3. ## Routes / faces (who may → result), all verified by the gate
  4. | route / face | signed out | other user | owner |
  5. |---|---|---|---|
  6. | GET /api/me | `{user:null}` | own opaque id | own opaque id (no identity/email) |
  7. | GET /api/notes | 401 | own list only | list |
  8. | GET /api/notes?id= | 401 | 404 | note |
  9. | POST /api/notes save | 401 | naming A's id → makes a note of their own, A's unchanged | saves |
  10. | POST /api/notes delete | 401 | A's note kept | deletes |
  11. | face notesPut / notesDrop | nothing stored/deleted | same, A's note unchanged | works |
  12. | face notesPull | `{login:true}` | own notes only | own notes |
  13. | face notesLogin | junk code refused | junk refused | — |
  14. | notesChanged / notesSignedIn / notesSignedOut / UI events as faces | refused (value undefined) | | |
  15. | pages `/`, `/note/:id` | no note text | no foreign note text | own |
  16. | /login/callback, /login/failed, /login.js, icons | public by design | | |
  17. ## Findings
  18. | # | check | result | sev | fixed | test (tests/security.mjs) |
  19. |---|---|---|---|---|---|
  20. | 1 | AuthZ every route/API/face | no hole found | – | – | 35 checks |
  21. | 2 | Injection: seed `</script>`, subjects, markdown `javascript:`, `<img onerror>`, ?next= (open redirect, CR/LF), file paths, SSRF | clean (editor drops javascript: hrefs; ident exchange URL is config, code is hex-only) | – | – | seed/HTML/links/next/files checks + 6 real-Chrome checks (regression guards; they also pass on old code) |
  22. | 3 | POST /api/notes CSRF (any Origin, `text/plain` form body accepted; SameSite=Lax only guard, sibling subdomains are same-site) | real | low–med | y: foreign `Origin` → 403, non-JSON content type → 415 | "another Origin … 403", "text/plain … 415" (fail on old) |
  23. | 4 | Session fixation: `/login/callback` signed the login into the cookie the visitor already had | real | med | y: new session at every login (old one logged out), as gitoria | "login rotates the session id", "pre-login cookie does not act as the user" (fail on old) |
  24. | 5 | Cookie not `Secure` behind https | real | med | y: `sessionSecure` from NOTES_PUBLIC_URL | "cookie: Secure when public address is https" (fails on old) |
  25. | 6 | `/__hl/upload` open to anyone (900 MB accepted into memory) — notes takes no file | real | med | y: `uploadMax = 0` (as gitoria/ident) | "/__hl/upload … 413" (fails on old) |
  26. | 7 | No rate limit on /login/callback (each try = a server-side ident exchange) | real | low | y: 30 tries / 10 min per `X-Client-IP` (no header = one bucket) → 429, `lib/ratelimit.hl` | "flood of wrong codes is rate limited" (fails on old) |
  27. | 8 | JSON/redirect answers lacked `X-Content-Type-Options: nosniff` | real | low | y (/api/*, /login/callback) | 3 nosniff checks (fail on old) |
  28. | 9 | face notesPut/notesDrop with a non-object payload → 500 whose text names source path/line | real | low | y: payload type checked | "junk payloads … no crash" (fails on old) |
  29. | 10 | Logout: same cookie signed out in API and faces; login tag now also cleared | ok | – | y (tag) | "logout …" |
  30. | 11 | Secrets: pages, seeds, served modules, server log hold no app secret / session id / identity | clean | – | – | secrets checks |
  31. | 12 | Git history: no .env/db/secret; one anonymous (user null) session file in `.scratch/f2-mdvalue/.sessions` in commit a916ec5 | info, harmless | info | n (history rewrite not mine) | – |
  32. | 13 | Login CSRF: `/login/callback?ident_code=<attacker's code>` signs a victim into the attacker's account (needs ident round-trip `state`) | real, open | low | **n** | – |
  33. | 14 | Face `notesLogin` (selector path) has no rate limit: a face gets no request, no IP | open | low | **n** | – |
  34. ## hl:web / Hybriel level (known, Arachne; they apply here)
  35. Page answers carry no CSP / X-Content-Type-Options / X-Frame-Options / Referrer-Policy (no hook); 404 page reflects the path as HTML (XSS); `/__hl/emit` and ws have no Origin check (faces are CSRF-able by a same-site page; #3 fix only covers /api/notes); face session rotation (face `notesLogin` still logs into the existing session — callback path fixed). Printed as `known:` lines by the gate, not counted.
  36. ## Gates
  37. - `node tests/security.mjs` NEW: new code 76 passed, 0 failed; same file on old code (main): 59 passed, 11 FAIL (findings 3–9). Env: NOTES_SEC_PORT (8860), NOTES_SEC_PORT2 (8862), NOTES_SEC_IDENT_PORT (8861), NOTES_SEC_CHROME (8870-8879). **Atlas: add `"node tests/security.mjs"` to deploy.sh GATES and these env names to deploy-init.sh (notes line).**
  38. - `node tests/browser.mjs`: 75 passed, 0 failed (old 75/0, same). `theme/check-theme.mjs .`: 23 files, 0 problems.
  39. ## Open items
  40. #13 (login CSRF, needs ident `state` through the return URL → ident/Anton), #14, hl:web items above, and a CSP once hl:web has a header hook.

Branches

Latest commits

  • e5abf7b7notes header: the selector alone top right plus Log out as before the theme missions; the user icon is gonemre
  • a2e343aeident 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
  • b96c7f70theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 6140e6a0sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • cb7e6469deploy: security gate (tests/security.mjs)mre
  • 774bf34bnotes security: CSRF guard on /api/notes, new session at login, Secure cookie, uploadMax 0, login rate limit, nosniff, face payload check; tests/security.mjs; SN reportmre
  • ef18a68fsync components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
  • c37488b1MN report: alignment updatemre
  • 4fb35a0enotes mobile: Delete note and the delete row exactly on the editor's edges; gate asserts 1 pxmre
  • 91736270MN report and logmre
  • 15667425notes: delete confirmation buttons at most 12rem wide on the desktopmre
  • 8f7a6a95gate: MN phone checks (list header gutter, back gap, delete question)mre
  • 90c73ed3notes mobile: back link gapmre
  • 72bd4f83notes mobile: list header on the gutter, delete confirmation as a question + two equal buttons, Delete note under the editor edgemre
  • ba1e73f8notes: a sent edit is done once the server's version is not older, so a second writer's text shows in the first tab; gate: two writers both waysmre
  • c69ef9ebsync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 2eb783f5sync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
  • 4dd46dadsync-components: copy icons/icons.hl + README (F4); testsmre
  • c92e4a0ftests/e2e-outside.mjs: real-Chrome E2E, a note pushed from another device while open, then typingmre
  • 0516b4ccmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre