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
- 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
- 3de46dacnotes: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 73+5 failing → 78 passedmre
- 5909d458notes: MdEditor from components 59704ce (text on the clipboard always pastes, a file manager copy still attaches; pipe rows without a delimiter row; tickets#49, notes#5)mre
- 98bd6a98N5b: pipe rows without a delimiter row are a table (MdEditor ad4e929, plain copy); gate tests/dashboard-table.mjs; reportmre
- dbf93319N5 report: components gate rerun 613 passed, 0 failedmre
- 3a8bc0d2N5: empty Table-button table is written as a real pipe table (MdEditor 4bd1112, plain copy); gate tests/table-button.mjs; reportmre
- c16bd443N5: step 1 report (tables pass locally; his DASHBOARD note has no delimiter row)mre
- 6091320anotes: MdEditor 7437e32 (surface drawn at once when the page is claimed); gate measures claim-to-text on 5 note loads at 1280 and 390mre
- 0aa9277enotes: move each component's styles into its own Style block (shell and header selector in main.hl, list, editor frame and delete question in notes.hl); styles.hl keeps the theme inherit, the accent and the message colour; .gitignore ignores a bin symlink too; tests/shots.mjs for the pixel comparemre
- 9ba01de3notes: write the standby service out in full so the boot gate can read the main servicemre
- 98cab40anotes: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
- 1fadb473notes gate: the editor table now has 1 px cell lines from the notes thememre
- 8762115cnotes: take the components e54f83a (paste as Markdown, text typed before the editor is built is kept, Table button); table lines come from the notes thememre
- ac23e194ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- 2804f0d3Merge branch 'iw-ident-widget'mre
- 52d8d242notes: e2e script checks Log out and the selector in the header instead of the user menumre
- 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
- 7a889b82notes: MdEditor with the Table button, typed pipe rows and the theme's table look (components mt-tables); a table note is named by its header words; gate checks that fail on mainmre
- b96c7f70theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre