Cross-user isolation: 4 fixes + two-user leak suite (#409) #437

Merged
kayg merged 6 commits from train/2026-10-15l into dev 2026-10-15 11:53:08 +00:00
Owner

Audit half of #409: cross-user isolation. Findings and the sharing grill are posted on #409.

Fixes, each in its own commit with a regression test (verified to fail without the fix):

  • Critical notes.restore / notes.forget turned the client's id into Trash/<id>.md unchecked; an id with ../ reached another person's Home (restore moved their note into yours, forget deleted it). Ids are now checked before any path is built.
  • High a session cookie sent from another site's page (e.g. a sibling preview./next. host, which SameSite=Lax still sends cookies to) was accepted by the API and the live websocket. Cookies now count only when there is no Origin header or it is this server's own. Bearer tokens are unaffected. Needs --origin to match the address people use (already true in prod and e2e).
  • Medium a refused account.revoke of someone else's device id still signed that device out until restart.
  • Low account.passkey-add-finish let another person cancel your add-passkey prompt.

Merge gate (ADR 0007):

  • crates/calternal/src/isolation.rs: Bob runs every action from engine.actions() against Alice's ids and a random id; no answer may carry Alice's marker, and both must answer alike. New actions are covered without editing the test. Also a room-join check.
  • crates/auth/tests/isolation.rs: two signed-in people (devices, passkeys, prompts, cookie origin).
  • backdrops: a two-user upload test (reads, list, delete, per-user dedupe).
  • crates/calternal/src/app.rs: the server wiring moved out of main so it can be shared.

Checks: cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace (412 passed, 0 failed).

Refs #409

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

(Replaces #419, merged with current dev. Review on #419.)

Audit half of #409: cross-user isolation. Findings and the sharing grill are posted on #409. Fixes, each in its own commit with a regression test (verified to fail without the fix): - **Critical** `notes.restore` / `notes.forget` turned the client's id into `Trash/<id>.md` unchecked; an id with `../` reached another person's Home (restore moved their note into yours, forget deleted it). Ids are now checked before any path is built. - **High** a session cookie sent from another site's page (e.g. a sibling `preview.`/`next.` host, which SameSite=Lax still sends cookies to) was accepted by the API and the live websocket. Cookies now count only when there is no `Origin` header or it is this server's own. Bearer tokens are unaffected. Needs `--origin` to match the address people use (already true in prod and e2e). - **Medium** a refused `account.revoke` of someone else's device id still signed that device out until restart. - **Low** `account.passkey-add-finish` let another person cancel your add-passkey prompt. Merge gate (ADR 0007): - `crates/calternal/src/isolation.rs`: Bob runs **every action from `engine.actions()`** against Alice's ids and a random id; no answer may carry Alice's marker, and both must answer alike. New actions are covered without editing the test. Also a room-join check. - `crates/auth/tests/isolation.rs`: two signed-in people (devices, passkeys, prompts, cookie origin). - backdrops: a two-user upload test (reads, list, delete, per-user dedupe). - `crates/calternal/src/app.rs`: the server wiring moved out of `main` so it can be shared. Checks: `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace` (412 passed, 0 failed). Refs #409 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T (Replaces #419, merged with current dev. Review on #419.)
notes.restore and notes.forget turned the client's id straight into
Trash/<id>.md. An id with ../ resolved into another person's Home (or
anywhere on disk): restore moved their note into the caller's Notes,
forget deleted it. Every id-to-path function in trash.rs now checks the
id first (the same rule as note ids: letters, digits and dashes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
revoke marked the installation id revoked in memory before checking it
belonged to the caller, so revoking someone else's device id answered
not_found but signed that device out until the next restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
passkey-add-finish removed the prompt before checking whose it was, so
another person could cancel it. take_add leaves other people's prompts
alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
SameSite=Lax still sends the cookie from sibling hosts on the same site
(preview., next.), so their pages could open the live websocket and act
as the signed-in person. When a browser sends an Origin that isn't this
server's, the cookie is ignored; bearer tokens are unaffected.

tests/isolation.rs: two signed-in people; devices, passkeys, prompts and
the cookie (covers this and the two commits before it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
app.rs holds the server wiring, so main and the suite build the same
app. isolation.rs: Alice seeds marked data, Bob runs every action from
engine.actions() against her ids and a random id; no answer may carry
the marker and both must answer alike. New actions are covered without
touching the test (ADR 0007). Plus a room join check, and a two-user
upload test in backdrops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
notes: tidy the Trash isolation test for clippy (#409)
Some checks failed
CI / web (pull_request) Failing after 35m50s
CI / server (pull_request) Successful in 23s
CI / rust (pull_request) Failing after 2m6s
f741f73e02
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
kayg merged commit 8484618bca into dev 2026-10-15 11:53:08 +00:00
kayg deleted branch train/2026-10-15l 2026-10-15 11:53:09 +00:00
Sign in to join this conversation.
No reviewers
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
kayg/calternal!437
No description provided.