From 870e78e81ab8b05f68f67f8cd136fcc10e2fa030 Mon Sep 17 00:00:00 2001 From: mnovak Date: Wed, 11 Nov 2026 21:11:31 +0100 Subject: [PATCH] =?UTF-8?q?[docs]=20F20:=20review=20=E2=80=94=2031=20tests?= =?UTF-8?q?,=2012/12=20planted=20bugs=20caught?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .agents/reviews/feature-relay.md | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .agents/reviews/feature-relay.md diff --git a/.agents/reviews/feature-relay.md b/.agents/reviews/feature-relay.md new file mode 100644 index 0000000..0032c88 --- /dev/null +++ b/.agents/reviews/feature-relay.md @@ -0,0 +1,86 @@ +# Review — `feature/relay` (F20: wire types and the relay, on loopback) + +Adversarial self-review, 2026-11-11. Base: `main` at a19a469. Analysis: `.agents/features/relay.md`. + +## Evidence +| What | Result | +|:--|:--| +| `cargo test --workspace --locked` | protocol **14** (9 unit, 5 property tests of 10,000 cases each), relay **17**, client 0 — **31 passed, 0 failed** | +| `cargo clippy --workspace --all-targets --locked -- -D warnings`, `cargo fmt --all --check` | clean | +| `scripts/check-deps.sh` | relay does not depend on client; protocol depends on nothing here | +| `scripts/test-hooks.sh` | 7 passed | +| Planted bugs (`mutate_relay.py`, one at a time, then restored) | **12/12 caught** after one test was fixed (F1) | + +| Planted bug | Caught by | +|:--|:--| +| Any token accepted | 4 tests, among them *only the post token posts…* | +| `secure_delete` off | *a deleted blob is not left in the file* | +| WAL journal (a `-wal` copy) | *no token, secret or address reaches the database* | +| A `sender_ip` column slipped in | *schema is exactly protocol section 5* | +| Blob TTL a day short | *purged after 30 days, not before* (after F1) | +| Blob TTL two hours long | the same, and *a deleted blob is not left…* | +| An invite not deleted on claim | *claimed once…*, *still good just before 7 days* | +| An invite that never expires | *an invite expires after 7 days* | +| Rotation that changes nothing | *after rotation the old post token is refused* | +| Acknowledging across mailboxes | *an acknowledged blob is gone and no other is touched* | +| An unknown mailbox answered 403 instead of 404 | 5 tests, among them *an unknown mailbox looks exactly like a wrong token* | +| A request printed to stderr | *the binary serves its version and prints no request* | + +## Findings +**F1 — test honesty, found by a planted bug, fixed.** The purge test first checked at 29 days and +at 31 days. A TTL one day short still passed it. The test now checks one hour before and one hour +after the 30-day boundary. A TTL that is a day short or two hours long both fail it. + +**F2 — privacy, the canary in §7 is only half proved here.** *A canary string sent in a message +never appears in the relay's database* is a property of the client's encryption. The relay stores +whatever bytes it is given. F20 proves the relay's half: no token, invite secret, client address or +user agent ever reaches the database file. The file was searched byte by byte after real TCP +requests. The message canary is F21's first end-to-end test. + +**F3 — privacy, what the relay does keep.** +- **Per mailbox:** the token hashes and the day it was made. +- **Per blob:** the ciphertext, its size and the hour it arrived. +- **Per invite:** the secret's hash, the KeyPackage and the expiry, rounded up to the hour. + +All of it is §5's list, checked by the schema test. A KeyPackage holds the inviter's MLS public key +and credential. That is §4 by design: it is how the invitee starts the conversation. It is deleted +when claimed, or at expiry. + +**F4 — correctness, acknowledging by hash.** Two identical blobs in one mailbox: one acknowledgement +deletes one of them, and the second waits for its own. MLS ciphertexts do not repeat, so this only +matters for a misbehaving client. The cost is reading the mailbox's blobs on each acknowledgement: +at most 100 are fetched at a time, which is fine for a home relay. If it ever matters, a per-blob +hash column would be a protocol change. + +**F5 — abuse, open by design (relay.md §4).** Mailbox and invite creation need no account. A relay +reachable by strangers can be filled. v0 caps sizes (a blob ≤ 256 KiB, JSON ≤ 32 KiB), not counts. +The relay listens on loopback by default; quotas come before any public relay. + +**F6 — the HTTP routes are not in `PROTOCOL.md` yet.** The routes, the uniform 404 and acknowledging +by hash live in `relay.md` §2 and in the protocol crate. None of it adds a stored field or loosens a +promise. They are still part of *what crosses the wire*, so adding them to `PROTOCOL.md` (a new §8) +needs Mark's approval. + +**F7 — concurrency.** One SQLite connection behind a mutex, used briefly inside async handlers. On a +home relay that is fine. Under load it would block a runtime thread. `spawn_blocking` or a pool is +the fix when it matters. + +**F8 — scope.** +- Fuzzing uses `proptest`: 50,000 parser cases and 3,500 random requests per run. `cargo fuzz` + waits for a Linux runner (relay.md §4). +- Not tested: the hourly purge timer in `main.rs`. The purge itself is tested, with the clock passed + in. +- Not checked: the reproducible Nix build, by hand in WSL; there is no Nix there yet. + +## Privacy — every path a byte could leave +- **Off the relay:** only the responses to the token holder. A refusal is a bare status with no body. +- **Into a log:** one line at start (version and bind address). Nothing per request, tested on the + real binary. +- **Into the database:** §5 only, tested by the schema test and by a byte search of the file. + +## Not verified +- TLS and a reverse proxy (F23). +- A real network beyond loopback. +- Load. +- The Nix build. +- Windows only: the CI runners are Windows, and so is this machine.