Skip to content

btcpayserver: until the operator registers, any local user can become the server admin and reach the internal Lightning node #131

Closed

Description

@ostermayer

BTCPay Server makes the first account that registers the server administrator. modules/btcpayserver.nix binds the web UI to 127.0.0.1:23000 by default, and nothing in the module or the docs closes the window between the first start and the operator's own registration.

The path, from any local unprivileged account on the node:

  1. The operator enables services.btcpayserver, and the unit starts on the next switch.
  2. Before the operator opens the UI, the local user runs curl http://127.0.0.1:23000/register ... (or uses an SSH port forward) and registers. BTCPay grants that account ServerAdmin because no admin exists yet, and BTCPay's disable-registration then locks registration for everyone else, including the operator.
  3. The admin's default store already carries the internal Lightning node (btclightning= in the generated config). With lightningBackend = "clightning", that's the unrestricted lightning-rpc socket (btcpayserver: the clightning backend grants BTCPay full lightningd RPC over the unix socket #87), so the admin can pay any invoice from the node's channels and withdraw on-chain funds. With the lnd backend, the baked macaroon has invoices:write and address:write but no offchain:write, so the damage stops at receiving into the attacker's invoices and address churn.
  4. The admin can also upload server plugins, which run in-process as the btcpayserver user (the module keeps Restart = "always" for that), and read every store's API keys.

The same first-admin window exists for the onion service and for any LAN or WireGuard address the operator sets, with a larger audience. Loopback is the default, so the issue is about the local-user boundary that the rest of the tree takes seriously with separate users per service, per-service secrets and netns-isolation.

GPT-6 Astra confirmed it and rated it high with the clightning backend, and noted that BTCPay's registration handler accepts plain HTTP on localhost.

Fix options, from small to complete:

  • Document the window next to the backend option and in docs/services.md: register the admin right after the first start, and set services.btcpayserver.address to a unix socket or a firewall-restricted address for first setup.
  • Pass BTCPAY_DISABLE_REGISTRATION=true by default once an admin exists, through an option such as services.btcpayserver.allowRegistration that defaults to false once a flag file in the data dir says an admin was created. BTCPay reads BTCPAY_ environment variables.
  • Bind the UI to a unix socket owned by a btcpayserver-ui group and put nginx or the operator in that group, so loopback HTTP isn't reachable by every local account.

The clightning half gets smaller once #87 lands with a restricted rune instead of the admin socket, but the admin takeover itself stays.

Found by DeepSeek V4.1 Flash 1017 at max thinking in a chain-focused review of master 4452d89. GPT-6 Astra, run at xhigh reasoning as the second opinion, confirmed it, and I checked it against the module and the pinned BTCPay source.

Activity

  1. added
    area: modules
    type: security
    on Oct 23, 2026
  2. added 2 commits that reference this issue on Nov 18, 2026
    abe7644
    25cf58b
  3. added a commit that references this issue on Nov 18, 2026
    211033b
  4. added this to the v0.2.0 milestone on Nov 18, 2026
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions