Skip to content

lndconnect: keep the macaroon and the rune out of sed's argv - #77

Merged
seberm merged 2 commits into
bitcoinix:masterfrom
ostermayer:lndconnect-no-secret-argv
Oct 19, 2026
Merged

seberm merged 2 commits into
bitcoinix:masterfrom
ostermayer:lndconnect-no-secret-argv

Conversation

@ostermayer

@ostermayer ostermayer commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

modules/lndconnect.nix builds the lndconnect-clightning and lnconnect-clnrest helpers. Both rewrite the URL with sed. The sed program carries the admin macaroon in hex, or the admin rune, as part of the command line (lines 157 to 171 on master). Every local user can read /proc/<pid>/cmdline for 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

Run (KVM box) Result
default scenario (lndconnect-onion-clightning, lnconnect-onion-clnrest tests parse the helper output) PASS
wireguard-lndconnect scenario (lndconnect-clightning-wg, lnconnect-clnrest-wg) PASS

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.

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).
@prusnak prusnak added area: modules modules/ and pkgs/lib.nix type: security Hardening or vulnerability (public-safe only) labels Oct 18, 2026
@seberm
seberm merged commit 278969d into bitcoinix:master Oct 19, 2026
17 checks passed
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).
@ostermayer
ostermayer deleted the lndconnect-no-secret-argv branch November 8, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: modules modules/ and pkgs/lib.nix type: security Hardening or vulnerability (public-safe only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants