Skip to content

Strict channels: modified-client tests, rewind and roster fixes, who changed while away - #2470

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/2251-strict-channels-rest
Nov 27, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/2251-strict-channels-rest

Conversation

@jan-runkel-zeitgleich

Copy link
Copy Markdown
Collaborator

Part of #2251 (the rest of #1924, docs/e2ee.md §4.6.2). teamcraft-crypto/strict-channels stays off; nothing here turns it on.

Modified-client tests in the core suite

  • teamcraft-core gets a test-hooks feature, enabled only through a dev-dependency of the crate on itself, so no app build carries it: Client::commit_unchecked_change signs and commits a membership change past the committer's own verdict (via teamcraft_crypto::mls::test_hooks::set_unchecked_commits), the way a modified client could (finding 3).
  • FakeServer::withhold_roster(reader, last_shown) shows one reader an older workspace roster.
  • New tests in tests/suite/strict_channels.rs: a plain member's signed removal refused alike on every member and "Remove {name} and continue" through the rewind; a plain member's signed addition refused alike and "Continue"; two admins continuing at once (one removes, one doesn't; both remove); a withheld roster that makes a device fall out and an admin's welcome that brings it back; a member's welcome held until the user takes it after strict_rejoin_wait (accept_strict_rejoin); a lagging roster on an honest server.

Bugs the tests found, fixed

  1. Two admins continuing at once split the group. The second admin's rewind dropped the first admin's continuation. The first admin and the members who had already merged it were past that epoch, so the group split. A rewind now names the refused commit it replaces (PostMlsCommitRequest.replaces, the stop's queue entry). The server (DB transaction, rewind_mls) rewinds only while that commit still holds the epoch. Otherwise it answers with an epoch conflict, and the second admin catches up: the first commit ends its stop. A rewind without the field (an older app) behaves as before. Includes a new sqlx query (.sqlx/query-c9d2…json, generated for that query only) and a server test.
  2. A workspace signer's commit stopped devices instead of being judged on the roster. The core processed the commit, got a retry error, read the roster and processed it again on the same group. But openmls spends the epoch's handshake secret on the first decrypt, so the second try failed ("deleted to preserve forward secrecy"), and that counts as a refusal, so the device stopped. Now the app decides from the unencrypted authenticated data whether the commit may need the roster (new mls::strict_commit_reads_roster, with crypto tests). It reads the roster first, as the design says, and processes the commit once. If the roster still can't judge the signer, the device moves past the entry and asks to be added back right away. This also fixes a stop on an honest server: a removal by a workspace admin promoted just before was refused on the device's older roster, and that device stopped with nobody else stopped to continue from.
  3. A welcome back skipped the sender check when the device had kept its group. join_from_welcome drops the group before opening the welcome, which also deleted the rejoin record. So check_strict_welcome saw no fallen-out device and opened any member's welcome at once (finding 2 again). The check now gets is_rejoin from its caller.

Who is new or gone after an add-back (tree diff lines)

  • When a device that knew the channel strict drops its group for a welcome back, it keeps the group's users until a welcome is opened, also across held ones. After it is back (an admin's welcome, or the user's word), it writes one derived line per user who is new or gone: ConversationEvent::ChangedWhileAway. The line is derived from the welcome it opened, and a member's message of that kind stays hidden. The held welcome's joined/gone are now against that tree too; before, they were against an empty one.
  • Desktop and web render it (ws-joined-while-away, ws-gone-while-away, en and de). Android and iOS pass over the event for now: Strict channels: show the lines of who is new or gone after an add-back on Android and iOS #2464.

Not in this PR

Checks

  • cargo test -p teamcraft-core --features ui --test suite: all 1218 pass (with CI's RUST_MIN_STACK). The strict-channel module alone: 34 tests.
  • cargo test -p teamcraft-crypto --lib strict: 60 pass.
  • cargo test -p teamcraft-server --features integration --test suite mls::rewind: 6 pass, against the local test Postgres.
  • teamcraft-ui workspace_event tests and the core lib tests pass.
  • Clippy with -D warnings and fmt on the touched crates (core with ui, with sealed-sqlite alone, and with strict-channels).
  • Not built: the wasm off-module (strict_channels_off.rs), because this machine has no wasm target. CI covers it.

Refs #2251

🤖 Generated with Claude Code

Rest of #1924, part of #2251. `teamcraft-crypto/strict-channels` stays
off; nothing here turns it on.

Tests with a modified client in the core suite: the core's `test-hooks`
feature (a dev-dependency of its own suite only, never in an app) gives
`Client::commit_unchecked_change`, which commits a signed change past the
committer's own verdict via crypto's `test_hooks::set_unchecked_commits`,
and `FakeServer::withhold_roster` shows one reader an older roster.

They found three bugs:

- Two admins continuing at once: the second rewind dropped the first
  admin's continuation, which its committer and the members who merged
  it were already past, so the group parted. A rewind now names the
  refused commit it replaces (`replaces`); the server rewinds only while
  that commit holds the epoch, else it is an epoch conflict and the
  second admin catches up. Without the field, as before.
- A workspace signer's commit in a strict channel was processed, the
  roster read and the commit processed again on the same group, but
  openmls spends the epoch's handshake secret on the first decrypt: the
  retry failed ("deleted to preserve forward secrecy") and the device
  stopped. The app now decides from the unencrypted authenticated data
  whether the commit may need the roster
  (`mls::strict_commit_reads_roster`), reads it first and processes once;
  a roster that still can't judge makes the device go past the entry
  and ask to be added back. This also fixes an honest-server stop: a
  removal by a just-promoted workspace admin was refused on the
  device's older roster, and nobody else had stopped to continue.
- A welcome back was opened from any member when the device had kept
  its group: dropping the group for the welcome dropped the rejoin
  record with it, so the sender check never ran. The check now takes
  the rejoin from its caller.

After an add-back into a channel the device knew strict, it writes a
line per user new or gone since its last tree (kept when the group is
dropped for the welcome): `ConversationEvent::ChangedWhileAway`, derived
and hidden if a member sends one; desktop and web render it (en, de).
Android and iOS: #2464. The held welcome's joined/gone are against that
tree too (before: against none).

Refs #2251

Signed-off-by: Jan Runkel <jan.runkel@zeitgleich.de>
@jan-runkel-zeitgleich jan-runkel-zeitgleich added bug Something isn't working security Security hardening (report vulnerabilities privately, not as issues) ci Run CI, Android, iOS and web-size workflows on this pull request labels Nov 27, 2026
…a hook

The web build without `strict-channels` compiles `strict_channels_off.rs`,
which has no `strict_stop`: `post_commit` asks `strict_rewind_replaces`
instead (none in that build).

Refs #2251

Signed-off-by: Jan Runkel <jan.runkel@zeitgleich.de>
@github-actions
github-actions Bot enabled auto-merge (squash) November 27, 2026 00:13
@github-actions
github-actions Bot merged commit e30f52c into main Nov 27, 2026
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci Run CI, Android, iOS and web-size workflows on this pull request security Security hardening (report vulnerabilities privately, not as issues)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant