Skip to content
Repos

TOSV

Markdown 4.3 KB106 lines Opens in site

Directory Raw Download

TOSV implementation root

How the vault is built, end to end, in one guided tour. This page narrates; SPEC normates. On any conflict the spec wins and this page gets fixed the same commit. No sharding: the spec stays the shardable canonical doc, this root stays a readable single file with links outward.

Shape

Two files plus one shared core (tosv.cpp for HTTP, tosv-sftp.cpp for SSH plus SFTP, both C++17 stdlib plus POSIX plus pthreads plus pinned static libsodium, both including vault.inc for the DB, crypt, cache, audit, and rate-limit core), built by make build (vendored sodium plus hardened flags) in the Makefile, versioned by VERSION. Data root is the working directory: .env.json, tosv_db.txt, tosv_audit.log, tosv_store/, plus sftp_gateway_keys and the SFTP host key. Subsystem mechanics live in tosv.AGENTS and sftp.AGENTS.

Request path

Accept loop on 127.0.0.1:8765, one detached thread per connection, raw header parse to 64KB, Content-Length body read, route match, auth gate, handler, close. Shared state (sessions, rate windows, audit, DB save) holds short mutexes, never across socket IO. Routes and codes: SPEC 6.2; surfaces: SPEC 4.

Auth ladder

Bootstrap once (bootstrap), session cookie for the wizard (session), Basic store creds for upload, Basic grant creds plus IP plus window for fetch and WebDAV, duress pair for wipe. Guessing dies on rate limits.

Crypto walk

Per request: per-blob salt, Argon2id key from store auth, secretstream seal over 64KB chunks (AEAD), 64KB chunk streaming (streaming), buffers wiped after use (memory). No stored keys; version plus hash travel in the tag. v2 is tamper-evident; v1 blobs stay readable through the frozen legacy path.

Storage

Grants in an atomic flat DB (DB), blobs as UUID-named ciphertext (UUID), events in a minimal audit log, modes defaulting append-only (modes). WebDAV serves the same store with the same identity model (dav).

SSH plus SFTP

tosv-sftp is a standalone daemon, no OpenSSH linkage: own SSH-2.0 transport (mlkem768x25519-sha256 hybrid or curve25519-sha256 with strict-kex required, chacha20-poly1305 at openssh.com, ssh-ed25519 host and client keys, rekey at 1GB or 3600s), own SFTP v3 layer over the vault store. Clients authenticate by gateway key (sftp_gateway_keys, label plus bound gids), then prove each grant in-band by addressing /<gid>/<grant-pass>/; passes never appear in audit lines. One session channel, subsystem sftp only; exec, shell, pty, env, and TCP forwarding are refused. Full contract in sftpserver (60 SF plus 8 INT), decision in ADR 0008, ops in the SFTP runbook.

Transport and ops

Loopback in binary, stunnel at edge (transport), caps on every input, boring shutdown per D-04, daily restic backups with monthly restore drill, seven runbooks (see the runbook index), DTAP separation, 48h postmortems. Gates G0-G4 in SPEC 6.5; status in BUILD-TRACK.

Build order

M1 core HTTP plus DB plus auth plus wizard, M2 crypto plus streaming fixes, M3 WebDAV plus rates plus audit plus duress, M4 tests plus runbooks plus drill plus gates, M5 issue-zero, M6 critical pass, M7 v2 AEAD, M8 load tests, M9 key cache, M10 own SSH plus SFTP daemon. Estimates and freeze: SPEC 7 and D-12. Decisions: SPEC 9 plus ADR 0001, ADR 0002, ADR 0005, and ADR 0008.

Vision and threats

Start at the concept for why, then the security index for the full 22-measure map with pros, cons, and recursive resolutions.

See also

19.0ms