notes
All repositories: gitoria
4.9 KB
# SN — notes security audit (branch sn-sec)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.## Routes / faces (who may → result), all verified by the gate| route / face | signed out | other user | owner ||---|---|---|---|| GET /api/me | `{user:null}` | own opaque id | own opaque id (no identity/email) || GET /api/notes | 401 | own list only | list || GET /api/notes?id= | 401 | 404 | note || POST /api/notes save | 401 | naming A's id → makes a note of their own, A's unchanged | saves || POST /api/notes delete | 401 | A's note kept | deletes || face notesPut / notesDrop | nothing stored/deleted | same, A's note unchanged | works || face notesPull | `{login:true}` | own notes only | own notes || face notesLogin | junk code refused | junk refused | — || notesChanged / notesSignedIn / notesSignedOut / UI events as faces | refused (value undefined) | | || pages `/`, `/note/:id` | no note text | no foreign note text | own || /login/callback, /login/failed, /login.js, icons | public by design | | |## Findings| # | check | result | sev | fixed | test (tests/security.mjs) ||---|---|---|---|---|---|| 1 | AuthZ every route/API/face | no hole found | – | – | 35 checks || 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) || 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) || 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) || 5 | Cookie not `Secure` behind https | real | med | y: `sessionSecure` from NOTES_PUBLIC_URL | "cookie: Secure when public address is https" (fails on old) || 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) || 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) || 8 | JSON/redirect answers lacked `X-Content-Type-Options: nosniff` | real | low | y (/api/*, /login/callback) | 3 nosniff checks (fail on old) || 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) || 10 | Logout: same cookie signed out in API and faces; login tag now also cleared | ok | – | y (tag) | "logout …" || 11 | Secrets: pages, seeds, served modules, server log hold no app secret / session id / identity | clean | – | – | secrets checks || 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) | – || 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** | – || 14 | Face `notesLogin` (selector path) has no rate limit: a face gets no request, no IP | open | low | **n** | – |## hl:web / Hybriel level (known, Arachne; they apply here)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.## Gates- `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).**- `node tests/browser.mjs`: 75 passed, 0 failed (old 75/0, same). `theme/check-theme.mjs .`: 23 files, 0 problems.## Open items#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
- c49ce093|||PR WIP remove notes polling and use framework reachabilityAtlas
- c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
- 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
- a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
- 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
- 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
- eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
- 3537cf7eMerge branch 'vendor-day59' into mainAtlas
- c13d188b|||PR Vendor Hybriel day59Atlas
- 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
- 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