gitoria
All repositories: gitoria
5.8 KB
# SG — gitoria security audit (branch sg-sec)Method: a real local gitoria + its own ident (tests/identkit.mjs), real HTTP requests (node http, git push/clone with tokens), as signed-out /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);on sg-sec 69 passed, 0 failed. Nothing live was probed.## Table| # | check | result | severity | fixed | test (tests/security.mjs) ||---|---|---|---|---|---|| 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 || 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 || 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 …" || 2 | open redirect / header injection via `?next=` | only same-origin paths or this system's repo addresses; CRLF stays encoded | ok | – | "login ?next=" || 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" || 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 | – | – || 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:` || 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" || 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 | – || 4 | **session cookie without `Secure`** (https prod) | HttpOnly + SameSite=Lax + Domain were set; Secure was not | MEDIUM | **y** `sessionSecure = scheme == 'https'` | "cookie: Secure …" || 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" || 4 | session fixation via the selector face `gitoriaLogin` | a face cannot set a cookie | low | n (hl:web, see .scratch) | – || 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" || 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:` || 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 | – || 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 | – || 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" || 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…" || 6 | **nosniff** on function-route answers (API JSON/Markdown, redirects, /__git/*, git transport, 401) | was missing | low | **y** | "X-Content-Type-Options: nosniff — …" (7) || 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:` |hl:web items with repro: `.scratch/SG-hlweb-gaps.md` (5 items; also copied into the main repo's .scratch/).## Gates (ports 8900–8919)- before (main): browser gate 232 passed, 0 failed; check-theme 48 files, 0 problems.- after (sg-sec): browser gate 232 passed, 0 failed (same count); check-theme 48 files, 0 problems; security gate 69 passed, 0 failed.- 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.## Open items1. hl:web: 404 reflected XSS (HIGH), page security headers, Origin check on emit/WebSocket, face-level session rotation, upload caps (Anton/Arachne).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).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
- fe209ffeMerge branch 'w56-owner-members' into mainGitoria
- fa0754c8|||PR repository owner transfer and members API (#55)mre
- 8862e537Merge branch 'w55-rename-org' into mainGitoria
- 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
- 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
- 499f25f2Review fixes for the Settings organization move (#53)mre
- ed3b922b|||PR move a repository into an organization in Settings (#53)mre
- 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
- 9f7ce8d8Preserve rename compatibility and live page titlesmre
- c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
- ce08920dMerge branch 'w52c-header-phone' into mainGitoria
- 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
- e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
- c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
- 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
- 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
- 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
- 155861f6Merge branch 'w52-person-approval' into mainGitoria
- b5435de8|||PR person approvals: second Kunibert round (#52)mre
- 3a8b2fb8|||PR person approvals: Kunibert review fixes (#52)mre