[relay] F23: quotas (507), NixOS module behind Caddy with TLS and no logs, VM test (unrun) #17

Closed
mnovak wants to merge 0 commits from feature/home-relay into main
Owner

F23 — the relay on a home server (T#8, Amicitia #51). Analysis: .agents/features/home-relay.md.

  • Quotas (PROTOCOL.md section 8, a new status). A mailbox holds at most 1 000 waiting blobs and 32 MiB. The relay holds what its operator sets: by default 1 GiB, 100 000 mailboxes and 10 000 unclaimed invites. Over a limit the answer is a bare 507, per mailbox only after the post token. Nothing new is stored to count.
  • deploy/nixos/module.nix: services.tabellarius. The relay runs on loopback, sandboxed by systemd, and may talk to localhost only. Caddy sits in front with Let's Encrypt TLS, no access log, no error log, and the forwarding headers removed, so the relay never learns who connected. Refused-connection firewall logging is off by default.
  • deploy/nixos/test.nix (nix flake check): a VM test that a client's address appears nowhere on the server after a session that includes refusals and a 507.
  • deploy/nixos/README.md: how to run it, and what an operator still sees.
  • The container image of T#8 is left for later.
**F23 — the relay on a home server** (T#8, Amicitia #51). Analysis: `.agents/features/home-relay.md`. - **Quotas** (`PROTOCOL.md` section 8, a new status). A mailbox holds at most 1 000 waiting blobs and 32 MiB. The relay holds what its operator sets: by default 1 GiB, 100 000 mailboxes and 10 000 unclaimed invites. Over a limit the answer is a bare **507**, per mailbox only after the post token. Nothing new is stored to count. - **`deploy/nixos/module.nix`:** `services.tabellarius`. The relay runs on loopback, sandboxed by systemd, and may talk to localhost only. Caddy sits in front with Let's Encrypt TLS, **no access log, no error log**, and the forwarding headers removed, so the relay never learns who connected. Refused-connection firewall logging is off by default. - **`deploy/nixos/test.nix`** (`nix flake check`): a VM test that a client's address appears nowhere on the server after a session that includes refusals and a 507. - `deploy/nixos/README.md`: how to run it, and what an operator still sees. - The container image of T#8 is left for later.
mnovak added 2 commits 2026-11-16 11:40:31 +01:00
mnovak added 1 commit 2026-11-16 11:40:31 +01:00
mnovak reviewed 2026-11-16 11:40:32 +01:00
mnovak left a comment
Author
Owner

Adversarial self-review — F23, the home relay

Evidence

What Result
cargo test --workspace --locked (Windows) client 25, protocol 14, relay 25 (17 + 8 new quota tests): 64 passed, 0 failed
Clippy (-D warnings), fmt, check-deps.sh clean / ok / ok
Planted bugs (mutate_quotas.py) 8/8 caught: the mailbox cap checked before the token; the blob cap one too many; the byte cap refusing an exact fit; the relay-wide byte cap ignored; the mailbox count cap ignored; expired invites counted; 507 answered as 500; --max-bytes ignored

Not verified — read this first

  • The NixOS module and its VM test have never been evaluated. This machine has neither Nix nor WSL (WSL's Windows component is missing since today). Both were written against the NixOS options as I know them (services.caddy.logFormat, virtualHosts.<name>.logFormat, testers.runNixOSTest). They need nix flake check on Linux before anyone relies on them. The first real run is Mark's server. Until then, the claim the proxy logs no address is a design, not a tested fact. CLAUDE.md section 2.4 says a privacy claim without a test is removed from the docs, so the README and analysis say plainly that the VM test has not run yet.
  • The systemd sandbox options were not run either. A too-strict one would stop the relay from starting, which is visible at once, not a silent leak.
  • Let's Encrypt, a real DNS name, and the app over https (Amicitia's half of F23).

Verdict

The quotas are tested and merge. The deploy files merge as an unrun draft, marked so in their README, so Mark can run them. Findings Q1–Q7 are on their lines.

## Adversarial self-review — F23, the home relay ### Evidence | What | Result | |:--|:--| | `cargo test --workspace --locked` (Windows) | client **25**, protocol **14**, relay **25** (17 + 8 new quota tests): **64 passed, 0 failed** | | Clippy (`-D warnings`), fmt, `check-deps.sh` | clean / ok / ok | | Planted bugs (`mutate_quotas.py`) | **8/8 caught**: the mailbox cap checked before the token; the blob cap one too many; the byte cap refusing an exact fit; the relay-wide byte cap ignored; the mailbox count cap ignored; expired invites counted; 507 answered as 500; `--max-bytes` ignored | ### Not verified — read this first - **The NixOS module and its VM test have never been evaluated.** This machine has neither Nix nor WSL (WSL's Windows component is missing since today). Both were written against the NixOS options as I know them (`services.caddy.logFormat`, `virtualHosts.<name>.logFormat`, `testers.runNixOSTest`). They need `nix flake check` on Linux before anyone relies on them. The first real run is Mark's server. Until then, the claim *the proxy logs no address* is a design, not a tested fact. CLAUDE.md section 2.4 says a privacy claim without a test is removed from the docs, so the README and analysis say plainly that the VM test has not run yet. - The systemd sandbox options were not run either. A too-strict one would stop the relay from starting, which is visible at once, not a silent leak. - Let's Encrypt, a real DNS name, and the app over `https` (Amicitia's half of F23). ### Verdict The quotas are tested and merge. The deploy files merge as an unrun draft, marked so in their README, so Mark can run them. Findings Q1–Q7 are on their lines.
@@ -150,6 +201,20 @@ impl Store {
}
let conn = self.conn();
Self::authorize(&conn, id, token, Column::Post)?;
// After the token: a stranger learns nothing about this mailbox from a 507.
Author
Owner

Q1 — privacy: 507 after the token. A per-mailbox 507 before the token check would tell anyone who knows a mailbox id that it is busy. The planted bug the mailbox cap checked before the token proves the test sees it.

**Q1 — privacy: 507 after the token.** A per-mailbox 507 before the token check would tell anyone who knows a mailbox id that it is busy. The planted bug *the mailbox cap checked before the token* proves the test sees it.
@@ -235,0 +300,4 @@
// Expired invites wait for the hourly purge; they do not count against new ones.
let waiting = Self::number(
&conn,
"SELECT count(*) FROM invites WHERE expiry > ?1",
Author
Owner

Q2 — expired invites do not count. The hourly purge removes them later. Counting them would let an hour of spam block new invites longer than the 7-day rule says. A planted bug proved the test.

**Q2 — expired invites do not count.** The hourly purge removes them later. Counting them would let an hour of spam block new invites longer than the 7-day rule says. A planted bug proved the test.
@@ -0,0 +81,4 @@
# It talks to Caddy on loopback and to nothing else, even if it had a bug.
IPAddressDeny = "any";
IPAddressAllow = "localhost";
Author
Owner

Q6 — defence in depth. IPAddressDeny=any + IPAddressAllow=localhost: even a compromised relay process cannot open a connection to anywhere but loopback. With DynamicUser, ProtectSystem=strict and the rest. Unrun (see Not verified).

**Q6 — defence in depth.** `IPAddressDeny=any` + `IPAddressAllow=localhost`: even a compromised relay process cannot open a connection to anywhere but loopback. With `DynamicUser`, `ProtectSystem=strict` and the rest. Unrun (see *Not verified*).
@@ -0,0 +115,4 @@
# Caddy's own logger: errors about TLS handshakes or upstreams can name a client's address.
# No log is the rule; an operator who needs one turns it on for a while, knowing why.
logFormat = ''
output discard
Author
Owner

Q4 — no log at all from Caddy. Not access log off, errors on: Caddy's TLS-handshake and upstream errors can carry a client address. The cost is that an operator debugging a problem must switch logging on, and the README says what that writes.

**Q4 — no log at all from Caddy.** Not *access log off, errors on*: Caddy's TLS-handshake and upstream errors can carry a client address. The cost is that an operator debugging a problem must switch logging on, and the README says what that writes.
@@ -0,0 +125,4 @@
extraConfig = ''
reverse_proxy 127.0.0.1:${toString cfg.port} {
# The relay never learns who connected: Caddy adds these by default.
header_up -X-Forwarded-For
Author
Owner

Q5 — the relay never learns who connected. Caddy adds X-Forwarded-For by default; it and X-Real-IP and Forwarded are removed. The relay logged nothing anyway; now it does not even receive the address. Not tested: the VM test checks logs, not headers. A header check would need the relay to echo headers, which it must never do.

**Q5 — the relay never learns who connected.** Caddy adds `X-Forwarded-For` by default; it and `X-Real-IP` and `Forwarded` are removed. The relay logged nothing anyway; now it does not even receive the address. Not tested: the VM test checks logs, not headers. A header check would need the relay to echo headers, which it must never do.
@@ -0,0 +76,4 @@
# Nowhere on the server: not in the journal, not under /var/log, not in the relay's data.
server.succeed("journalctl --sync")
server.fail("journalctl --no-pager -o verbose | grep -F '" + client_ip + "'")
Author
Owner

Q7 — test honesty. The test greps for the client's address after a session with successes, refusals (404, 400) and a 507. It has no positive control: if the grep could never match (a wrong interface, a different address format), it would pass vacuously. A control that turns Caddy's log on and expects a match is the next thing to add when it first runs on Linux.

**Q7 — test honesty.** The test greps for the client's address after a session with successes, refusals (404, 400) and a 507. It has no positive control: if the grep could never match (a wrong interface, a different address format), it would pass vacuously. A control that turns Caddy's log on and expects a match is the next thing to add when it first runs on Linux.
@@ -94,6 +94,12 @@ unknown fields. A blob is at most 256 KiB, and a KeyPackage at most 16 KiB.
- A wrong token, an unknown id and a malformed id all give the same bare **404**, so nobody can probe
what exists.
- **Quotas** *(added 2026-11-16, F23, so a relay can face the internet; `.agents/features/home-relay.md`)*:
Author
Owner

Q3 — protocol change: a new status, 507. No new field, nothing new stored. Old clients see a non-2xx, which they already treat as try again later. Documented with date and reason, as CLAUDE.md section 3 asks. Abuse is bounded, not prevented: a flood can still fill the caps. Proof of work or invite-only mailbox creation is for a later protocol version.

**Q3 — protocol change: a new status, 507.** No new field, nothing new stored. Old clients see a non-2xx, which they already treat as *try again later*. Documented with date and reason, as CLAUDE.md section 3 asks. Abuse is bounded, not prevented: a flood can still fill the caps. Proof of work or invite-only mailbox creation is for a later protocol version.
Author
Owner

Merged into main with --no-ff as 0e6be38280 (remote hash verified). The self-review is review 380 on this PR.

Merged into `main` with `--no-ff` as 0e6be382803367f19a831cd90d32108175bb69b3 (remote hash verified). The self-review is review 380 on this PR.
mnovak closed this pull request 2026-11-16 11:40:50 +01:00
Some checks are pending
ci / check (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.