Repository navigation
Description
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:
- The operator enables
services.btcpayserver, and the unit starts on the next switch. - 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 accountServerAdminbecause no admin exists yet, and BTCPay'sdisable-registrationthen locks registration for everyone else, including the operator. - The admin's default store already carries the internal Lightning node (
btclightning=in the generated config). WithlightningBackend = "clightning", that's the unrestrictedlightning-rpcsocket (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 hasinvoices:writeandaddress:writebut nooffchain:write, so the damage stops at receiving into the attacker's invoices and address churn. - 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 setservices.btcpayserver.addressto a unix socket or a firewall-restricted address for first setup. - Pass
BTCPAY_DISABLE_REGISTRATION=trueby default once an admin exists, through an option such asservices.btcpayserver.allowRegistrationthat defaults to false once a flag file in the data dir says an admin was created. BTCPay readsBTCPAY_environment variables. - Bind the UI to a unix socket owned by a
btcpayserver-uigroup 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
btcpayserver: create the admin account before BTCPay opens its port
btcpayserver: create the admin account before BTCPay opens its port
btcpayserver: create the admin account before BTCPay opens its port (b…