fix(up): don't pass OLM secret via argv to the detached subprocess - #128
Open
BYBEYER wants to merge 1 commit into
Open
fix(up): don't pass OLM secret via argv to the detached subprocess#128BYBEYER wants to merge 1 commit into
BYBEYER wants to merge 1 commit into
Conversation
In detached mode the parent re-spawned itself with --id/--secret on the command line of the elevated subprocess, leaving the device secret visible to every local process for the daemon's entire lifetime (/proc/<pid>/cmdline is world-readable), plus transiently in the sudo sh -c wrapper argv. When the credentials come from the account store, stop passing them via argv entirely: the subprocess already resolves the invoking user's config dir via SUDO_USER and reads the store for the session token, so it now reads the OLM credentials from the same place. Explicitly passed --id/--secret flags keep working unchanged. The subprocess also skips EnsureOlmCredentials (the parent just ran it and saved the result), which avoids duplicate API calls and prevents the root subprocess from ever writing the user-owned account store. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Live verification done on a real deployment (Fedora Atomic/Bazzite host, Pangolin server on 1.10.x, account-store credentials, detached mode):
|
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.
Fixes #127
Problem
In detached mode,
pangolin upre-spawns itself as an elevated subprocess and passes the OLM device credentials on the command line (--id/--secret), even when they come from the account store. The secret is visible to every local process viaps//proc/<pid>/cmdline(world-readable) — transiently in thesudo sh -cwrapper argv, and for the entire lifetime of the detached daemon. See #127 for full details and reproduction.Change
When the credentials come from the account store (
credentialsFromKeyring), the parent no longer passes--id/--secretto the subprocess. The subprocess already resolves the invoking user's config dir viaSUDO_USERand reads the account store there (it does this today for the session token), so it now reads the OLM credentials from the same place.Details:
isSubprocessis computed early (moved up from the detach block) so the credential-resolution path can distinguish the elevated subprocess from a direct invocation.EnsureOlmCredentials: the parent ran it and saved the result moments earlier, so re-running it would only duplicate API calls — and in the worst case have the root subprocess write the user-ownedaccounts.json.--id/--secretflags keep working exactly as before (still forwarded via argv; the user supplied them on their own command line to begin with).Testing
go build ./...,go vet ./...,go test ./...clean on Linux (go 1.26.5, amd64).pangolin up, checking/proc/<pid>/cmdlineand that the client connects/registers) is in progress; I'll follow up with the result in a comment.🤖 Generated with Claude Code