TOSV status: where we are, what is true, how to continue
Handoff document. SPEC.md stays normative; this page narrates the full state so work can continue later without archaeology. Numbers below are measured values from 2026-10-31 and 2026-11-01 runs, not estimates.
1. Where we are
- Product: TOSV 0.4.0, two-file C++17 vault (
tosv.cppHTTP plustosv-sftp.cppSSH/SFTP, sharedvault.inccore) plus pinned static libsodium 1.0.22. Tags:v0.5.0(M11),v0.4.0(M10),v0.3.0(M9),v0.2.0(M7),v0.1.0(M5); M8 test-only, untagged. - Spec: SPEC.md 0.5.0, milestones M0-M11 DONE, Gate 2 351/351 (rclone leg SKIPs without rclone),
make cigreen (lint, doc-check, smoke, gate2), locust smoke plus soak green with cache, SFTP smoke plus soak green. - Crypto generation: v2 (secretstream AEAD plus Argon2id) for all new stores; v1 (XOR layers) read-only for legacy blobs. SSH transport: mlkem768x25519-sha256 (PQ hybrid) or curve25519-sha256 strict-kex plus chacha20-poly1305 plus ssh-ed25519, rekey 1GB/3600s.
- Docs: SPEC, BUILD-TRACK, CHANGELOG, AGENTS plus tosv.AGENTS plus sftp.AGENTS, security index plus 22 measure pages, concept, implementation root, sftpserver contract, ADRs 0001-0008, 8 runbooks plus index, 3 research reports, this page. Every page carries a doc header and links onward.
Milestone log (evidence in BUILD-TRACK.md):
| M | What | Gate |
|---|---|---|
| M0 | Mode A scaffold, SPEC approved (G0) | - |
| M1-M4 | Core HTTP/DB/auth/wizard, crypto streaming, DAV, tests/runbooks/drill | 54/54 |
| M5 | Issue-zero: blocks, tags, clock guard, v6, expiry, locks, mlock, rclone/stunnel drills | 79/79 |
| M6 | Critical pass: crash class, injections, traversal, per-blob layers, tw radio | 145/145 |
| M7 | v2 AEAD: research, vendored sodium, secretstream plus Argon2id, v1 fixture, NFR runs | 178/178 |
| M8 | Locust harness: locustfile, runner, make targets, smoke plus soak plus 503 probe | 178/178 |
| M9 | Key cache: research, LRU 128 plus TTL 300, 14 asserts, soak compare | 192/192 |
| M10 | Own SSH/SFTP daemon: sftpserver contract, vault.inc, transport plus SFTP v3, 156 asserts, fuzzer, sftp soak, wipe pass, live caps, rclone, bench graphs | 348/348 |
| M11 | Post-quantum SSH KEX: mlkem768x25519-sha256 hybrid, pinned static mlkem-native 2.0.0, curve25519 fallback, 3 new asserts, ADR 0009 | DONE |
2. System as built
Shape: two binaries sharing one data root (the working
directory: .env.json, tosv_db.txt, tosv_audit.log,
tosv_store/, plus sftp_gateway_keys and the SFTP host key).
./tosv PORT (default 8765): loopback-only bind (fatal on
failure), one detached thread per connection, 64-conn cap (503
beyond), 30s recv timeout. ./tosv-sftp PORT (default 2222):
standalone SSH-2.0 plus SFTP v3 daemon, same loopback bind and
64-conn shape, 300s SFTP idle timeout, gateway-key auth plus
in-band grant proof.
Routes (codes in SPEC 6.2): /login (GET form, POST bootstrap,
store, duress), / wizard (session), /grant (POST, session),
/store (POST, Basic store creds), /fetch/UUID (GET, Basic
grant creds plus IP plus window gates), /logout, /dav*
(WebDAV class 1: OPTIONS, PROPFIND, MKCOL, PUT, GET, HEAD,
DELETE, COPY, MOVE, LOCK, UNLOCK, PROPPATCH).
File map:
| Path | Role |
|---|---|
tosv.cpp |
the HTTP app |
tosv-sftp.cpp |
the SSH/SFTP daemon (no OpenSSH linkage) |
vault.inc |
shared core: DB, crypt, cache, audit, rates |
Makefile |
build, smoke, gate2, ci, sodium, backup, DTAP helpers |
VERSION |
0.4.0, stamped via -DTOSV_VERSION |
tests/gate2.sh |
Gate 2 suite, 348 asserts |
tests/sftp/ |
raw_probe, bench, load-run, fuzzer plus corpus |
tests/fixtures/v1/ |
genuine v1 blob plus tag plus plaintext plus TEST-ONLY creds |
scripts/vendor-sodium.sh |
pinned download plus size plus sha256 verify |
scripts/doc-check.sh |
headers, forbidden strings, ID uniqueness, changelog order |
scripts/backup-*.sh |
restic run, verify, prune (prune needs TOSV_PRUNE_CONFIRM=yes) |
third_party/ |
tarball plus source plus static build (git-ignored, reproducible) |
3. Crypto, exactly
v2 blob layout (all new stores):
[0x02:1][salt:16][secretstream header:24][ct chunk: plain+17]...
Chunks are 64 KiB plaintext (TAG_MESSAGE), last chunk (possibly
empty for a 0-byte file) carries TAG_FINAL. Ciphertext length is
exactly computable: 100000B plain becomes 100075B on disk, empty
becomes 58B, 131072B becomes 131147B. Keys: 32B via
crypto_pwhash Argon2id INTERACTIVE (ops 2, mem 64 MiB) from
store_user:store_pass plus the per-blob salt; exactly one KDF
runs at a time (KDFM mutex, 64 MB transient bound).
Read path: blob_ver dispatches on the tag third field (default 1
when absent; missing tag sniffs the first blob byte, 0x02 means
v2). v2 fetch runs one pre-pass verifying AEAD stream plus tag
hash together, then streams 200 with exact Content-Length from
size math. Failure modes: crypto tamper (flip, truncation,
reorder, salt rewrite) gives 500 integrity fail plus an
aead-fail audit line; tag rot gives integrity-fail; unknown
version gives 500 unsupported version. DAV PROPFIND reports
plaintext length (dav_len); PUT/GET share the store/fetch
primitives. Tags: hash layers version; v2 tags are real SHA256
with 0 2 and verify with coreutils.
v1 legacy (read-only): leg_* hash plus XOR layers 1-8. The
M7 known-answer test proved the hand-rolled hash was never
standard SHA-256 (T1/Ch read state words 3,4,5 instead of 4,5,6),
so it is frozen byte-identical and used for old blobs only. The
layers grant param is accepted but inert for v2. v1 blobs stay
malleable until re-stored.
Supply chain: libsodium 1.0.22 tarball, 2008529 bytes,
sha256 adbdd8f16149e81ac6078a03aca6fc03b592b89ef7b5ed83841c086191be3349,
built --enable-static --disable-shared --enable-pic, linked as
one 948368-byte archive. Hardening: FORTIFY 3, SSP-strong,
stack-clash, CET full, GLIBCXX assertions, PIE, RELRO, BIND-NOW,
noexecstack, no -Werror. Research: 11 triangulated sources in
research/v2-crypto-2026-10-31.md.
4. Measurements (2026-10-31 through 2026-11-02, this machine unless noted)
| ID | Budget | Measured | Method |
|---|---|---|---|
| NFR-04 | p95 fetch under 2s at 10MB | p50 139ms, p95 153ms | 20 timed curl fetches, loopback |
| store | (informational) | 87-90ms at 1MB | Gate 2 sample plus probe |
| NFR-05 build | under 60s on 2-core | 29s from scratch | taskset 2-core, sodium configure plus make plus tosv |
| NFR-05 binary | under 5MB | 567528 bytes | stat |
| flat RAM | 64KB chunks | 100MB fetch flat RSS | Gate 2 (plus 5196KB idle probe) |
| secretstream | exact lengths | 100075, 58, 131147 | Gate 2 size asserts |
| INTERACTIVE | keeps NFR-04 | yes, 13x headroom | MODERATE (~0.7s) not needed, D-18 revisit clause |
| load smoke | 0 fails | 788 reqs, fetch p50 220ms p95 370ms, RSS avg 67MB | 10 users, 60s, 10MB fetch |
| load soak | 0 fails | 10096 reqs, fetch median 4.0s p95 4.3s, RSS avg 235MB | 64 users, 600s, 1MB fetch, KDF-queue-bound, pre-cache |
| soak cached | 0 fails | 68130 reqs, fetch median 6ms p95 8ms, 68/s, RSS avg 31MB | 64 users, 600s, 1MB fetch, M9 cache |
| 503 onset | clean shed | 38% shed at 80 users, crypto markers zero, RSS max 273MB | 80 users, 90s, all failures are 503 busy |
| sftp smoke | 0 errors | puts 20, gets 590, put p95 697ms, get p95 36ms, 10.2 MiB/s, RSS avg 7MB | 10 users, 60s, 1MB put+get, sha-verified, 2026-11-02 |
| sftp soak | 0 errors | puts 20, gets 4491, get p50 4.5s p95 5.0s, 75.2 MiB/s, RSS avg 18MB | 40 users, 600s, 10MB put+get, sha-verified, 2026-11-02 |
| http smoke | 0 failed | fetch p50 61ms p95 75ms, DAV p50 7ms p95 10ms, 959 reqs | 10 users, 60s, 10MB fetch, M10 code, 2026-11-02 |
| http soak | 0 failed | fetch p50 7ms p95 9ms at 67.5/s, DAV p50 7ms p95 9ms, 67952 reqs, RSS 36MB | 64 users, 600s, 1MB fetch, M10 code, 2026-11-02 |
| sftp shed | clean shed | puts capped at 20 per 300s per IP, gets never shed, 0 reconnects | soak: 4264 puts shed by design, 0 errors |
| sftp single | NFR-04 shape | 10MB get 157-233ms | single connection, loopback |
| sftp fuzz | 0 findings | 354847 runs in 301s, libFuzzer plus ASan/UBSan | 32 seeds, max_len 8192 |
| sftp rekey | byte-identical | asyncssh 5MB over 84 rekeys, stock sftp 5MB over 39 rekeys, 0 flow deaths | TOSV_REKEY 50000/100000, sha256 match |
| sftp rclone | byte-identical | 1MB copyto up 0.14s plus down sha match, lsd 0.02s | rclone 1.60.1, Gate leg, EOF-back fix |
| live grants | 507 at cap | 10000 grants created, 10001st refused 507 | loopback, session cookie, Gate live |
| live blobs | 507 at cap | store allowed at 100000 files, refused at 100001 | 100k empty files, Gate live |
| PROPFIND 10k | exact 10001 | self plus 10000 visible, beyond-cap file GETs intact | 10002 files plus tags, Gate live |
| 512MB blob | identical | 512MB store 200 plus sha match, 512MB+1 refused 413 | loopback, Gate live |
| kill-9 | fails closed | partial blob 500 plus audit marker, serves 207 after restart | kill -9 mid-PUT, Gate live |
5. Findings register (everything found, none hidden)
Found and fixed during M1-M7, newest last:
- F-01..F-08 (M1-M6): DAV 302d by session gate (DAV exempted);
suite bare-
waithang (PID-specific waits); tag-before-flush race (flush first); CONN double-count (decrement-only guard);wipe_storebrace miscount (brace-traced fix); stunnel runbook missing section; missing forward declarations; wizard footer version pin. - F-09 (M7): new v2 tests failed on the v1 binary exactly as designed (version byte, tag version, size math, unknown version returned 200 fail-open), then passed on v2.
- F-10 (M7): the v1 tamper test passed for the wrong reason (tag
hash mismatch, not crypto). Fixed by asserting the
aead-failaudit marker, which proves the crypto layer fired. - F-11 (M7): hand-rolled SHA-256 failed known-answer test against
coreutils plus Python; root cause read from the source (wrong
state words in T1/Ch). Frozen as
leg_*, never for new data. - F-12 (M7): per-blob layers have no meaning under AEAD; contract changed (layers v1-only, inert for v2), 3 Gate asserts remapped to the new contract, recorded in ADR 0005.
- F-13 (research): early draft miscited NFR-04 as a store budget and claimed unverified OWASP tuning times; both corrected to the normative fetch budget plus measured values.
- F-14 (research): dead Gentoo URL replaced by OWASP plus GCC
primary sources;
--with-piccorrected to--enable-picfrom the vendored configure;-z,noexecheapdropped after ld ignored it with a warning. - F-15 (M8): 64-user soak is KDF-queue-bound at median 4.0s
(zero errors, memory flat); 80-user probe sheds 38% as clean
503
busywith zero crypto markers. Operating envelope set: sub-500ms single-digit, NFR-04 holds at 10 users, key cache recorded as the follow-up fix, not scheduled. - F-16 (sweep): no secrets committed anywhere (93 tracked files
plus full history scanned; only the labeled TEST-ONLY fixture).
Local
tosv_db.txtwas 644, tightened to 600..gitignoreextended for dotenv, keys, host keys, logs, and tmp files. Full log below. - F-17 (M10): rekey window self-deadlock. SFTP reads plus the
client's WINDOW_ADJUST queued in
pendduring kex; the drain stalled on window 0 before reaching the credit, client stayed quiet waiting for replies (3 adjusts received, 0 applied). Fix: type-93 credits applied inline inkex_recvvia sharedapply_adjust; credits never queue. Same session also fixed mpint leading-zero in KEX hashing (asyncssh interop), partial sends, and oversize plen caps. Full log in sftpserver App D. - F-18 (M10): SSH interop class. AEAD padding alignment, double INIT reply, attr file-type bits, seal chunking, V2Push exact-multiple edge, CLI arg order; all fixed same day with Gate asserts (sftpserver App D, D1-D7).
- F-19 (M10): DAV PROPFIND cap counted
.tagsidecars toward the 10k return cap (same class as SFTP D3, 5001 visible not 10001). Fix mirrors D3: 20k dirent scan cap plus exactly 10k visible names. Live-cap assert now passes exact. - F-20 (M10): 10k-grant probe parsed zero cookies because curl
jars HttpOnly cookies as
#HttpOnly_lines, which the#-comment skip dropped. Test bug; parser strips the prefix now, 10000 grants plus 507 on 10001 pass live. - F-21 (closure): two sessions edited one tree. A concurrent
gate2.sh write mid-CI tore bash parsing (phantom syntax
error, resolved by hash snapshot plus rerun on the stable
file). A probe
pkill -x tosvthen killed the gate's own HTTP server (self-inflicted 000s, resolved by scoped kills plus a hands-off rerun). Foreign hunks (wipe pass, live caps, stunnel doc) were each reviewed, plus one-Wmisleading-indentationfalse positive silenced with a newline; finalmake ci330/330 with zero warnings, commit0986437, tagv0.4.0. Rule earned: snapshot the gate hash before CI, and never broad-kill during a run. - F-22 (rclone): unanswered CHANNEL_EOF stalled Go clients 30s
per command (close-deadlock: they wait for us, we waited for
them). Fix: EOF-back symmetric half-close; rclone
lsdnow 0.02s, 1MB roundtrip sha-identical. Regression leg in raw_probe.py, proven FAIL on pre-fix binary, PASS on fixed. Third SFTP client green (sftpserver App D, D9). - F-23 (bugfix sweep): full 681-line re-read found 13 defects,
all fixed with 17 new asserts (348/348). Classes: gmtime
thread race (now gmtime_r); CIDR suffix fail-open to /0
(strict numeric parse, hostile-storage contract kept);
uncapped DB read (16MB); secret files 644-at-create (now
0600-at-create); double SFTP replies on truncated packets
(single-reply discipline, raw-handshake probe, App D10);
gateway perms unchecked at runtime; boot FS throws;
512MB login body (cap moved pre-read, graceful 413);
PROPFIND races plus real infinity recursion; MKCOL lying
201; COPY off-dav silent /x; secret-response copies
(resp_wipe). Plus gate's own
rclone obscuredash-flake. Long fuzzer 1350422 runs clean.
Sweep log (2026-10-31)
Scope: all 93 tracked files, full git history, local ignored runtime files, key-like filenames, one branch, empty stash.
| Check | Method | Verdict |
|---|---|---|
| Hardcoded passwords, tokens, API keys | two repo-wide pattern sweeps plus corrected full-history scan with a control line | clean; only the 4 labeled fixture lines, ever |
| Private keys and certs | filename scan plus history scan for PEM blocks | clean; wolfssl/wolfssh files are upstream public test fixtures and git-ignored |
| Fixture secret reuse | repo-wide file-list grep per value | each value appears only in meta.env |
| Live runtime files | presence plus perms plus shape (values never printed) | .env.json 0600 ok; tosv_db.txt was 644, fixed to 600; audit log loopback-only, zero secret words; store empty |
| Stale branches, stash | branch -a, stash list |
one branch, empty stash |
Correction honesty: the first history scan silently matched
nothing because of an invalid git flag (stderr suppressed);
a control line caught it and the scan was re-run correctly.
Actions: chmod plus .gitignore extension, commit ea9b3ca.
6. Open issues and residual risks
| ID | Issue | Severity | Path |
|---|---|---|---|
| R-01 | v1 blobs malleable until re-stored | medium | re-store campaign at next touch; no flag day by design |
| R-02 | Blob length leaks (no padding) | low | padding stays a future option |
| R-03 | No forward secrecy across blobs | low | per-blob salts bound damage; X25519 future |
| R-04 | TLS-E2E envelope, Shamir recovery, PQ KEX | partial | PQ KEX done in M11 (ADR 0009, SF-61); host key stays Ed25519; envelope and Shamir need ADR plus owner decision |
| R-05 | SFTP/SSH access | DONE in M10 | own daemon shipped, ADR 0008, NG-01 retired |
| R-06 | TPM, FUSE, monitoring | roadmap | future platform page |
| R-07 | Caps partly unproven live (1000 sessions, 24h expiry, live IPv6) | low | 10k grants, 100k blobs, 512MB blob, PROPFIND 10k proven live in M10; stunnel overhead runbooked, not yet run |
| R-08 | MODERATE KDF revisit | closed 2026-11-02 | INTERACTIVE keeps 13x NFR-04 headroom on measured M7/M9 numbers; MODERATE stays future per D-18 |
| R-09 | HMAC audit journal | low | needs key-management ADR first |
| R-10 | SSD ghosts, backups survive duress | accepted | by design; documented in duress page |
| R-11 | Missing-tag first-byte sniff (1/256 v1 corner) | negligible | fails closed to 500; documented in code |
| R-12 | Auth-string temporaries unwiped | DONE in M10 | WipeStr plus DBGuard plus GrantGuard plus ParamWipe plus cred_match; Gate green |
| R-13 | DAV HEAD reports Content-Length 0 | DONE in M10 | real length via dav_len; Gate asserts 7-byte length |
| R-14 | Fetch does two full passes (verify plus stream) | accepted | measured: NFR-04 keeps 13x headroom |
| R-15 | Stale mirror lines may linger in measure pages | negligible | doc-check gates headers plus IDs; mirrors fixed same-commit per rule |
| R-16 | HTTP/WebDAV transit has no PQ guarantee | closed by default | in-tree TLS 1.3, X25519MLKEM768 only unless TOSV_TLS_ALLOW_CLASSICAL=1, no external library (ADR 0011); operator must set TOSV_TLS_CERT and TOSV_TLS_KEY (tosv --tls-selfsign makes them); cert signature stays Ed25519; handshake parser mutation-fuzzed only, no external review |
| R-17 | SSH curve25519 fallback | closed by default | PQ-only is the default, TOSV_SFTP_ALLOW_CLASSICAL=1 opts out (SEC-10, SF-62); older clients without ML-KEM are locked out by design |
| R-18 | Ed25519 host key and user auth | medium | wait for standard SSH PQ signature |
| R-19 | Argon2id INTERACTIVE, no passphrase entropy floor | closed 2026-11-05 | no change: generated store and grant passphrases are 96 to 132 bits (16 or 22 chars of a 64 alphabet), so KDF cost is not the limit; MODERATE would break the 64MB KDF cap (FR-06) |
| R-20 | v1 blobs weak, still readable | medium | tool shipped: tosv --restore-v2 (FR-17); operator must run it, then delete tosv_v1_bak/ |
7. How to continue
Read order for a fresh session: this page, SPEC.md (normative), tosv.AGENTS.md (subsystem mechanics), docs/implementation.md (guided tour), tests/gate2.sh (executable contract), then the measure page for the area under change.
Commands (repo root, no hand-prepared machine beyond g++ plus pthreads plus curl/jq/python3):
make build # vendors sodium once, builds ./tosv plus ./tosv-sftp 0.4.0
make smoke # boot probe on 18765
./tests/gate2.sh # full suite, 348 asserts, about 30 minutes
make bench # HTTP plus SFTP smokes, then docs/bench/ graphs
make ci # lint plus doc-check plus smoke plus gate2
make fuzz-sftp # 5min libFuzzer plus ASan/UBSan on the SFTP layer
make load-sftp-smoke # 10 users, 60s SFTP put+get, sha-verified
make load-sftp-soak # 40 users, 10min SFTP put+get
./scripts/backup-run.sh # restic drill path
./scripts/backup-verify.sh <dest> # verify a snapshot
TOSV_PRUNE_CONFIRM=yes ./scripts/backup-prune.sh
TOSV_NTP=host ./tosv 8765 # serve with clock guard
Conventions that gate CI: every docs/**/*.md starts with a
<!-- doc: ... --> header; no placeholder markers and no em dashes anywhere
(code, docs, commits, chat); SPEC IDs unique; changelog ascends;
every behavior change ships a Gate 2 assert in the same commit;
commit style TOSV Mx: ..., tags vX.Y.Z, never push without
being asked. Pre-existing untracked files (.bash_history,
tosv.cpp.bak, reference-only wolfssl/, wolfssh/) are not
ours; leave them alone.
8. Next
Load-test plus SSH plus measurement proposals were delivered as an inline plan in chat on 2026-10-31 (no plan file, by policy). Owner approved 2026-10-31: build literally all, in this order: Locust load tests first (M8 DONE), key-cache follow-up (M9 DONE), then the SSH ADR spike plus verdict, then the measurement backlog. Each lands as a milestone row in BUILD-TRACK.md. SSH ADR takes number 0008 (0007 went to the key cache).
SSH verdict delivered 2026-10-31, see ssh-transport research: wolfSSH builds statically (proven: libwolfssl.a 1.2MB plus libwolfssh.a 307KB) but is GPLv3-or-commercial, which the owner rejected (no commercial license, no GPL), and its SFTP server is port-layer FS backed, not vault-native. Owner decision: implement their own standalone SSH plus SFTP daemon in this repo under the same discipline, SSH gateway identity plus in-band grant proof. Contract is sftpserver.md v0.2.0 (60 SF plus 8 INT, research round 2 applied: SFTP IDs corrected against the draft, KEX plus chacha constructions pinned to RFCs and OpenSSH source, strict-kex upgraded to required).
M10 built it all 2026-11-01 (I build all, tested): vault.inc
extraction, tosv-sftp daemon, 156 new Gate asserts (348/348),
libFuzzer plus ASan/UBSan clean, SFTP smoke plus soak green,
auth-memory wipe pass (R-12), DAV HEAD length (R-13),
live caps plus kill-9 plus 512MB proven (R-07 shrunk),
rclone third client (D9), bench graphs via make bench,
ADR-0008, SPEC 0.4.0, sftp.AGENTS plus runbook, tagged v0.4.0.
Next: stunnel overhead run, then owner pick from
R-02/R-04/R-08/R-09.
See also
- SPEC, build track, changelog, implementation, security index, v2 research, ADR 0005, SSH transport research, SFTP server requirements, ADR 0008, SFTP runbook
M11 measurements (2026-11-03, loopback, this machine)
- PQ rekey: 100 consecutive ML-KEM hybrid rekeys in one stock sftp session (RekeyLimit 1K), rc 0, no errors.
- Interop: OpenSSH 10.2p1 sftp/ssh and asyncssh 2.24.1 negotiate mlkem768x25519-sha256 and curve25519-sha256 both ways.
- Handshake cost: 30 ssh connection attempts each, 49ms average for both algorithms; client process start dominates, so the PQ delta is below this method's resolution. No finer number claimed.
- Library size: libmlkem768.a built portable C only, no assembly backend.
- Harness defect found: gate2 cap-clear used
rm -fover 100000 paths (E2BIG, store never cleared, 2 false fails); nowfind -delete. - Fuzz: harness builds with the PQ code and ran 141624 inputs in 60s under ASan/UBSan, clean. Gap: the harness does not call do_kex (needs a live Conn), so the Q_C parse path is covered by Gate 2 and interop only, not by the fuzzer.