Skip to content

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

Closed

Description

@ostermayer

modules/btcpayserver.nix puts the btcpayserver user in the nbxplorer group so that BTCPay can read NBXplorer's API cookie (btcexplorercookiefile=${nbxplorer.dataDir}/<network>/.cookie, with the data dir at 0770 nbxplorer:nbxplorer), but the same module gives the bitcoind RPC secret for NBXplorer to that group too:

nix-bitcoin.secrets = {
  bitcoin-rpcpassword-btcpayserver = {
    user = cfg.bitcoind.user;
    group = cfg.nbxplorer.group;
  };
};

The secrets module installs it 0440, so BTCPay can read the bitcoind RPC password of the btcpayserver RPC user. BTCPay never talks to bitcoind, it talks to NBXplorer, and the password is in its reach only because the cookie and the password share a group.

What that user can do is the public whitelist plus getblockfrompeer (the whitelist is cfg.bitcoind.rpc.users.public.rpcwhitelist ++ [ "getblockfrompeer" ]). The public list includes sendrawtransaction, getrawmempool, getpeerinfo and getnodeaddresses, so a compromised BTCPay gets direct access to bitcoind's P2P view and mempool, and to any method a later change adds to the public list or to this user. It also makes the web app the second holder of a credential that the whitelist comment in bitcoind-rpc-public-whitelist.nix treats as per consumer. BTCPay already carries a history of authentication bypasses (2.4.2 in August 2026 drained Lightning nodes through stolen credentials), so each credential it can read is one more thing to rotate after an incident.

Fix: separate the two files' groups. Either create a group for the NBXplorer cookie (nbxplorer-api), add btcpayserver to that one and keep bitcoin-rpcpassword-btcpayserver on NBXplorer's primary group, or keep the group and set the secret's group to cfg.nbxplorer.user (the primary group, which only NBXplorer has) while the cookie dir keeps the shared group. The .cookie file is written by NBXplorer at start, so its mode comes from NBXplorer's umask, and it's worth checking that it stays group readable after the change. The btcpayserver test covers the connection.

I can send that PR with the default and regtest scenario runs if you want it.

Found by DeepSeek V4.1 Flash 1017 at max thinking in the review of #73's tree. GPT-6 Astra, run at xhigh reasoning as the second opinion, confirmed it and rated it medium, and I checked it against master 4452d89.

Activity

  1. added
    area: modules
    type: security
    on Oct 23, 2026
  2. added 2 commits that reference this issue on Nov 18, 2026
    c292e49
    17114fa
  3. added a commit that references this issue on Nov 18, 2026
    1774424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: modulestype: security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions