gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf04afc43f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mref04afc43/reports/ST-sec.md

6.3 KB

  1. # ST — tickets security audit (2026-10-23)
  2. Method: a real local instance (own store, ident stub, ports 8840–8859), real HTTP (fetch), page faces via POST /__hl/emit, real headless Chrome (390×844 touch DPR 3 and 1280×800). Users: alice (admin sa), bob (use), carol (admin sc, none in sa), dave, signed out. Live site never touched. Branch `st-sec`. Gate: `tests/security.mjs` (~300 checks).
  3. Reads are public by design (tickets, projects, history, events); attachments are members-only.
  4. | # | check | result | severity | fixed | test (tests/security.mjs) |
  5. |---|---|---|---|---|---|
  6. | 1a | AuthZ signed out: 17 write routes → 401; /api/inbox, /api/events, attachments 401; 19 faces refused | ok | – | n/a | §1 |
  7. | 1b | AuthZ outsider / role `use`: every write route and face (ticket, comment, state, edit, assign, members, invites, settings, connections) 403; bob may comment + like only; comment edit/delete author-only; others' token revoke refused; forged `session` arg refused | ok | – | n/a | §1b/1c |
  8. | 1c | **Relations across projects**: `mayLink` wanted edit in EITHER ticket's project, so a member of any project could set a parent / blocker on (and write a history event into) a ticket of a project where they have no role, e.g. block someone else's ticket | real | **Medium** | y: edit/admin needed in the project of the ticket whose relation changes (README + messages updated) | "authz relations" ×8 [fix] |
  9. | 2a | Injection: subject/summary/comment/project title/connect label with `<img onerror>`, `<script>`, `javascript:` / `data:` links → text only (real Chrome: nothing ran, no javascript:/data: href, https link has noopener noreferrer); filenames (`../`, CRLF, quotes) cleaned, headers clean; connect return URL (userinfo, suffix, `\`, `#`, `//`, javascript:); login `next=` (open redirect, CRLF); traversal (`..`, `%2e%2e`, `.env`, sources, storage); no SSRF (only fetch is the configured ident) | ok | – | n/a | §2, §7 |
  10. | 2b | Connect return host accepted `%` (`evil.com%2F.worldapi.org`; browsers reject it, still wrong) | real | Low | y | "inject connect return" |
  11. | 2c | A subject could hold line breaks / control chars (`## injected` line in the Markdown view that programs read) | real | Low | y: `oneLine` on create + edit | "inject [fix ST]" ×3 |
  12. | 3a | Uploads: 10 MiB/file → 413, 11 files → 400, 27 MB → 413, empty → 400, content decides type (HTML/SVG named .png refused; svg/html/txt served as download), nosniff + sandbox CSP + CORP + private cache, only members (cookie, token) fetch | ok | – | n/a | §3 |
  13. | 3b | **5 MB JSON body (any token holder) froze the single-threaded server for 18+ min at 100 % CPU** (jsoncheck.hl walks it character by character) | real | **High** (DoS) | y: JSON body > 1 MiB → 413 before it is read (`maxJsonBytes`) | "limits [fix ST]" ×2 |
  14. | 3c | `/__hl/upload` over uploadMax answers 500; no body cap in hl:http1 | hl:web/http1 | Medium | no – Arachne (known) | note |
  15. | 4a | Cookie `hlsid`: HttpOnly + SameSite=Lax, **no Secure**, default name shared with sibling hosts' fixation | real | Medium | y: `ticketssid`; behind https `__Host-ticketssid` + Secure (TICKETS_PUBLIC_URL). **At deploy every browser signs in once again; API tokens/keys unaffected** | "cookie [fix ST]" |
  16. | 4b | **Session fixation** in /login/callback (cookie planted before login became the signed-in one) | real | Medium | y: new session per login, old one logged out (as gitoria SG). Face `identLogin` rotation = hl:web (known) | browser.mjs "login (ST)", security "session fixation" ×2 |
  17. | 4c | CSRF: JSON API takes only bearer tokens (cookie ignored, 401); faces/ws Origin check = hl:web (known) | ok / known | – | n/a | §4 |
  18. | 4d | Logout kills the cookie session (youData null, faces refused); tokens live until revoked on /you | ok | – | n/a | §4 |
  19. | 4e | Rate limits: none on /login/callback (ident code single use), /api/connect/exchange (192-bit code). **`/connect` (open to anyone) added a stored row per call, forever** | real | Low–Medium | y: expired requests dropped, max 300 waiting → 429 | "limits [fix ST]" |
  20. | 4f | Every first visit mints a session file (anonymous disk growth) | hl:web | Low | no – Arachne | note |
  21. | 5 | Secrets: pages/seeds/JSON hold no secret, token, hash, identity id of others (only /you shows own); log has none; ident key `pk_` is public; git history: no .env/storage/sessions/real keys (test fixtures only — checked by pattern, nothing printed) | ok | – | n/a | §5 |
  22. | 6a | Headers on function routes (JSON, markdown, 401, redirects, error pages, 404s): none | real | Low | y: nosniff, X-Frame-Options DENY, Referrer-Policy no-referrer, CSP default-src 'none'; inbox no-store | "headers [fix ST]" ×5 |
  23. | 6b | Pages: no CSP / nosniff / XFO / frame-ancestors / Referrer-Policy from hl:web (Arachne w115 hook pending) | hl:web | Medium (clickjacking) | partly: CSP `<meta>` (object/base/frame/form restricted; script/connect allow IDENT_URL for selector.js) + referrer meta; real Chrome: no CSP violation, attachment pictures load. frame-ancestors/XFO = hl:web or nginx | "page [fix ST]", §7; strict notes with SEC_STRICT=1 |
  24. | 6c | `/api/events` answers `Access-Control-Allow-Origin: *` (hl:http1 native SSE); bearer-only, no credentials | accepted | Info | n/a | "cors" |
  25. Old code on the same file: 201 passed, 13 failed + crash at the 5 MB body (server wedged). New: see below.
  26. ## Gate counts (new code)
  27. security (new) 300 passed + 2 stub-only (selector.js 404 from the ident stub, filtered afterwards, not re-run: quota) · browser 406/0 (MT 405 + 1) · events 52/0 · check-theme 46 files 0 problems.
  28. Test edits forced by the cookie name / rotation: `hlsid`→`ticketssid` in browser/events/e2e-*/realdata tests; browser.mjs follows the rotated cookie.
  29. **deploy.sh**: add `"node tests/security.mjs"` to GATES. Env for deploy-init: `TICKETS_SEC_PORT=8767` (uses P, P+1 ident stub, P+2 https server), `TICKETS_SEC_CHROME=8770-8774` (default 8855-8859).
  30. ## Open items
  31. 1. hl:web: page response headers (frame-ancestors, nosniff, XFO), Origin check on emit/ws, face-level session rotation, upload/body caps, 500 on oversize /__hl/upload, anonymous session minting (Arachne w115 pending re-vendor). 2. No per-IP rate limit on login callback / exchange (nginx). 3. No length cap on subject/summary/comment text beyond 1 MiB body. 4. API tokens never expire; unlimited projects/tokens per user. 5. Login CSRF via the ident code (low, as gitoria). 6. Page seeds list `file.hl:line` site markers (hl:web).

Branches

Latest commits

  • f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
  • 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
  • 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
  • 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre
  • 8a69999cident#28: /login/callback never signs out the session it finds; a valid code puts the user on the same sessionmre
  • 337e9b21tickets#37: a comment's files are open to everyone who can read the commentmre
  • 1800600ftickets: write the standby service out in full so the boot gate can read the main servicemre
  • 8179d287tickets: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
  • 0398145ctickets: the table grid rule is marked functional for check-thememre
  • 40fddc20tickets takes components e54f83a: tables get thin grey lines from the theme, desktop toolbar stays one row with the Table button, F4 check counts 11 buttonsmre
  • c1b77d61tickets#35: text typed before the editor is built is taken in once by the build (the input handler no longer writes it to the field first, which doubled the first letters); the gate failure shows the surfacemre
  • 32bf1873tickets#35: the gate types right after the load with the CPU slowed, no waitingmre
  • 64ea9ca2tickets#35: text typed into the reply editor before the page has finished starting is kept; the gate types right after loadmre
  • ccd3a327tickets: the security gate expects frame-src to be exactly the ident address (the sign-in frame), still no wildcard or selfmre
  • 4348dbabident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • 66ef3005Merge branch 'iw-ident-widget'mre
  • bc0ad663tickets: a gap between your name and Log out in the phone header (they touched); gate checks itmre
  • 2f818d46UX2: report, LOG line, e2e fixes, gate pause after loadmre
  • af3ef7c4gate: the legacy state line says progressmre
  • 62480a00tickets#33: a state change with a note is a comment card in the feed (same framework rendering, can be liked, edited, deleted), its state line stands alone; gate checks for a new comment with and without a state change, at once and after a reloadmre