Account deletion, storage quotas, rate and size limits, server hardening #12

Merged
backmeupplz merged 10 commits from account-delete-quotas-rate-limits into main 2026-11-27 19:57:38 +00:00
Owner

Server pieces for a hosted Plaintext server, account deletion (App Store guideline 5.1.1(v)), and server hardening.

Account deletion

  • DELETE /v1/account is signed by the login key over account_delete_message (±120 s, and the server's host as for a login), so a session token alone can't delete an account.
  • It deletes the account and its agents, sessions, inbox, share links, invites and the vaults nobody else uses.
  • Shared vaults stay with the others: the server stops serving the deleted account, and pulls list it under gone until an owner's device removes it with a new key.
  • The only owner of a vault others use can't delete their account (409, and the client names the vaults), and neither can the admin of a server others use.
  • Session::delete_account; the CLI plaintext account delete asks for the password again and has you type the username.

Storage quotas

  • PLAINTEXT_QUOTA_MB counts item blobs and files in the vaults an account created, plus the share links and messages it and its agents sent.
  • Writes that would add past it get 413. Reads, deletes and key replacement always work. Unset means unlimited.
  • GET /v1/account reports quota and usage.

Rate limits (open servers)

  • 10 signups and 30 failed logins per hour per client address (IPv6 per /64).
  • A correct login always works.
  • PLAINTEXT_TRUST_PROXY=1 reads the last X-Forwarded-For entry.

Request size limits

  • Bodies are 64 KiB by default. The keyring, messages and links take 2 MiB, vault writes 32 MiB and files 64 MB.
  • The larger routes check the session before reading the body.

Server hardening

  • Without PLAINTEXT_URL, only localhost logins are accepted, and the server warns at startup.
  • An open server needs a setup code while it has no accounts.
  • Signed documents are size-limited as a whole. Rosters list at most 1000 different members.
  • Inbox responses come in pages.
  • Sessions expire after 30 days, or a shorter ttl on login.
  • Disabling a person disables their agents.
  • Expired rows are cleaned up periodically.
  • HEAD on share links gets 405, and responses carry Cache-Control: no-store.
  • A lock poisoned by a panic no longer fails later requests.

Also merges main (sync problems and remove_members combined) and rebuilds docs/s. DESIGN.md, README and PARITY.md are updated.

Tests in client/src/tests.rs: account_deletion, storage_quota, signup_and_login_rate_limits, request_size_limits, server_hardening, plus server unit tests (migrations, limiter, localhost check).

🤖 Generated with Claude Code

Server pieces for a hosted Plaintext server, account deletion (App Store guideline 5.1.1(v)), and server hardening. **Account deletion** - `DELETE /v1/account` is signed by the login key over `account_delete_message` (±120 s, and the server's host as for a login), so a session token alone can't delete an account. - It deletes the account and its agents, sessions, inbox, share links, invites and the vaults nobody else uses. - Shared vaults stay with the others: the server stops serving the deleted account, and pulls list it under `gone` until an owner's device removes it with a new key. - The only owner of a vault others use can't delete their account (409, and the client names the vaults), and neither can the admin of a server others use. - `Session::delete_account`; the CLI `plaintext account delete` asks for the password again and has you type the username. **Storage quotas** - `PLAINTEXT_QUOTA_MB` counts item blobs and files in the vaults an account created, plus the share links and messages it and its agents sent. - Writes that would add past it get 413. Reads, deletes and key replacement always work. Unset means unlimited. - `GET /v1/account` reports `quota` and `usage`. **Rate limits** (open servers) - 10 signups and 30 failed logins per hour per client address (IPv6 per /64). - A correct login always works. - `PLAINTEXT_TRUST_PROXY=1` reads the last `X-Forwarded-For` entry. **Request size limits** - Bodies are 64 KiB by default. The keyring, messages and links take 2 MiB, vault writes 32 MiB and files 64 MB. - The larger routes check the session before reading the body. **Server hardening** - Without `PLAINTEXT_URL`, only localhost logins are accepted, and the server warns at startup. - An open server needs a setup code while it has no accounts. - Signed documents are size-limited as a whole. Rosters list at most 1000 different members. - Inbox responses come in pages. - Sessions expire after 30 days, or a shorter `ttl` on login. - Disabling a person disables their agents. - Expired rows are cleaned up periodically. - `HEAD` on share links gets 405, and responses carry `Cache-Control: no-store`. - A lock poisoned by a panic no longer fails later requests. Also merges main (sync `problems` and `remove_members` combined) and rebuilds `docs/s`. DESIGN.md, README and PARITY.md are updated. Tests in `client/src/tests.rs`: `account_deletion`, `storage_quota`, `signup_and_login_rate_limits`, `request_size_limits`, `server_hardening`, plus server unit tests (migrations, limiter, localhost check). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DELETE /v1/account is signed by the login key and takes the account's agents,
inbox, links and unshared vaults with it; shared vaults stay with the others,
whose owners' devices replace the key (gone members in the vault response).
The only owner of a vault others use, and the admin of a server others use,
can't delete their account. PLAINTEXT_QUOTA_MB limits the items and files in
the vaults an account created; open servers rate-limit signups and failed
logins per address (PLAINTEXT_TRUST_PROXY reads X-Forwarded-For).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A removed creator stops paying for the vault; deleted creators hand off to a remaining member.
- Only an owner is refused deletion when no other owner remains.
- Rate limits reserve a slot before the request, read the last X-Forwarded-For line,
  clear per hour and fail closed past 100k addresses.
- revoke() also removes gone and expired members in the same roster version.
- A 413 in one vault no longer stops the others syncing or the account being deleted.
- Deleting an item deletes its unreferenced attachments; attach cleans up on a failed push.
- Client pre-check matches the server's rule; quota parse can't overflow; app() is private.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Server: request size limits, keep serving after a panic
All checks were successful
CI / check (pull_request) Successful in 1m16s
b6ce950c55
Bodies are limited to 64 KiB by default; the keyring, messages and links
take 2 MiB, vault writes 32 MiB and files 64 MB, and those larger routes
check the session before reading the body. A panic while holding a lock
no longer makes every later request fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes: logins pass a full rate-limit table, proxy ports, deletion leftovers
All checks were successful
CI / check (pull_request) Successful in 1m20s
fb5527570a
- A full rate-limit table refuses new signups but lets logins through.
- X-Forwarded-For entries with a port or brackets parse as the address.
- Deleting an account drops its wrapped keys everywhere, ignores an expired
  owner role, and hands vaults only to current, enabled members.
- The creator migration skips a v0 signer who was removed since.
- A member removal that races another device, or is too big, no longer
  stops the rest of the sync.
- PARITY.md and DESIGN.md updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/main' into account-delete-quotas-rate-limits
Some checks failed
CI / wasm (pull_request) Failing after 1m37s
CI / check (pull_request) Successful in 1m28s
44a2713699
# Conflicts:
#	DESIGN.md
#	cli/src/state.rs
#	client/src/lib.rs
#	client/src/tests.rs
Server hardening
Some checks failed
CI / wasm (pull_request) Failing after 1m17s
CI / check (pull_request) Has been cancelled
166eb8d320
- Without PLAINTEXT_URL, logins are accepted only for localhost; the server
  warns at startup. Open signup needs a setup code.
- Signed documents are size-limited as a whole; rosters list at most 1000
  different members; wrapped keys are capped.
- Inbox responses come in pages of up to 32 MiB.
- Expired links, messages and sessions are skipped by requests and deleted
  every ten minutes; links are looked up by id only.
- Share links and messages count toward the sender's quota (an agent's
  owner's).
- Disabling a person disables their agents.
- Sessions expire after 30 days, or a shorter ttl the login asks for.
- HEAD on a share link gets 405; responses carry Cache-Control: no-store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuild docs/s for the core changes
All checks were successful
CI / wasm (pull_request) Successful in 1m21s
CI / check (pull_request) Successful in 1m52s
12060d5376
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes: logins past the limit, strict localhost check, quota payers
All checks were successful
CI / wasm (pull_request) Successful in 1m39s
CI / check (pull_request) Successful in 3m8s
dcfaa67826
- A correct login works even from an address over its failed-login limit.
- The localhost check accepts only a loopback name and an optional port.
- Account deletion is signed for the server's host, like a login.
- Agents never pay for a vault; their owner does.
- A sender can delete a message the recipient hasn't deleted yet.
- An open server needs a setup code only while it has no accounts.
- Tests for the member cap, agent payers and localhost forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test: the roster member cap by its message
All checks were successful
CI / check (pull_request) Successful in 1m55s
CI / wasm (pull_request) Successful in 1m21s
79a790fa44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
backmeupplz changed title from Account deletion, storage quotas, rate and size limits to Account deletion, storage quotas, rate and size limits, server hardening 2026-11-27 19:41:24 +00:00
backmeupplz deleted branch account-delete-quotas-rate-limits 2026-11-27 19:57:38 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
backmeupplz/plaintext!12
No description provided.