Skip to content

fix(browser): bound import's key derivation parameters and report what remove cannot check - #249

Merged
william-monroy merged 3 commits into
mainfrom
fix/browser-remove-import
Dec 3, 2026
Merged

william-monroy merged 3 commits into
mainfrom
fix/browser-remove-import

Conversation

@william-monroy

@william-monroy william-monroy commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two turno-browser patches.

Import: a bound on the key derivation parameters

import read scrypt N (up to 2^20), r (up to 32) and p (up to 16) from the file header and derives the key before the GCM tag can be checked, so a header could ask import for far more memory than export ever uses. Export has always written N 2^17, r 8, p 1 (checked in the history of sealed.ts since it was added in #74). Import now takes r 8 and p 1 only and N at most 2^17 (and at least 2), so its cost is at most export's (about 128 MiB). A header outside these bounds is refused as damaged in parseEnvelope, before any key is derived. Every file export has written still imports. The comment on the ceiling now says what the code does, and the moving-a-session page states the bound.

Remove: say what could not be checked

remove no longer reports complete: true and exits 0 while it could not check something. Each such case goes under left with a new item field "unchecked": true (additive: the top-level --json fields are unchanged), shown as "could not check" in the plan and "not checked" after the run, and the exit code is 1.

  1. Agent config file that does not parse or cannot be read: listed with the file, the error and the step to do by hand. A file with no quoted key equal to the server's name ("browser-school", not browser-school-laptop) cannot hold the entry, so it is not listed (otherwise any broken agent file would make every removal incomplete). Agent JSON files are read with comments and trailing commas allowed: Gemini CLI reads its settings.json with strip-json-comments; Claude Code, Cursor and Copilot CLI write plain JSON, and a lenient read only finds more of what is in a file. After an agent's mcp remove, a file that cannot be read counts as failed, not deleted, in the step and in the final check.
  2. Recorded registration in a file the agent's command does not change (Cursor, GitHub Copilot CLI, Gemini CLI): the file is now read directly; when it holds the identity's entry, it is listed with the step to do by hand.
  3. Vault credentials no index names: turno-core's SecretStore has no listing, and adding a prefix listing is not done here: the macOS security tool has no prefix query (only a dump of every item in the keychain), and libsecret's search matches attributes exactly. So the limit is stated in the help and the reference. What remove can do is not lose the names: an identity.json or vault index that exists but cannot be read is now kept and listed as unchecked (deleting it would lose the names of the secret store items), so a later run, once it is readable, finds and removes them.
  4. Exports made before 0.9.0: stated in the help and the reference.
  5. turno-browser-mcp whose environment cannot be read: listed in the plan and in the final check, with its stop command, instead of being left out. Such a process does not count as a sign that the identity exists. If the final check cannot read the process table, the planned ones stay listed.
  6. Failed items are checked again: one that is gone after all moves to deleted (its error dropped); one that remains stays in failed. Planning and the check now use lstat, so a broken link at an identity path is planned and checked, and an error other than "not there" counts as still there.
  7. Secrets shared with an identity whose identity.json (or turno's mcp.toml) cannot be read: kept and listed as unchecked ("could not check whether ... uses it") instead of deleted.

The help text of remove (and so the generated reference pages) describes the unchecked cases and the limits.

Tests

Only the touched files: test/sealed.test.ts (header with N 2^18 and 2^20, r 4, 16 and 32, p 2 and N 1, written by hand and refused as damaged with no key derived) and test/cli/remove.test.ts (broken agent file, unreachable registration, unknown-environment process with a fake process table, unreadable identity.json and vault index kept and removed on a later run, a broken file naming only browser-school-laptop, a commented Cursor file, a failed item that is gone moving to deleted). Scratch HOME, fake secret store and fake agent commands throughout.

Also run: typecheck, Biome, knip, scripts/no-em-dash.mjs, scripts/changeset-names.mjs, docs generate:check.

… writes

turno-browser import took scrypt N up to 2^20, r up to 32 and p up to 16 from
the file header, and derives the key before the tag can be checked. It now
takes r 8 and p 1, as export has always written, and N at most 2^17, so an
import costs no more memory than an export. A header outside these bounds is
refused as damaged before any key is derived.
turno-browser remove listed nothing and exited 0 when it could not check part
of an identity. It now lists each such case under left with "unchecked": true
and exits 1: an agent config file it cannot read or parse (unless its text does
not hold the server's name), a registration init recorded in a file the
agent's own command does not change, an identity.json or vault index it cannot
read (kept, since they name the secret store items), and a turno-browser-mcp
started with the identity's id whose environment cannot be read.

An agent file that cannot be read after the agent's mcp remove counts as
failed. The final check uses lstat for paths, so an error other than "not
there" is not taken for gone, and checks failed items again. The help states
the limits: vault credentials are found through the sites the vault index
names, and session exports through the record kept since 0.9.0.
…move keeps

A broken agent file is now skipped only when no quoted key names the
identity's server, so browser-school-laptop no longer counts for
browser-school, and agent files are read with comments and trailing commas
allowed (Gemini CLI reads its settings.json with comments). Planning uses
lstat, so a broken link at an identity path is planned and checked. A secret
another identity's identity.json or turno's mcp.toml may use is kept and listed
as unchecked when that file cannot be read. When the final check has no
process table, the processes the plan could not tell apart stay listed.
@william-monroy
william-monroy force-pushed the fix/browser-remove-import branch from 16ea6a5 to 51fe05f Compare December 3, 2026 17:28
@william-monroy
william-monroy merged commit 3e5de71 into main Dec 3, 2026
20 of 23 checks passed
@william-monroy
william-monroy deleted the fix/browser-remove-import branch December 3, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant