Repository navigation
lndconnect: keep the macaroon and the rune out of sed's argv - #77
Merged
Merged
Conversation
The clightning-rest and clnrest variants of the connect helper rewrote the URL with sed, with the admin macaroon (hex) or the admin rune spliced into the sed program. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs. Use bash parameter substitution instead, which spawns no process. Same class as the rpcauth argv fix (bitcoinix#44).
ostermayer
added a commit
to ostermayer/bitcoinix
that referenced
this pull request
Oct 17, 2026
`rtl-setup-config` spliced the RTL `multiPass` into a sed program with `$(cat ...)`. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs, and the password guards an lnd admin macaroon copy and the clnrest admin rune. Let jq read the secret file itself (`--rawfile`) and set the field. No process ever sees the password as an argument, and jq escapes it as JSON, which sed did not (a password with `|`, `&` or `"` broke the config before). Same class as the rpcauth argv fix (bitcoinix#44) and the lndconnect fix (bitcoinix#77).
ostermayer
added a commit
to ostermayer/bitcoinix
that referenced
this pull request
Oct 17, 2026
The backend's `preStart` spliced the public RPC password into a sed program with `$(cat ...)`. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs. Let jq read the secret file itself (`--rawfile`) and set `CORE_RPC.PASSWORD`. No process sees the password as an argument, and jq escapes it as JSON. Same class as the rpcauth argv fix (bitcoinix#44) and the lndconnect fix (bitcoinix#77).
This was referenced Oct 17, 2026
prusnak
approved these changes
Oct 18, 2026
seberm
pushed a commit
to ostermayer/bitcoinix
that referenced
this pull request
Oct 19, 2026
`rtl-setup-config` spliced the RTL `multiPass` into a sed program with `$(cat ...)`. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs, and the password guards an lnd admin macaroon copy and the clnrest admin rune. Let jq read the secret file itself (`--rawfile`) and set the field. No process ever sees the password as an argument, and jq escapes it as JSON, which sed did not (a password with `|`, `&` or `"` broke the config before). Same class as the rpcauth argv fix (bitcoinix#44) and the lndconnect fix (bitcoinix#77).
prusnak
pushed a commit
to ostermayer/bitcoinix
that referenced
this pull request
Oct 20, 2026
The backend's `preStart` spliced the public RPC password into a sed program with `$(cat ...)`. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs. Let jq read the secret file itself (`--rawfile`) and set `CORE_RPC.PASSWORD`. No process sees the password as an argument, and jq escapes it as JSON. Same class as the rpcauth argv fix (bitcoinix#44) and the lndconnect fix (bitcoinix#77).
msgilligan
pushed a commit
to msgilligan/bitcoinix
that referenced
this pull request
Nov 8, 2026
`rtl-setup-config` spliced the RTL `multiPass` into a sed program with `$(cat ...)`. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs, and the password guards an lnd admin macaroon copy and the clnrest admin rune. Let jq read the secret file itself (`--rawfile`) and set the field. No process ever sees the password as an argument, and jq escapes it as JSON, which sed did not (a password with `|`, `&` or `"` broke the config before). Same class as the rpcauth argv fix (bitcoinix#44) and the lndconnect fix (bitcoinix#77).
msgilligan
pushed a commit
to msgilligan/bitcoinix
that referenced
this pull request
Nov 8, 2026
The backend's `preStart` spliced the public RPC password into a sed program with `$(cat ...)`. A program argument is visible to every local user through /proc/<pid>/cmdline for as long as sed runs. Let jq read the secret file itself (`--rawfile`) and set `CORE_RPC.PASSWORD`. No process sees the password as an argument, and jq escapes it as JSON. Same class as the rpcauth argv fix (bitcoinix#44) and the lndconnect fix (bitcoinix#77).
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.
Problem
modules/lndconnect.nixbuilds thelndconnect-clightningandlnconnect-clnresthelpers. Both rewrite the URL withsed. The sed program carries the admin macaroon in hex, or the admin rune, as part of the command line (lines 157 to 171 onmaster). Every local user can read/proc/<pid>/cmdlinefor as long as sed runs. That is the same class as the rpcauth argv problem in #44, with a smaller window and a credential that gives full control of the node.Change
Use bash parameter substitution instead of sed.
${url/#lndconnect/c-lightning-rest}replaces the prefix.${url/macaroon=*/macaroon=$macaroonHex}replaces the last fragment. No process starts, so nothing shows up in a command line. The clnrest branch reads the rune into a variable first and does the same.Testing
defaultscenario (lndconnect-onion-clightning,lnconnect-onion-clnresttests parse the helper output)wireguard-lndconnectscenario (lndconnect-clightning-wg,lnconnect-clnrest-wg)A byte-for-byte comparison of the old sed output and the new substitution over 1,228 generated URLs (both certificate modes, padded and unpadded runes) found no difference.
Models used on this PR: Fable 5.1 and Opus 5.5 for the changes. Kimi K3 (max), GLM 5.3 (max), DeepSeek V4.1 Flash 1017 (max) and GPT-6 Astra (xhigh) reviewed it in the audit runs over the open branches. None found a problem in the changed files.