SPB Git

Repository Public

PLATFORM_AUDIT.md 7.9 KB

# Platform audit: SPB Git server as of 2026-12-02

Audit of the forge the iOS client talks to, done before any application code was written. Sources: the spbgit repository (HEAD 9726aff, deployed code 657d23b, version 3.2.0), the production deployment and live requests against https://git.spboucher.ai. Measurements were taken on 2026-12-02 from a residential connection in Québec.

# 1. Deployment

Item Value
Host M1M32 (Mac Studio M1, 10 cores, 32 GB), gateway of the MacLustr cluster
Process spbgit-server under PM2, node src/server.mjs, port 7420 on 127.0.0.1, max_memory_restart 2 GB
Public route Caddy on the OVH gateway (TLS) through the WireGuard tunnel to M1M32:7420
Code ~/srv/spbgit/app, a git clone whose origin is the bare repository ~/srv/git/spbgit.git
Repositories bare repositories in ~/srv/git/<name>.git: 286 on the day of the audit
State ~/srv/spbgit/data: meta.json (descriptions, topics, homepage, pinned, created, default branch), activity.jsonl (5 835 push records), clones.json, tokens.json (argon2id hashes), releases/, visitor-pass.key
Cache ~/srv/spbgit/cache: 36 830 files, 4.07 GB, validated by a stamp of ref mtimes
Resident memory about 1.25 GB, 120 MB of JS heap

Stack: Node 20+, Fastify 5, nunjucks views, zod validation, shiki highlighting, markdown-it with sanitize-html, argon2 token hashes. Every git read shells out to the git binary with execFile and argument arrays, under a global semaphore of 12 concurrent processes. No database.

# 2. What the server can do today

Domain Website JSON API (3.2.0)
Repository list and metadata yes yes: /api/v1/repos returns every repository in one response
Site statistics yes yes: /api/v1/stats (repositories, commits, languages, streaks, active days)
Directory listing yes yes: /api/v1/repos/:name/tree, one level, strong ETag
File content yes (HTML) raw bytes only: /raw/:repo/<ref>/<path> (no metadata, no paging, no Range)
README yes (HTML) no
Commit list yes yes, 30 per page, no filter, no parents
Commit detail and diff yes (HTML, prepared diff cached) no
Branches, tags yes (HTML) no; tags appear only through /releases
Releases and assets yes yes (read and write)
Blame yes (HTML) no
Repository insights yes (HTML page) no
Global metrics over time calendar on the home page only the totals of /api/v1/stats
Activity feed home page, /feed.atom no JSON
Search repositories, files, commits, branches, READMEs yes: /api/v1/search; no content (code) search
Authentication none on the website personal access tokens (spbgit_<id>_<secret>), all-or-nothing, no expiry
Writes none create, patch, soft-delete repositories; tokens; release assets; shield mode
File edits, branches, tags by git push only no
Private repositories not a concept: everything under ~/srv/git is public

Consequence for the client: reading a repository list, a tree, commits and releases is possible now; everything else the application must show (file metadata and paged content, README source, commit detail, structured diff, branches, tags, graph, metrics over time, activity, code search, owner operations) needs new API routes. Scraping the HTML pages was ruled out: fragile, expensive for the server, and classified as crawler traffic by the shield. The additions are specified in API_CONTRACT.md and implemented in spbgit 3.3.0.

# 3. The anti-scraping shield, and what it means for a native client

Since 3.2.0 every costly route (deep: file, tree, commits, commit, blame, raw, search, the tree and commits API) passes through a chain of budgets (src/lib/shield.mjs, docs/SECURITY.md in the server repository). A client without a visitor pass shares one small world-wide bucket (60 requests per minute for tools, 30 under attack). The pass is a signed cookie obtained by a SHA-256 proof of work (/pass/challenge, /pass/redeem), 16 bits normally, up to 21 under attack. On the day of the audit the shield was in attack mode at 20 bits.

A native application is a "tool" for the shield (its user agent does not start with Mozilla/). Without a pass it would be refused as soon as a few people browse at once. Decision: the application obtains a visitor pass the same way a browser does, by solving the proof of work natively with CryptoKit, keeps the cookie, renews it before expiry, and treats 429/503 with X-Spbgit-Shield as a transient state with Retry-After. It does not ask for a privileged bypass: an anonymous application build could be imitated by the very crawlers the shield stops. Only requests authenticated with an owner token are exempt (3.3.0).

Other limits a client must respect: 200 requests per minute per address on everything, 6 archive requests per minute, 5 MiB JSON bodies.

# 4. Performance measured on the public endpoints

Brotli accepted, single request, warm caches:

Request Status Bytes on the wire Time
/api/v1/stats 200 418 0.11 s
/api/v1/repos (286 repositories) 200 74 028 (777 173 uncompressed) 0.20 s to 0.51 s
/api/v1/repos/spbgit 200 1 010 0.07 s
/api/v1/repos/spbgit/tree 200 394 0.15 s
/api/v1/repos/spbgit/commits 200 8 081 0.43 s
/api/v1/search?q=fastify 200 2 926 0.29 s
/feed.atom 200 1 053 0.05 s

The repository list is small enough once compressed to be fetched whole, cached on the device and filtered locally; server-side paging is still added for future growth. About 60 % of the uncompressed list is the SVG sparkline path of each repository, which a native client does not need (compact=1 in 3.3.0). The first search after a server restart takes about 6 s (index build); the client must show progress and allow cancellation.

# 5. Risks found during the audit

Finding Effect on the client Handling
Tokens have no scope and no expiry; one bootstrap token exists an owner mode with a phone-stored token would hold full rights for ever scopes, expiry and an audit log in 3.3.0; the app asks for a dedicated, revocable token
DELETE /api/v1/repos/:name needs only the token a mistaken tap could remove a repository (soft delete, 30 days) typed confirmation in the app, X-Confirm-Name header on the server
No write API for contents an "editor" could only be simulated real commits through git plumbing with compare-and-swap on the branch tip (3.3.0)
Commit counts are per default branch totals on the dashboard are not "all commits of all branches" each metric carries its definition; the app shows the definition
Repository size is the bare repository on disk it is not a measure of source code separate codeBytes metric; never mixed in one chart
No JSON activity feed activity screen would need Atom parsing with little data /api/v1/activity (3.3.0)
The deployed checkout was 2 commits ahead of origin before the audit and is now 4 behind (documentation and headers only) none functionally fast-forward at the 3.3.0 deployment
Residential uplink behind the forge large downloads compete with every hosted site no automatic download of large repositories; archives only on explicit request with the size shown

# 6. Conclusions that shaped the application

  1. Public browsing works without an account; an owner token only adds write operations.
  2. The client is cache-first: the repository list, statistics, trees pinned to a commit and blobs pinned to a commit are immutable or cheap to revalidate with ETags.
  3. Expensive analytics are computed and cached on the server; the phone never clones or scans repositories to compute statistics or to search.
  4. The server remains the only authority for permissions. Face ID protects the token on the device and nothing else.
Files main
Menu

Theme