Repository navigation
btcpayserver: make NBXplorer's RPC password readable only by NBXplorer - #268
Conversation
viberaven
left a comment
There was a problem hiding this comment.
Reviewed a189a77ca47c.
No actionable findings. NBXplorer still reads its password as the correct service user, bitcoind retains access to the separate HMAC, and BTCPay retains its cookie group without permission to read the password. A local evaluation with custom NBXplorer user/group produced owner nb-custom, group nb-api, mode 400, and BTCPay membership in nb-api; the HMAC owner remains bitcoin. The upgrade guidance covers manually managed secrets and password rotation. The mdBook build passes. I inspected the new VM assertions and successful CI results rather than rerunning the VM locally.
Review performed with Codex (GPT-6 Astra).
|
Code change looks correct. Needs adjusting to the notice rules from #283 before merge. Must fix (maintainer can do this during the rebase):
Tested: reviewed the diff at a189a77. The new assertions run in CI's Assisted-by: Claude Code (Claude Opus 5.5) |
a189a77 to
c292e49
Compare
The bitcoind RPC password of NBXplorer, bitcoin-rpcpassword-btcpayserver, had NBXplorer's group and the default mode 0440. btcpayserver is in that group to read NBXplorer's API cookie, so BTCPay Server could read the password too, although it never uses it. Give the file to NBXplorer's user with mode 0400. The group still gives btcpayserver the cookie. bitcoind reads only the HMAC file, so it doesn't need the password. A program that read the password through the group or as the bitcoin user now fails, so add a 0.2.0 notice. Fixes bitcoinix#128. Assisted-by: Claude Code (Claude Opus 5.5)
c292e49 to
17114fa
Compare
Fixes #128.
The btcpayserver user is in NBXplorer's group, because BTCPay Server reads NBXplorer's API cookie (
/var/lib/nbxplorer/<network>/.cookie). But the secretbitcoin-rpcpassword-btcpayserver, NBXplorer's bitcoind RPC password, had the same group and the default mode0440. So BTCPay Server could read the password, although it never uses it.The secret now belongs to NBXplorer's user, with mode
0400. Only NBXplorer reads it, in itspreStart. bitcoind reads onlybitcoin-HMAC-btcpayserver, which doesn't change. The group still gives BTCPay Server the cookie.setup-secretsand nixops apply the new owner and mode on the next deployment.A program that read the password through the group, or as the
bitcoinuser, now fails. So config version 0.2.0 gets a notice for configs with BTCPay Server, anddocs/upgrading.mdsays what to do. It also says how to replace the password if BTCPay Server was compromised. Users who manage the secret files outside bitcoinix have to change this one by hand. The notice targets 0.2.0, the lowest open milestone.Testing
The
btcpayserverVM test now checks that the password file isnbxplorer-owned with mode0400, that the btcpayserver user can't read it, and that it can still read NBXplorer's cookie. Before this change, the first two checks fail.regtest: passes. NBXplorer still connects to bitcoind, and BTCPay Server's/api/v1/healthreportssynchronized, so BTCPay Server still authenticates to NBXplorer with the cookie.default: passes.ciTestInfo,checks.x86_64-linux.module-configandchecks.x86_64-linux.test-runner: pass.mdbook build: passes, and the release note links to the new upgrading section.Not in this PR
POST /v1/cryptos/BTC/rpc) still lets the cookie holder call the methods NBXplorer allows withoutexposerpc, for examplesendrawtransactionandgettxout. This PR removes BTCPay Server's direct access to the rest of the whitelist and its copy of the credential.0770 nbxplorer:nbxplorer, so the btcpayserver user can write there. That could be its own issue.module-config,test-runner,ci-workflowsandregtestpass on the KVM host. On master, the notice is a warning until 0.2.0 is released, and the tests pass withversion.nixat 0.1.6 and at 0.2.0.Models
Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283.