gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchnotes17-ghost-noteae1075b2Preserve rejected drafts during note ID adoptionAtlasnotes17-ghost-note/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

  • ae1075b2Preserve rejected drafts during note ID adoptionAtlas
  • 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
  • 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
  • 649cef37|||PR Vendor Hybriel day56Atlas
  • aadd0abcMerge branch 'hl-standard-2' into mainAtlas
  • 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
  • 617ee8c0Merge branch 'hl-standard' into mainAtlas
  • 452458ee|||PR Type the function parameters of notes' own .hl files (HL-STANDARD L10)Atlas
  • 23758cd6Re-vendor complete Hybriel plugins and runtime to day44mre
  • 5d7cc700Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 3e07b1cfVendor complete Hybriel day39 plugin sources and librariesmre
  • d7366702Check session cookie flags after login and assert anonymous GET stays cookielessmre
  • 16bc8fd8Re-vendor Hybriel day38b with the mpackdb store-open race fixmre
  • d860dc2dnotes#12: the markup names its own rules instead of hand-written class strings: the selected row is `aria-current="page"` (the list-first theme rule styles it, no class), the delete question is `Style.pAsk` and follows its own `open` attribute (bound to `asking`), the error line is `Style.pMessage` (body once in lib/looks.hl, rule in notes.hl, main.hl and loginfailed.hl). The CSS declarations are the same, only selectors changed (.ask -> p.ask, .ask.open -> p.ask[open], .message -> p.message); the pages look the same (AE 0 at 4 sizes). main.hl's selectorClass in/out stays (login.js reads it).mre
  • 2e7f8664notes#13: the list and back links pass the note key from the loop (emit pick(e, r.key)) instead of writing data-note into the View and reading it back with getAttribute; the two window.history.replaceState calls and the identcode e.target.value read stay (hl:web has no replace-navigation, a bound hidden input is not adopted on a script's change event), see NO13 reportmre
  • 4dc98282notes#15: a deleted note made in this tab leaves the list at once (the delete now removes this tab's edit under every key the row has: local id, server id); gate: browser.mjs notes#15 section, red on the old codemre
  • e4e7402fnotes#11: plain declarations instead of let for variables never reassigned (components/notes.hl 3, lib/jsoncheck.hl 5, lib/util.hl 2, tools/migrate-short-ids.hl 8)mre
  • 27b6a09enotes#8: Style blocks in the nested form (note-list, note-editor, .ask with their children nested, :empty as a nested pseudo-class); the same CSS rules, the pages look the samemre
  • 71a9538bnotes: B27W report, log linemre
  • 78ba0073notes: an ident access key (Authorization: Bearer idt_…) reads and writes its identity's notes through /api/me and /api/notes; gate tests/ident-access-notes.mjs (ident#27)mre