Keep the secrets the first start minted, so a second start can still read the vault - #415
Open
zopeVaibhav wants to merge 1 commit into
Open
Conversation
zopeVaibhav
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso and
tylerslaton
as code owners
September 7, 2026 11:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The desktop shell generated all six of its deployment secrets on every press of Start. Five of them
can be rotated harmlessly, because the processes that share them restart together from the same
file.
KEY_ENCRYPTION_KEYcannot: it encrypts the credential vault,stack::downrunscompose downwithout-v, and the volume holding the vault outlives the key that opened it. The secondsession of an installed OpenBot therefore met credentials it could no longer decrypt, and the error
that came back was
OperationError: The operation failed for an operation-specific reason— AES-GCMrefusing a tag, naming neither the key, nor the credential, nor the restart.
COMPUTER_TOKENis the second one that matters, for a different reason. The supervisor bakes it intoa Bot's computer container as an environment variable at create time (
supervisor/src/index.ts:96),Stop leaves those containers stopped rather than removed so the Bot keeps its volumes
(
stack.rs:154), andensurestarts an existing owned container and otherwise leaves it "exactly asit is" (
supervisor/src/docker.ts:422). Those containers are not Compose services, sostack::upnaming every service does not recreate them. After a restart the server held a token no earlier
computer had.
writenow keeps the secrets an existing.envalready carries and generates only what is notalready there. Two values are deliberately not carried: anything published in this repository — the
.env.examplekey andstart.sh's threeopenbot-dev-*fallbacks — and aKEY_ENCRYPTION_KEYthatis not a base64 32-byte value, which
server/src/config.tsrefuses to start on. Carrying eitherwould keep an install broken in a way nothing on screen could undo.
scripts/start.shalready works this way for the two secrets it generates:MANAGED_AGENT_TOKENandAGENT_TOOL_TOKENare generated once, written back to.env, and reused on later runs. This is thatrule applied to the shell, and to all six.
The guard lives in
writerather than incomposebecausewriteis already the function thatreads the existing file and decides, per line, what to keep.
Fixes #414.
Where it runs
This runs on one laptop, in a Tauri shell, before any server process exists. It is a desktop
installer writing a file, not a request path.
.env,which is the thing being made to outlive a restart rather than new state being introduced.
shell that raises a single-machine deployment, and
OPENBOT_SINGLE_USER=trueis written twolines away. A hosted OpenBot never runs it. The failure it fixes is the desktop analogue of a
replica bug — one process regenerating a secret another process's data depends on — but the
second process here is the next launch of the same one.
main.rshands thewindow over to the instance that already exists.
everything_that_is_not_a_secret_still_takes_this_run_s_valuepins that a port moved betweenversions is still written fresh rather than carried.
Boundary and audit
server code is touched.
has no audit trail and predates the server it starts.
trusted at all. The one new input is the deployment's own
.env, and the two ways it can lie —a published value, or a key the server would refuse — are both rejected rather than carried.
Changelog
CHANGELOG.mdunderUnreleased.Proof
Every command
.github/workflows/desktop.ymlruns on this tree, on this machine:The bug reproduces, and the tests catch it. With the carry-forward line removed and everything else
in this branch left in place, three of the new tests fail and the rest still pass:
Restored:
22 passed; 0 failedforenv::,78 passed; 0 failedfor the crate.The consequence was checked against the real code rather than argued. Encrypting under the key the
first Start wrote and decrypting under the key the second Start wrote, through
server/src/credentials.tsunmodified:Nothing outside
desktop/changed, and the repository is unaffected:bunx biome lint --error-on-warnings .clean over 573 files,bun run typecheckclean inapp,serverandworker.bun testgives2443 pass, 23 skip, 3 failon this branch and the identical2443 pass, 23 skip, 3 failonmain— the three are the handoff-queue lease tests, which fail on aclean checkout and are not touched here.
Not covered: the shell was not installed and driven end to end for this, because reproducing the
original failure that way means installing a container engine, letting the first Start pull five
images, storing a credential through the UI, quitting and starting again. The two halves were each
run instead — the file the shell writes, in Rust, and the decryption the server does, in TypeScript —
and they meet at the value of
KEY_ENCRYPTION_KEY.desktop.ymlsays thecorejob is "the onlyjob that runs the assertions about what the shell writes into
.env", which is the level this istested at.