Skip to content

trustedcoin: keep the bitcoind RPC password out of the startup log - #193

Closed
ostermayer wants to merge 2 commits into
bitcoinix:masterfrom
ostermayer:trustedcoin-redact-rpc-password
Closed

ostermayer wants to merge 2 commits into
bitcoinix:masterfrom
ostermayer:trustedcoin-redact-rpc-password

Conversation

@ostermayer

Copy link
Copy Markdown
Collaborator

Fixes #191.

Trustedcoin 0.8.7 logs the bitcoind RPC settings at startup, password included (main.go:192, same on master). modules/clightning.nix always writes bitcoin-rpcuser and bitcoin-rpcpassword into the Core Lightning config, so with the plugin enabled the public RPC password lands in the lightningd journal. The operator account is in systemd-journal, so it can read that line, and so can anything that ships the journal elsewhere.

This adds a one-line patch to pkgs/trustedcoin that prints password: <redacted> and drops the argument. go.mod is untouched, so vendorHash stays. I'll send the same change upstream so the patch can go away later.

Checks on the KVM host:

  • nix build .#trustedcoin builds. strings on the binary finds the redacted format string once and the old password: %s string not at all.
  • The second commit extends the trustedcoin test: it waits for the redacted settings line and then checks that the clightning journal does not contain the public RPC password, so the password can't come back unnoticed. Run on its own (./test/run-tests.sh -s "{ imports = [ scenarios.trustedcoin ]; tests = mkForce { trustedcoin = true; }; }") it passes on this branch. The same test against the unpatched package fails, because the redacted line never appears while the clear text one does, so it does catch the leak.
  • The full trustedcoin scenario is flaky on master and on this branch for a reason that has nothing to do with the patch: when clightning restarts during the run, trustedcoin answers tip: 0 before its bitcoind check finishes, lightningd aborts with bitcoind has gone backwards from 70 to 0 blocks!, and the unit sits in its 10 minute start-post timeout before systemd retries. Master happened to recover on the retry, my two runs on this branch did not. That is trustedcoin: lightningd aborts with "bitcoind has gone backwards" when clightning starts right after bitcoind, and the unit then waits 10 minutes before systemd retries #192.

Found by the review gate on the tree of #190 (Codex GPT-6 Astra, xhigh). Fable 5.1 made the patch. Codex GPT-5.6 Sol (xhigh) reviewed it, found no defect in the patch and asked for the test, which the second commit adds.

Review gate on a57d1a2 (GLM 5.3 max with the Codex GPT-6 Astra xhigh second opinion, report 2026-10-31-085605): 3 findings, none in pkgs/trustedcoin or test/suite/regtest.py, all known. The DeepSeek V4.1 Flash 1017 (max) plus GLM 5.3 (max) run on the first commit 987f963 (report 2026-10-31-085155, Astra second opinion): 6 findings, none in pkgs/trustedcoin, all known issues or informational.

When trustedcoin finds bitcoin-rpcuser and bitcoin-rpcpassword in the
Core Lightning config, it logs both at startup together with the host
and port. modules/clightning.nix always writes those two options, so
with the plugin enabled the public RPC password ends up in the
lightningd journal, which the operator account can read because it is
in systemd-journal.

The patch replaces the password in that one log line with <redacted>
and drops the argument. No dependency changes, so vendorHash stays.
The trustedcoin test only checked that RPC works, so the password could
come back into the startup line without anything failing. It now waits
for the redacted settings line and then greps the clightning journal for
the public RPC password, which must not be there.
@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: packages pkgs/ and flake pins labels Oct 31, 2026
@prusnak

prusnak commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Please file an issue in the upstream repository. This bug should be fixed there.

@ostermayer

Copy link
Copy Markdown
Collaborator Author

Upstream PRs: nbd-wtf/trustedcoin#43 for this redaction, nbd-wtf/trustedcoin#44 for the restart race in #192.

@prusnak

prusnak commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

closed in favor of upstream PR nbd-wtf/trustedcoin#43

@prusnak prusnak closed this Oct 31, 2026
@ostermayer
ostermayer deleted the trustedcoin-redact-rpc-password 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: ci .github/, test/, dev/ area: packages pkgs/ and flake pins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trustedcoin: the plugin logs the public bitcoind RPC password at startup, so it ends up in the journal

2 participants