gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit03b5bb0803b5bb08W39 report to reports/, drop scratch repro, mission + logmre03b5bb08/reports/SG-sec.md

5.8 KB

  1. # SG — gitoria security audit (branch sg-sec)
  2. Method: a real local gitoria + its own ident (tests/identkit.mjs), real HTTP requests (node http, git push/clone with tokens), as signed-out /
  3. another user (bob) / owner (alice). Gate: `tests/security.mjs` (69 checks). Run on the OLD code (main) it gives 56 passed, 13 failed (the fixed items below);
  4. on sg-sec 69 passed, 0 failed. Nothing live was probed.
  5. ## Table
  6. | # | check | result | severity | fixed | test (tests/security.mjs) |
  7. |---|---|---|---|---|---|
  8. | 1 | AuthZ, 15 faces (create, token make/remove, key add/remove, set branch, disconnect tickets, merge, open ticket, save name, login/logout) | signed out and non-owner refused everywhere; owner works; client-only events cannot be called by a peer | ok | – | "face …" checks |
  9. | 1 | AuthZ routes: /api/repos* (public read, no secret field, POST 405), /settings/connect(ed) (owner only, else → /settings), /__git/keys + /__git/access (secret, no X-Forwarded-For, owner-only write), git HTTPS (push: owner's token only; clone public; receive-pack advert 401) | correct | ok | – | route + git checks |
  10. | 2 | HTML injection: description, display name, README Markdown (javascript:, data:, //evil, raw `<script>`), file / branch / commit names, seed JSON | all rendered as text; unsafe hrefs dropped; seed cannot close its script tag | ok | – | "page …", "Markdown …" |
  11. | 2 | open redirect / header injection via `?next=` | only same-origin paths or this system's repo addresses; CRLF stays encoded | ok | – | "login ?next=" |
  12. | 2 | path traversal / source exposure (.env, project.hl, lib, storage, .git, `..`, `%2e%2e`) | 404; client modules are stubs for server code, no secret | ok | – | "files:", "served client modules" |
  13. | 2 | git argument/option injection (`-rf.txt`, `<…>` names, branch names), SSRF | paths via `--literal-pathspecs`, refs from git itself, hex ids; the only server-side fetches go to the configured ident / tickets URLs (tickets `api` must start with `<tickets>/api/projects/`) | ok | – | – |
  14. | 2 | **hl:web 404 page echoes the decoded path as text/html** | reflected XSS: `/nope%3Cscript%3E…` | **HIGH** (hl:web) | **n (STOP, Hybriel)** | prints `known:` |
  15. | 3 | **/__hl/upload open to anyone** (900 MB announced by a signed-out visitor, parts kept in memory) | no face takes a file | MEDIUM | **y** `uploadMax = 0` (project.hl) | "/__hl/upload … 413" |
  16. | 3 | git push body: 500 MB cap checked after the body is read; temp files in storage/git/.tmp | only the owner can push (token); anonymous upload-pack bodies are small in practice | low, open | n | – |
  17. | 4 | **session cookie without `Secure`** (https prod) | HttpOnly + SameSite=Lax + Domain were set; Secure was not | MEDIUM | **y** `sessionSecure = scheme == 'https'` | "cookie: Secure …" |
  18. | 4 | **session fixation**: `/login/callback` reused the cookie's session | a cookie planted before the button login became the logged-in one | MEDIUM | **y** (lib/api.hl: new session per login, old one logged out) | "login rotates…", "pre-login cookie does not act" |
  19. | 4 | session fixation via the selector face `gitoriaLogin` | a face cannot set a cookie | low | n (hl:web, see .scratch) | – |
  20. | 4 | logout, code reuse, junk codes | logout ends the user of the session; a login code works once | ok | – | "logout", "a login code works once" |
  21. | 4 | CSRF | SameSite=Lax only; /__hl/emit and the WebSocket check no Origin and faces cannot read headers | low-medium (hl:web) | n | prints `known:` |
  22. | 4 | rate limits login/exchange | none in gitoria; every callback/face call causes one ident exchange (ident has its own IP limits, IDENT_IP_LIMIT); codes are one-time | low, open | n | – |
  23. | 4 | login CSRF (no `state` bound to the session in ident's button flow) | an attacker's code in a victim's browser logs the victim in as the attacker | low, open (needs an ident flow change) | n | – |
  24. | 5 | **ident identity id in the page data** of a signed-in user (`myUser` record in components/tokens.hl, sshkeys.hl — users.hl says it "never goes to a page") | own identity (public short id) in the seed of `/` | low | **y** (`userIdOfSession`, only the @id is kept) | "pages carry no secret" |
  25. | 5 | secrets in pages / seeds / modules / API / errors / git history (57 commits, patterns for ident secret, ssh secret, gtr_/tktc_/tkt_ tokens, private keys, .env, db files) | none; only test placeholders in tests | ok | – | "pages carry no secret", "served client modules…" |
  26. | 6 | **nosniff** on function-route answers (API JSON/Markdown, redirects, /__git/*, git transport, 401) | was missing | low | **y** | "X-Content-Type-Options: nosniff — …" (7) |
  27. | 6 | **CSP, X-Frame-Options/frame-ancestors, Referrer-Policy, nosniff on HTML pages** | none (hl:web has no hook for page headers; maybe nginx on Byrodin adds some — not probed) | MEDIUM (hl:web) | **n (STOP)** | prints `known:` |
  28. hl:web items with repro: `.scratch/SG-hlweb-gaps.md` (5 items; also copied into the main repo's .scratch/).
  29. ## Gates (ports 8900–8919)
  30. - before (main): browser gate 232 passed, 0 failed; check-theme 48 files, 0 problems.
  31. - after (sg-sec): browser gate 232 passed, 0 failed (same count); check-theme 48 files, 0 problems; security gate 69 passed, 0 failed.
  32. - NEW gate for deploy.sh GATES (Atlas adds it): `node tests/security.mjs` (env: GITORIA_SEC_PORT, GITORIA_SEC_PORT2, GITORIA_SEC_IDENT_PORT; deploy-init.sh suggestion: 8767, 8780 (second server), 8768). It starts two gitoria servers and one ident, no Chrome.
  33. ## Open items
  34. 1. hl:web: 404 reflected XSS (HIGH), page security headers, Origin check on emit/WebSocket, face-level session rotation, upload caps (Anton/Arachne).
  35. 2. Login CSRF (state), no gitoria-side rate limit on the exchange, anonymous git POST body is read fully before the 500 MB check, anyone with an ident name may open tickets in any connected repo (design).
  36. 3. Check on Byrodin (nginx, not probed): does it add security headers / body-size limits? If yes, the "pages" row drops to low.

Branches

Latest commits

  • 03b5bb08W39 report to reports/, drop scratch repro, mission + logmre
  • 154d333fMerge w39-create-api: POST /api/repos with a user token (#39)mre
  • 149dd512Rewrite W39 reportmre
  • e5385075Expect 401 for POST /api/repos without a tokenmre
  • 1a76055cDocument repository creation APImre
  • 4d779b3bAdd create-api gatemre
  • 88563122Add POST /api/repos for user tokensmre
  • b00860e3Create repositories with member checks in createRepoInmre
  • 0a38f236Report repository creation API blockermre
  • b5f72187Record malformed JSON blocker for repository creationmre
  • a2ae8302logmre
  • 6947cd58logmre
  • 2175e48clogmre
  • 40eb3ca1gitoria#38: review package, logmre
  • 06a5a50egitoria#38: deploy b8252ca, logmre
  • b8252ca0gitoria#46: W46b report, logmre
  • 50093aafgitoria#46: statuses keyed by app + context (merge w46b-keyed)mre
  • dd0267edgitoria#46: fix a label in the keyed gatemre
  • b1dcb580gitoria#46: statuses keyed by app + context, required = app + context, old rows still readmre
  • 2287363egitoria#47: W47 report, logmre