Skip to content

btcpayserver: make NBXplorer's RPC password readable only by NBXplorer - #268

Merged
prusnak merged 2 commits into
bitcoinix:masterfrom
ostermayer:btcpay-no-nbxplorer-rpc-password
Nov 18, 2026
Merged

prusnak merged 2 commits into
bitcoinix:masterfrom
ostermayer:btcpay-no-nbxplorer-rpc-password

Conversation

@ostermayer

@ostermayer ostermayer commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

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 secret bitcoin-rpcpassword-btcpayserver, NBXplorer's bitcoind RPC password, had the same group and the default mode 0440. 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 its preStart. bitcoind reads only bitcoin-HMAC-btcpayserver, which doesn't change. The group still gives BTCPay Server the cookie. setup-secrets and nixops apply the new owner and mode on the next deployment.

A program that read the password through the group, or as the bitcoin user, now fails. So config version 0.2.0 gets a notice for configs with BTCPay Server, and docs/upgrading.md says 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 btcpayserver VM test now checks that the password file is nbxplorer-owned with mode 0400, 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/health reports synchronized, so BTCPay Server still authenticates to NBXplorer with the cookie.
  • default: passes.
  • ciTestInfo, checks.x86_64-linux.module-config and checks.x86_64-linux.test-runner: pass.
  • Evaluation: a BTCPay Server config at config version 0.1.6 gets the notice, which names the configured NBXplorer user. On master it's a warning. A config without BTCPay Server gets no notice.
  • mdbook build: passes, and the release note links to the new upgrading section.

Not in this PR

  • NBXplorer's RPC proxy (POST /v1/cryptos/BTC/rpc) still lets the cookie holder call the methods NBXplorer allows without exposerpc, for example sendrawtransaction and gettxout. This PR removes BTCPay Server's direct access to the rest of the whitelist and its copy of the credential.
  • NBXplorer's data dir is 0770 nbxplorer:nbxplorer, so the btcpayserver user can write there. That could be its own issue.
  • After the rebase onto master c3d955c (Keep unreleased migration notices visible on master #283), module-config, test-runner, ci-workflows and regtest pass on the KVM host. On master, the notice is a warning until 0.2.0 is released, and the tests pass with version.nix at 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.

@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service labels Nov 15, 2026

@viberaven viberaven left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@github-actions github-actions Bot added the status: rebase needed Merge conflicts need to be resolved label Nov 16, 2026
@seberm

seberm commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Code change looks correct. Needs adjusting to the notice rules from #283 before merge.

Must fix (maintainer can do this during the rebase):

  • Move modules/versioning/0.1.7/nbxplorer-rpc-password.nix to modules/versioning/0.2.0/.
  • Move the release note and the upgrading text into the existing ## 0.2.0 sections. Drop the "set nix-bitcoin.configVersion = "0.1.7"" line: the 0.2.0 section already ends with the deferred configVersion line.
  • Revert the examples/configuration.nix bump. Examples stay at the released 0.1.6 until release prep.

Tested: reviewed the diff at a189a77. The new assertions run in CI's default and netns btcpayserver VM tests, which are green. Checked that NBXplorer's preStart runs as services.nbxplorer.user, and that the documented rotation regenerates bitcoin-HMAC-btcpayserver because the new password file is newer.

Assisted-by: Claude Code (Claude Opus 5.5)

@seberm seberm added this to the v0.2.0 milestone Nov 17, 2026
@ostermayer
ostermayer force-pushed the btcpay-no-nbxplorer-rpc-password branch from a189a77 to c292e49 Compare November 18, 2026 00:19
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)
@ostermayer
ostermayer force-pushed the btcpay-no-nbxplorer-rpc-password branch from c292e49 to 17114fa Compare November 18, 2026 01:01
@github-actions github-actions Bot added status: rebase needed Merge conflicts need to be resolved and removed status: rebase needed Merge conflicts need to be resolved labels Nov 18, 2026
@github-actions github-actions Bot removed the status: rebase needed Merge conflicts need to be resolved label Nov 18, 2026
@prusnak
prusnak enabled auto-merge November 18, 2026 10:25

@prusnak prusnak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@prusnak
prusnak merged commit 1774424 into bitcoinix:master Nov 18, 2026
25 checks passed
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: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

btcpayserver: BTCPay can read NBXplorer's bitcoind RPC password because the secret and the API cookie share a group

4 participants