SPB Git

Repository Public

SECURITY_MODEL.md 9.4 KB 128 lines markdown

1# Security model23How SPB Git for iOS protects the owner's credentials, the forge and the reader's device. Server-side controls4are implemented in `spbgit` 3.3.0; this document states what the client relies on and what it enforces itself.56## 1. Principles781. The server decides. Every privileged operation is authorised by the server from the token it receives; the9   application never grants itself a right, and hiding a button is a convenience, not a control.102. Nothing secret ships in the binary: no token, no SSH key, no API key, no signing material, no private11   endpoint. The only host in the binary is `git.spboucher.ai`.123. Public reading needs no account and sends no identifier other than the visitor-pass cookie the website also13   uses.144. Repository content is untrusted input. It is displayed, never executed.1516## 2. Actors and assets1718| Asset | Where it lives | Threats considered |19|---|---|---|20| Owner token (`spbgit_<id>_<secret>`) | device Keychain | theft from an unlocked or backed-up device, leak through logs, crash reports, pasteboard, screenshots, the shared HTTP cache |21| Repositories on the forge | server | unauthorised write, destructive mistake, overwrite of a concurrent push, injected git arguments or paths |22| The forge uplink and CPU | server | the application behaving like a crawler |23| The reader's device | device | hostile repository content: HTML and Markdown with scripts, huge files, decompression bombs, malformed media, path tricks in file names |2425## 3. Authentication and the owner mode2627- The owner pastes or scans a personal access token created for this device (label, scopes, expiry). The28  application verifies it with `GET /api/v1/whoami` before storing it and shows the scopes and the expiry date.29- Storage: Keychain generic password, `kSecAttrAccessibleWhenUnlockedThisDeviceOnly`, protected by an access30  control requiring user presence (`.userPresence`: Face ID or Touch ID with passcode fallback). The item is not31  synchronised to iCloud and is excluded from backups by its accessibility class. The token is never written to32  UserDefaults, files, logs, analytics, the pasteboard or widgets.33- Unlock: the token is read from the Keychain after a successful LocalAuthentication prompt and kept in memory34  by an actor for the duration of the owner session. The session locks when the application goes to the35  background for longer than the configured delay (default 5 minutes, immediately if the owner chooses so) and36  on demand.37- Face ID is a local gate on the stored token. It is not an authorisation: the server checks the token, its38  expiry and its scopes on every request.39- Scopes (3.3.0): `repo:write`, `repo:admin`, `tokens`, `admin`. The application asks for the least it needs40  and adapts the interface to the scopes reported by `whoami`. A `403 insufficient_scope` is shown as such.41- Expiry and revocation: `401 token_expired` or `401 unauthorized` ends the owner session, removes the token42  from the Keychain after confirmation and returns to public mode. Tokens can be listed and revoked from the43  application (scope `tokens`); revoking the current token signs out.44- Passkeys: the server has no passkey endpoint in 3.3.0 (the forge has no accounts, only tokens). The client45  therefore does not offer passkeys in 1.0; the authentication layer is isolated behind a protocol so that a46  WebAuthn-issued token can be added without touching the features.4748## 4. Transport4950- HTTPS only, App Transport Security without exception, TLS validated by the system trust store. No custom51  trust evaluation that could weaken it, no arbitrary loads.52- Requests with a token use an ephemeral `URLSession` configuration: no cookie storage, no URL cache on disk.53  Authenticated responses are never written to the shared disk cache, and the `Authorization` header is never54  logged.55- Redirects to another host are not followed for authenticated requests.5657## 5. Write operations5859- Every write shows what will happen before it is sent: files and diff for a commit, the exact branch, tag or60  repository name for the others.61- Concurrency: a commit carries `expectedHead` (the branch tip the editor loaded) and, per file, `expectedOid`.62  The server applies it with `git update-ref <ref> <new> <old>`; if the branch moved it answers `409 head_moved`63  and nothing is written. The application then shows the incoming commits and lets the owner reload; it never64  retries a write blindly.65- Destructive operations (deleting a repository, a branch or a tag, revoking a token) require typing the name66  of the object, then a fresh biometric confirmation. Repository deletion is a soft delete on the server67  (30 days in the trash) and the dialog says so.68- Every authenticated write is recorded by the server in an append-only audit log (date, token id and label,69  address, action, repository, short detail; no secret, no content). The application shows this log to the70  owner (scope `admin`).71- Operations are real or absent. When the server refuses or lacks a route, the application says so; it never72  displays a simulated success.7374## 6. Untrusted repository content7576| Content | Handling |77|---|---|78| Source and text files | rendered as text with a native highlighter; size limits; paged loading above 1 MiB; no file above the configured limit is loaded into memory whole |79| Markdown | parsed and rendered with native views; raw HTML inside Markdown is shown as text, not interpreted; links open only `https`, `http` and `mailto` after confirmation of the host when it differs from the forge; images load only over HTTPS and only from the forge by default (remote images are opt-in) |80| HTML files | shown as source. The optional preview uses a non-persistent `WKWebView` with JavaScript disabled, no network access (content rule list blocking every request), no file access and no link navigation |81| PDF, images, audio, video | PDFKit, ImageIO with a pixel-count ceiling, AVFoundation; downloaded to the application's temporary directory with a generated file name, never the repository-provided path |82| Quick Look | only for files the user opens explicitly, from a sandboxed temporary copy |83| Archives | never unpacked by the application |84| File names and paths | treated as display strings; local file names are derived from a hash; path components are validated (`..`, absolute paths, control characters refused) before any use in a URL |85| JSON, CSV | parsed with depth, node-count and row limits; beyond them the file is shown as text |8687Nothing from a repository is executed, opened in another application automatically, or added to the shared88pasteboard without a user action.8990## 7. Being a well-behaved client of the shield9192The application obtains a visitor pass by proof of work like any browser, identifies itself honestly in its user93agent, coalesces and caches requests, honours `Retry-After`, and never crawls: no background enumeration of94trees, no prefetch of files the reader did not open, offline downloads only on explicit request with the size95shown beforehand and a ceiling. It has no hidden bypass of the shield.9697## 8. Privacy9899No analytics, no advertising, no third-party SDK, no tracking. Favourites, history, search history and offline100copies stay on the device (application container and App Group shared with the widgets), and can be erased from101the settings. Push notifications are opt-in; when enabled the server stores the APNs device token, the followed102repository names and the locale, and deletes them when notifications are turned off. The privacy manifest103declares no collected data and no tracking domain.104105## 9. Verification106107The checks run for the release are recorded in `SECURITY_REPORT.md` (written at the security phase): Keychain108attributes on a device build, absence of the token in logs and caches, binary strings and hosts, behaviour of109each refusal (`401`, `403`, `409`), hostile content samples, and the server-side tests of the write path.110111## 10. Offline copies, App Group and platform integrations (as built)112113- **App Group** (`group.ai.spboucher.git`): the API cache, the reader's library (favourites, history, follows, pins)114  and the widget snapshots (totals of the forge, last push, public description of marked repositories; file names115  are digests). Never the owner token, never the APNs device token, never an authenticated answer.116- **Offline copies** live in the application container only, excluded from backups, under names derived from117  hashes. They are downloaded by an anonymous client (no token, even in owner mode), pinned to a commit, and a file118  is kept only when its content hashes to the git object id announced by the server; "Verify files" checks again.119- **Links from outside** (universal links, `spbgit://`, Spotlight results, Handoff activities, notification120  payloads, widget and intent parameters) all end in `DeepLink`, which validates every component. Ref names read121  from the server to resolve a slash are validated like any other input.122- **Notifications**: the local path sends nothing about the reader to the server (it reads the public activity123  feed). The push path sends the APNs token, the followed repository names and `en`/`fr`; turning notifications off124  deletes the registration. The token is kept in the application's own preferences.125- **Spotlight** indexes public facts of public repositories on the device; it can be turned off, which removes them.126- **Privacy manifests**: the app declares `UserDefaults` (`CA92.1`); the widget extension uses no required-reason127  API (its snapshots carry their own dates; no file timestamp, disk-space or `UserDefaults` call).128
Files main
Menu

Theme