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
- 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
- 38cc11ecmd-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- 3e7e79f5reports/H1-hydrate.mdmre
- d98775e8tests/browser.mjs: wait for hydration before the clicks after a goto('/') (tables new note, phone sidebar)mre
- 1f3198b6tests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre