Skip to content

lndconnect: give the operator onion access only when the operator role is enabled - #170

Merged
prusnak merged 5 commits into
bitcoinix:masterfrom
ostermayer:lndconnect-operator
Nov 10, 2026
Merged

prusnak merged 5 commits into
bitcoinix:masterfrom
ostermayer:lndconnect-operator

Conversation

@ostermayer

@ostermayer ostermayer commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #166.

lndconnect and lnconnect added nix-bitcoin.onionAddresses.access entries for the operator user whenever their onion variant was on. With nix-bitcoin.operator.enable at its default of false that user doesn't exist, onion-addresses failed at its chown, and no onion address was published for anyone. A public bitcoind then started with an empty externalip and refused to run, and lightningd behind it did the same.

One commit on current master:

  • lndconnect.nix adds the operator entries only when nix-bitcoin.operator.enable is set, like onion-services.nix and the WireGuard preset do. The lnd user's own entry stays, as a separate mkMerge part, so an operator named like the lnd user isn't a duplicate attribute key.
  • lnconnect-clnrest reads the operator's address file, so clnrest.lnconnect.onion asserts that the operator has clnrest in nix-bitcoin.onionAddresses.access. A config can grant that by hand without the whole operator role. The helper also reads the admin rune, which only the clightning group can read, so running it as that user also needs users.users.<name>.extraGroups = [ "clightning" ];. That group can read the rune and use the RPC socket. The message offers the grant only when the user exists.
  • onion-addresses.nix asserts at evaluation time that every access user is defined and lists the missing ones, so a typo fails the build instead of every address at boot.
  • An existing account named as the operator with the role off used to get the clnrest access implicitly and now loses it. A 0.1.5 versioning entry fires for exactly those configs, and stays quiet when the config grants the access itself. The operator's lnd-rest copy isn't checked: lndconnect runs as the lnd user and reads that user's copy, and the only reader of the operator's copy is nodeinfo, which enables the role itself. v0.1.4 shipped without this change, so it's 0.1.5, with a matching section in docs/upgrading.md and examples/configuration.nix at 0.1.5.
  • docs/services.md says the role, or the explicit grant plus the group, gives the clnrest helper what it needs, or that it runs as root.
  • Configuration checks for lndconnect and lnconnect with and without the role, an existing account with the role off, the explicit grant, an unknown access user, both assertion hints, and the versioning condition.
  • A new VM scenario, lnconnectNoOperatorRole, turns the role off and defines operator with only the clightning group and the explicit grant, then runs lightning-cli getinfo and lnconnect-clnrest --url as that user. It's in buildable in run-tests.sh but not in the CI matrix.

Tested

  • module-config on my KVM host on top of master: 68 tests pass.
  • ./test/run-tests.sh -s lnconnectNoOperatorRole passes. With the group removed it fails as expected, already at lightning-cli getinfo with Permission denied.
  • ./test/run-tests.sh -s full passes, including the lndconnect-onion-lnd and lnconnect-onion-clnrest tests.

Claude Fable 5.1 planned the first version and Claude Opus 5.5 wrote both. Codex (GPT-5.6 Sol, xhigh) reviewed each. On this one it found that the docs said only lnconnect-clnrest reads the operator's directory, while nodeinfo does too, which is fixed. It also notes that the access-user assertion rejects users created at runtime (useradd, LDAP), which was in the first version too. DeepSeek V4.1 Flash 1017 (max) and GLM 5.3 (max) audited the tree at d1b46ab with Codex (GPT-6 Astra, xhigh) as the second opinion: eleven findings plus three Astra extras, none in the files this PR touches. The WireGuard firewall one is what #188 fixes.

@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 labels Oct 27, 2026
@seberm seberm added the type: bug Behaviour is wrong vs. documented or intended label Oct 27, 2026

@seberm seberm 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.

Could we go back to keying on nix-bitcoin.operator.enable, as the first commit did? onion-services.nix already gives the operator onion access with mkIf config.nix-bitcoin.operator.enable, and the wireguard preset checks the same option, so a user-existence check makes lndconnect the only place where a hand-defined operator user gets onion access. The documented way to reuse an existing user is operator.enable = true plus operator.name, which merges into that user.

Keying on the option also keeps access an explicit choice instead of depending on whether some module happens to define a user named operator.name, and avoids reading users.users while onionAddresses.access is being built.

The new eval-time check in onion-addresses.nix seems the right place for the existence test and already prevents the boot failure; the branch also needs a rebase onto master.

Comment thread modules/lndconnect.nix Resolved

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

No additional code defects found at 64999ca.

Five focused Nix evaluations passed: lndconnect without an operator, with an enabled operator, with operator.name equal to the LND user, lnconnect onion mode without an operator, and onion access naming an undefined user. These checks confirm the expected access users and assertion messages.

The branch still conflicts with master in test/configuration.nix and needs that conflict resolved. This review does not resolve the existing maintainer feedback about using operator.enable versus user existence.

The full module-config suite exceeded the local memory limit. VM tests were not run because /dev/kvm is unavailable.

Review performed with Codex (GPT-6 Astra).

@ostermayer ostermayer changed the title lndconnect: give the operator onion access only when the operator user exists lndconnect: give the operator onion access only when the operator role is enabled Oct 30, 2026

@sebsgent sebsgent 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.

The operator.enable gating fixes #166, but the documented role-off migration doesn't give a working lnconnect-clnrest.

Must fix

  • The explicit clnrest grant passes evaluation, but the helper fails at runtime. lnconnect-clnrest has no run-as shebang and reads admin-rune directly. The rune is 0640 clightning:clightning in a 0710 dir, and only the operator role adds the clightning group. In a VM with alice as operator, the role off and access.alice = [ "clnrest" ], alice can read the onion address, but runuser -u alice -- lnconnect-clnrest --url fails with cat: .../admin-rune: Permission denied. The same command works as root, and as alice with the clightning group added. This was already broken before this PR, but the PR now presents the grant as the way to keep this working. Either document the missing step (users.users.<name>.extraGroups = [ "clightning" ];, noting that the group gives read access to the admin rune and to the RPC socket) or say that without the role the helper only works as root. Update docs/services.md, the second bullet in docs/upgrading.md, the assertion message in modules/lndconnect.nix and the 0.1.4 message in modules/versioning.nix. testOperatorAccountExplicitAccess only checks that evaluation passes, so it doesn't cover this.

Should fix

  • The lnd half of the 0.1.4 entry blocks evaluation for a small loss. lndconnect reads ${lnd.user}/lnd-rest and runs as the lnd user, so it doesn't use the operator's copy. The only reader in the tree is nodeinfo's onion_rest_address. Gate that half of the condition on nix-bitcoin.nodeinfo.enable, or drop it. Say in docs/upgrading.md that lndconnect itself doesn't need the grant.

Nit

  • With no operator account, the assertion's second hint (add clnrest to access.operator) only leads to the undefined-user assertion. Say that the user must exist, or offer that hint only when it does.

Tested: module-config passes on the PR merged with master. Five of the six new tests fail on master, and the operator-enabled one has nothing to catch there. The toplevel drvPath of a role-on lndconnect and lnconnect onion config is identical to master, so role-on nodes don't change. One VM run of the role-off explicit grant, as above. I did not re-run the full scenario.

Review performed with Claude Code (Claude Opus 5.5).

@ostermayer

Copy link
Copy Markdown
Collaborator Author

Thanks, all three are in. Rebased on master and squashed into one commit.

Must fix: confirmed. The rune is 640 and only the clightning group can read it. The operator role is the only thing that adds that group. docs/services.md, the 0.1.5 section in docs/upgrading.md, the assertion in modules/lndconnect.nix and the versioning message now say to add users.users.<name>.extraGroups = [ "clightning" ]; or to run lnconnect-clnrest as root. They also say that the group can read the admin rune and use the RPC socket, so it gives full control over the node. The new lnconnectNoOperatorRole VM scenario disables the role, defines operator with only the clightning group and the explicit clnrest grant, and runs runuser -u operator -- lnconnect-clnrest --url and lightning-cli getinfo as that user.

Should fix: dropped the lnd half. nodeinfo is the only reader of the operator's lnd-rest copy, and it sets nix-bitcoin.operator.enable = true itself. So gating on nodeinfo.enable could never match a config that has the role disabled. docs/upgrading.md now says that lndconnect isn't affected because it runs as the lnd user and reads that user's copy. testVersioningOperatorAccess checks that a role-off config that only uses lndconnect passes the check.

Nit: the assertion offers the explicit grant only when the operator user exists. If the user doesn't exist, it says to define the user and points to the docs. testLnconnectAssertionHints covers both cases.

Config version: 0.1.4 shipped without this change, so the entry, the upgrade section and the example config now use 0.1.5.

Tested on master plus this commit: module-config passes (68 tests). The lnconnectNoOperatorRole and full VM scenarios pass. With the group removed, lnconnectNoOperatorRole fails as expected, already at lightning-cli getinfo with Permission denied. The new scenario is in buildable in run-tests.sh, but I didn't add it to the CI matrix. Happy to add it if you want CI to cover it.

@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 c1e4bc0 against its merge base, including the previous review discussion. The operator.enable gating, separate LND grant, explicit clnrest access, login-name checks, and group-access guidance address the earlier concerns. One P2 migration gap remains, described inline: the generic access-user assertion introduces a second compatibility break that the 0.1.5 versioning entry does not cover.

Validation:

  • All 10 added configuration tests passed in separate Nix evaluations using the PR's pinned inputs.
  • Additional evaluation confirmed that the explicit grant works with an account whose attribute name differs from its login name.
  • The new lnconnectNoOperatorRole scenario evaluates without failed assertions, with the operator role disabled, only the clightning group, and the explicit clnrest grant.
  • All 9 test-runner tests passed against the assembled suite.
  • Compared the externally managed recipient case with the pre-PR configuration: the new generic assertion rejects it, while the 0.1.4 version check still passes.

Full flake and VM tests were not run locally; this host has no /dev/kvm.

Review performed with Codex (GPT-6 Astra).

Comment thread modules/onion-addresses.nix Resolved
@prusnak prusnak added the status: changes needed Cannot proceed until suggested changes are implemented label Nov 4, 2026
@ostermayer

Copy link
Copy Markdown
Collaborator Author

I pushed a second commit, c1e4bc0, on top of d1b46ab.

users.users.<name> can set a login name that differs from the attribute key, and a user can have enable = false. The onion-addresses check and the lndconnect operator check looked only at the attribute keys. They now match on the login name and skip disabled users. The hint in the assertion names the actual attribute you'd edit.

Tests:

  • module-config: 70 checks pass, with new cases for a renamed account and a disabled user
  • test_lnconnect_onion_clnrest now waits for onion-addresses before it reads the address

Codex GPT-5.6 Sol (xhigh) and GPT-6 Astra (xhigh) reviewed it, and their last round found nothing more. GLM 5.3 ran over c1e4bc0 and Astra checked its report. Nothing came up in the files this PR touches.

@ostermayer

Copy link
Copy Markdown
Collaborator Author

Thanks, that's a real gap. Fixed in fadefe6.

  • A second 0.1.5 entry reports onionAddresses.access users that aren't enabled accounts in users.users. That covers useradd, LDAP and disabled accounts. Its condition is the same check the assertion makes.
  • The clnrest operator entry no longer needs the operator to be defined in users.users, so an operator from useradd or LDAP gets the notice too.
  • The upgrade notes explain both. To keep access for such a user, either remove it from access or declare the account with all its current settings. The notes list them, because NixOS applies its own defaults to anything left out. They also say when enabling the operator role is safe, and what to do for an LDAP or disabled operator.
  • The assertion now says "aren't defined and enabled in users.users".
  • New tests cover an external access user at 0.1.4 and 0.1.5, a declared account, a disabled account and an external operator.

module-config passes with 71 checks, and the lnconnectNoOperatorRole and full VM scenarios pass on my KVM host.

Codex GPT-6 Astra and GPT-5.6 Sol (both at max) reviewed it over six rounds and found several holes in the migration advice and wording. All are fixed, and Astra's last round found no defects. Kimi K3, DeepSeek V4.1 Flash and GLM 5.3 (all at max) ran over fadefe6, and Astra and Sol checked their report. Nothing came up in the files this PR touches.

@prusnak prusnak removed the status: changes needed Cannot proceed until suggested changes are implemented label Nov 5, 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 fadefe6 against its merge base and the previous review discussion. No additional code defects found. The latest commit addresses the missing migration notice for externally managed recipients. The operator grants, login-name validation, and explicit-access migration look consistent.

Validation on this PR head:

  • module-config passed.
  • All nine test-runner checks passed.
  • The lnconnectNoOperatorRole VM scenario passed under KVM.

Before merging:

  • Resolve the current conflicts with master in docs/upgrading.md and modules/versioning.nix, preserving both sets of 0.1.5 changes.
  • Add the Assisted-by: commit trailers required by AGENTS.md. All three PR commits currently lack them; the AI-assistance disclosure in the PR description does not satisfy the commit-trailer policy.

The complete flake/VM matrix was not run locally.

Review performed with Codex (GPT-6 Astra).

@ostermayer

Copy link
Copy Markdown
Collaborator Author

Merged master in 8e6ed56, with no rebase. Master's three 0.1.5 entries come first, then the two from this PR, and docs/upgrading.md has one 0.1.5 section.

Master's clnrest notice fires for every config with clnrest enabled at 0.1.4. So a pass/fail version check could no longer tell whether this PR's clnrest notice fires. c1d527a adds an internal read-only option, nix-bitcoin.versioning.incompatibleChanges, that lists the notices that apply, and the tests now check each of this PR's notices directly. Setting either notice's condition to false makes its test fail. The throw users see is unchanged. e36b5e0 also mentions the onion access notices in the section's opening paragraph.

module-config passes with 74 checks, and lnconnectNoOperatorRole passes on my KVM host. Codex GPT-6 Astra and GPT-5.6 Sol (both at max) reviewed the merge and the new commit. Astra found no defects, and Sol's one docs point is fixed. The new commits carry the Assisted-by: trailer. I didn't rewrite the earlier ones.

Kimi K3, DeepSeek V4.1 Flash and GLM 5.3 (all at max) ran over e36b5e0, and Astra checked their report. Nothing came up in the files this PR touches.

@seberm seberm added the breaking Changes existing user config; needs a versioning.nix entry label Nov 6, 2026
@seberm seberm added this to the v0.1.6 milestone Nov 8, 2026
@seberm

seberm commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

v0.1.5 is released, so this PR's versioning entries can no longer target 0.1.5: users who already set configVersion = "0.1.5" would never see them. Could you rebase onto master (the branch has conflicts now) and move everything to 0.1.6?

  • modules/versioning.nix: version = "0.1.6" for both entries, and "Upgrading to config version 0.1.6" in their messages and the "Before 0.1.5" comments.
  • docs/upgrading.md: put the text in a new ## Upgrading to config version 0.1.6 section at the top, ending with the configVersion = "0.1.6" line. Leave the released 0.1.5 section as it is.
  • examples/configuration.nix: nix-bitcoin.configVersion = "0.1.6".
  • test/configuration.nix: passesVersionCheckAt "0.1.6", the matching configVersion and comment.

Thanks!

@prusnak prusnak added the status: changes needed Cannot proceed until suggested changes are implemented label Nov 8, 2026
@ostermayer

Copy link
Copy Markdown
Collaborator Author

Rebased onto master and moved everything to 0.1.6 as you listed. One extra: hasNotice now evaluates a 0.1.5 config instead of 0.1.4, so the notice tests cover a user who's already on the released 0.1.5. module-config, test-runner, the default, lnconnectNoOperatorRole and full scenarios and the deployment examples pass.

@ostermayer

Copy link
Copy Markdown
Collaborator Author

Rebased onto master again, because today's merges made it conflict. docs/upgrading.md keeps master's released 0.1.5 section as it is and adds this PR's 0.1.6 section above it, and test/configuration.nix keeps both sets of new tests. The code is the same as before.

I also added the Assisted-by trailer to the three older commits and fixed the message of abf6815, which still gave master's removed clnrest notice as its reason. module-config, test-runner and the lnconnectNoOperatorRole scenario pass.

@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 101cb54 against the merge base and the previous review discussion. No blocking correctness findings. The operator-role gating, separate LND grant, login-name validation, and explicit clnrest access are consistent with the surrounding modules. Both compatibility breaks now have 0.1.6 notices and migration guidance, and all five PR commits have Assisted-by trailers.

Validation on this head:

  • module-config: all 81 configuration tests passed.
  • test-runner: all nine checks passed.
  • lnconnectNoOperatorRole: passed under KVM, including lightning-cli getinfo and lnconnect-clnrest --url as the operator with the role disabled.
  • git diff --check passed.

Small non-blocking documentation follow-up: please add a short entry under 0.1.6 in docs/release-notes.md describing the onion-address publication fix and linking to the 0.1.6 upgrading section, as requested by AGENTS.md. The migration details are already documented there.

The complete flake and VM matrix was not rerun locally. GitHub reports the current ci_gate as successful.

Review performed with Codex (GPT-6 Astra).

prusnak added a commit that referenced this pull request Nov 10, 2026
…ded (#188)

The WireGuard preset binds the REST ports of the enabled `*connect`
helpers to 0.0.0.0 and guards them, and `restrictPeer`, only through
`networking.firewall.extraCommands`. Its assertion required the iptables
backend, but some layouts pass that check and still end with no
firewall. This is the same kind of gap #175 closed for netns-isolation.

What changed, one commit on current master:

- **Package check.** `networking.firewall.package` defaults to
`pkgs.nftables` whenever `networking.nftables` is enabled, whatever the
backend says. The firewall service then has no `iptables` binary and
fails at its first rule. The assertion now rejects the nftables package
unless `networking.firewall.extraPackages` holds iptables, which the
service also puts on its PATH.
- **flushRuleset check.** `pkgs.iptables` is iptables-nft, so the rules
live in the nftables ruleset. With `networking.nftables.flushRuleset`,
every start or reload of `nftables.service` runs `flush ruleset` and
deletes them while `firewall.service` stays active. NixOS turns it on by
default when `ruleset` or `rulesetFile` is set or `system.stateVersion`
is older than 23.11. A separate assertion rejects it and points to
`networking.nftables.tables` with `flushRuleset = false`.
- **Table name check.** `nftables.service` deletes and recreates every
table in `networking.nftables.tables`. A table named `filter` in the
`ip` or `ip6` family is the one iptables-nft keeps `nixos-fw` in, so
that's rejected too. `inet filter` still passes. Raw `flush` or `delete`
lines in `ruleset`, `rulesetFile` or `extraDeletions` aren't checked.
- The messages say to restart `firewall.service` once after a fix, since
the first nftables reload still runs the old deletions file.
- `docs/services.md` lists the preset's firewall requirements in the
WireGuard setup step.
- Configuration checks: nftables with the iptables backend fails, the
iptables package or `extraPackages` passes, `ruleset` set fails,
`system.stateVersion = lib.mkForce "23.05"` fails, tables only passes,
an `ip filter` table fails.

## Tested

- `module-config` on my KVM host on top of master: 67 tests pass. With
master's preset and the new tests, the four rejection tests fail. With
the previous PR head's preset, the `ruleset` and `stateVersion` tests
fail.
- In the pinned nixpkgs, `nftables.nix` sets the `flushRuleset` default
to `mkDefault (versionOlder stateVersion "23.11" || rulesetFile != null
|| ruleset != "")`, and recreates each table in `tables` on reload.
- The `wireguard-lndconnect` VM scenario passes.

DeepSeek V4.1 Flash 1017 (max) found the package gap in the gate runs on
#170 and #184 and Codex (GPT-6 Astra, xhigh) confirmed it both times.
@sebsgent found the flushRuleset hole. Claude Opus 5.5 wrote this
version. Codex (GPT-5.6 Sol, xhigh) reviewed it in two passes and found
two real issues: the `ip filter` table clash, and that the first reload
after a fix still applies the old deletions. Both are in. Its point that
any package not named `nftables` passes is by design, the same check as
#175. DeepSeek V4.1 Flash 1017 (max) and GLM 5.3 (max) audited the tree
at 1cea5a7 with Codex (GPT-6 Astra, xhigh) as the second opinion: seven
findings, none in the files this PR touches. They're in RTL, mempool
settings, the shared Tor SOCKS port and the netns source filter, and
Astra marked the three netns ones false positives.

netns-isolation has the same flushRuleset and table-name hole: a flush
deletes `nb-netns-bridge`'s MASQUERADE rule and the host's `nixos-fw`,
while the per-namespace rules survive. That's a separate PR.
@prusnak
prusnak force-pushed the lndconnect-operator branch from 8594cfa to 554954c Compare November 10, 2026 18:41
@prusnak
prusnak force-pushed the lndconnect-operator branch from 554954c to 16f30a1 Compare November 10, 2026 18:43
@prusnak

prusnak commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@ostermayer I tried to rebase the PR on top of current master, but now it fails in the CI. Can you please have a look?

…e is enabled

lndconnect and lnconnect added nix-bitcoin.onionAddresses.access entries
for the operator user whenever their onion variant was on. With
nix-bitcoin.operator.enable at its default of false, that user usually
doesn't exist. The onion-addresses service then failed at its chown and
published no onion address for anyone, which took down a public bitcoind
and the Lightning daemons behind it.

The operator entries now depend on nix-bitcoin.operator.enable, like the
operator access in onion-services.nix and the WireGuard preset. Access
stays an explicit choice and doesn't depend on whether some module
defines a user with the operator's name. The lnd user's own entry stays,
and it is a separate definition, so an operator named like the lnd user
is not a duplicate attribute key.

lnconnect-clnrest reads the clnrest onion address from the operator's
directory, so its onion option asserts that the operator has clnrest
access. A config can grant it explicitly without enabling the whole
operator role. The helper also reads the admin rune, which only the
clightning group can read. Without the role, the user must be added to
that group or run the helper as root. The docs, the assertion and the
versioning message say so, and note that the group can read the admin
rune and use the RPC socket. The assertion offers the explicit grant
only when the operator user exists. onion-addresses asserts at
evaluation time that every access user is defined, so a typo fails the
build instead of every address at boot.

An existing account named as the operator with the role disabled used to
get the clnrest access implicitly and now loses it. The 0.1.5 versioning
entry and the upgrade notes tell those users to enable the operator role
or to declare the access explicitly. The entry doesn't check the
operator's lnd-rest access. lndconnect reads the lnd user's copy, and
the only reader of the operator's copy is nodeinfo, which enables the
operator role itself.

Configuration checks cover lndconnect with and without the operator,
lnconnect without it, an existing account with the role disabled, the
same account with explicit access, the assertion hints, the versioning
entry and an unknown access user. The new lnconnectNoOperatorRole VM
scenario runs lnconnect-clnrest --url as an operator account that has
only the explicit grant and the clightning group.

Fixes bitcoinix#166

Assisted-by: Claude Code (Claude Opus 5.5)
onion-addresses chowns each access directory to the access key, which is
a login name. The new checks looked for a `users.users` attribute with
that key instead, so an account whose attribute name differs from its
`name` was rejected, and an account with `enable = false` passed and
broke the chown at boot. Compare with the login names of the enabled
accounts in onion-addresses, lndconnect and the 0.1.5 versioning check.

The extraGroups hints in the lnconnect assertion and the versioning
message now name the attribute that defines the account. Naming the
login, as before, would create a second, invalid entry for an account
like `users.users.account.name = "alice"`.
The docs call it the operator account for the same reason.

The lnconnect-onion-clnrest test now waits for onion-addresses before it
reads the address, since nothing orders clightning after that service.

Assisted-by: Claude Code (Claude Opus 5.5)
…sers

The onion-addresses assertion rejects access keys that aren't login names of
enabled users.users accounts. Configs that named users created with useradd,
provided by LDAP or disabled in users.users passed before and now fail
evaluation. Report them as a 0.1.5 change and document the migration in the
upgrade guide. The clnrest operator entry no longer requires the operator to be
defined in users.users, so an operator from useradd or LDAP is reported too.

Assisted-by: Claude Code (Claude Opus 5.5)
Other notices for the same config version can apply to the same config, so
a test can't tell from the whole version check whether one notice fires.
Add an internal, read-only option that lists the messages of the applying
changes, and match each test case against it. Also mention the onion
access notices in the 0.1.5 upgrade intro.

Assisted-by: Claude Code (Claude Opus 5.5)
v0.1.5 is released, so configs that already set `configVersion = "0.1.5"`
would never see the two onion access notices. Move both entries to 0.1.6
and put their upgrade notes in a new 0.1.6 section. The released 0.1.5
section is back to its released text, without the onion access mention in
its intro. The example config sets 0.1.6.

The notice tests now evaluate a 0.1.5 config, so they check that users of
the released version get each notice.

Assisted-by: Claude Code (Claude Opus 5.5)
@ostermayer

Copy link
Copy Markdown
Collaborator Author

Thanks for the rebase. It put the new lnconnectNoOperatorRole scenario inside #188's wireguardIptablesLegacy scenario and lost one };, so test/tests.nix didn't parse.

I rebased again from the head viberaven reviewed and kept both scenarios. The result differs from your push only by that };. nix flake check --all-systems, the ciTestInfo eval, and the lnconnectNoOperatorRole and wireguardIptablesLegacy scenarios pass on the KVM host.

@prusnak
prusnak enabled auto-merge November 10, 2026 20:06
@prusnak prusnak removed the status: changes needed Cannot proceed until suggested changes are implemented label Nov 10, 2026
@prusnak
prusnak merged commit 2362b11 into bitcoinix:master Nov 10, 2026
20 checks passed
unbeholdendev added a commit to unbeholdendev/infra that referenced this pull request Nov 17, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [bitcoinix/bitcoinix](https://github.com/bitcoinix/bitcoinix) | patch | `v0.1.5` → `v0.1.6` |

---

### Release Notes

<details>
<summary>bitcoinix/bitcoinix</summary>

### [`v0.1.6`](https://github.com/bitcoinix/bitcoinix/releases/tag/v0.1.6): bitcoinix 0.1.6

[Compare Source](bitcoinix/bitcoinix@v0.1.5...v0.1.6)

**Security release with breaking changes.** Narrows Tor enforcement to local addresses, closes a netns-isolation bypass, hardens RTL and the custom lnd macaroons, and updates lnd to 0.21.8-beta. All users should upgrade. Evaluation fails with a message for each breaking change that affects your config; act on it, then set `nix-bitcoin.configVersion = "0.1.6";`. Deploying restarts every netns-isolated service and each RTL backend once.

#### Security

- **Tor enforcement allowed more than Tor.** Services with `tor.enforce` and charge-lnd could reach every link-local address `169.254.0.0/16`, including a cloud provider's metadata service, and could resolve names through the host's resolver sockets. They now reach only localhost and, with netns-isolation, the namespace subnet, and can't use the nscd, systemd-resolved, D-Bus and Avahi sockets ([#&#8203;264](bitcoinix/bitcoinix#264), [GHSA-cgh8-4w2p-8fr8](GHSA-cgh8-4w2p-8fr8)).
- **netns-isolation:** with `br_netfilter` loaded, which Docker does, a service without `tor.enforce` could reach the listeners of namespaces it isn't connected to. Traffic between namespaces is no longer masqueraded ([#&#8203;239](bitcoinix/bitcoinix#239)).
- **RTL verifies its backends.** RTL sent the lnd admin macaroon and the clightning admin rune to any server on a backend's port. It now requires the backend's pinned TLS certificate ([#&#8203;258](bitcoinix/bitcoinix#258)) and stops when lnd or clightning stops, instead of polling a port that another local user could take over ([#&#8203;250](bitcoinix/bitcoinix#250)).
- **RTL two-factor authentication survives restarts.** Before, each restart turned 2FA off without a warning. `RTL-Config.json`, which holds the 2FA secret, is now readable only by RTL's user ([#&#8203;254](bitcoinix/bitcoinix#254)).
- **Custom lnd macaroons** (`services.lnd.macaroons`, used by BTCPay Server and charge-lnd) are now readable only by their `user`. Before, the user's primary group could read them, which for `operator` is `users`, so other normal users could. If other users log in to your node, [revoke all macaroons](https://docs.bitcoinix.net/services.html#revoke-all-macaroons) ([#&#8203;255](bitcoinix/bitcoinix#255)). Each custom macaroon now has its own root key, so one can be revoked without the others ([#&#8203;236](bitcoinix/bitcoinix#236)).
- **Root scripts no longer load config files from a service user's home.** The lnd user could make root's `curl` and `jq` load `~/.curlrc` and `~/.jq` from lnd's data dir ([#&#8203;241](bitcoinix/bitcoinix#241), [GHSA-cwmc-wjvh-3qp6](GHSA-cwmc-wjvh-3qp6)).
- **Backups fail when a database dump fails.** Before, duplicity succeeded without the database. With `services.postgresqlBackup.compression` set to `"zstd"` or `"none"`, backups left out the BTCPay and NBXplorer databases; they are now included, so run `systemctl start duplicity` after upgrading if you use one of these ([#&#8203;225](bitcoinix/bitcoinix#225)).
- **Multipath TCP:** service namespaces now copy the host's `net.mptcp.enabled`, so the setting of `hardened-extended` reaches netns-isolated services ([#&#8203;206](bitcoinix/bitcoinix#206)).
- **Secrets:** `setup-secrets` rejects empty secret files, and secret generation no longer replaces an empty TLS, WireGuard or replication SSH key ([#&#8203;244](bitcoinix/bitcoinix#244)).
- **WireGuard preset:** evaluation fails for firewall setups in which the preset's rules can't run or don't stay loaded ([#&#8203;188](bitcoinix/bitcoinix#188)).
- **lnd [0.21.8-beta](https://github.com/lightningnetwork/lnd/blob/master/docs/release-notes/release-notes-0.21.8.md)** fixes correctness bugs in channel state persistence, gossip validation, the sweeper and HTLC recovery ([#&#8203;263](bitcoinix/bitcoinix#263)).

#### Breaking changes

- **Tor enforcement:** a service with `tor.enforce` that connects to a non-local address or by host name needs a change. netns-isolation rejects `addressblock` 169 and 170 ([#&#8203;264](bitcoinix/bitcoinix#264)).
- **Onion address access:** `lndconnect.onion` and `clnrest.lnconnect.onion` give the operator user access only when `nix-bitcoin.operator.enable` is set. `nix-bitcoin.onionAddresses.access` accepts only users that are defined and enabled in `users.users` ([#&#8203;170](bitcoinix/bitcoinix#170)).
- **Secrets:** an empty or non-regular secret file now fails `setup-secrets`, and then no service can read its secrets. Check before deploying: `find /etc/nix-bitcoin-secrets -maxdepth 1 -type f -empty`. Set `nix-bitcoin.secrets.<name>.allowEmpty = true` for a secret that may be empty ([#&#8203;244](bitcoinix/bitcoinix#244)).
- **lnd wallet:** lnd stops when `wallet.db` isn't a regular file, or when its seed file is a symlink to a missing file while it has no wallet ([#&#8203;244](bitcoinix/bitcoinix#244)).
- **lnd macaroons:** bitcoinix deletes unused root keys with IDs `0x6e62000000000000` to `0x6e62ffffffffffff` on each lnd start; check `lncli listmacaroonids` before deploying. lnd's `no-macaroons` option isn't supported. Restart services that read a custom macaroon only at startup ([#&#8203;236](bitcoinix/bitcoinix#236)). A program that read a custom macaroon through the group needs its own macaroon ([#&#8203;255](bitcoinix/bitcoinix#255)).
- **RTL:** with both backends enabled, stopping one stops RTL for both ([#&#8203;250](bitcoinix/bitcoinix#250)). `LN_SERVER_URL`/`LND_SERVER_URL`, another `Settings.lnServerUrl`, a proxy without `no_proxy` for the backend, and servers with a self-signed certificate no longer work as before ([#&#8203;258](bitcoinix/bitcoinix#258)).
- **WireGuard preset:** fails evaluation with the nftables firewall package without iptables, with `networking.nftables.flushRuleset`, and with an `ip` or `ip6` table named `filter` in `networking.nftables.tables` ([#&#8203;188](bitcoinix/bitcoinix#188)).
- **extra-container [1.0.1](https://github.com/extra-container/extra-container/releases/tag/v1.0.1):** containers can no longer reach the host's Nix daemon socket, so `nix build`, `nix run`, `nix develop` and `nix-shell` fail inside them. `extra.hostNixDaemon = true;` restores the old behavior; read the security section of the extra-container README first ([#&#8203;211](bitcoinix/bitcoinix#211)).
- **Packages:** `rtl` and `trustedcoin` moved to `legacyPackages.<system>.pinned`. Trezor is `nix-bitcoin.pkgs.nbPython3Packages.trezor`. `nbPython3Packages` uses the Python interpreter of nixpkgs-unstable, so build custom Python environments with `nbPython3Packages.python` ([#&#8203;245](bitcoinix/bitcoinix#245)).
- **nodeinfo:** every bitcoinix update now produces a new system generation, because the revision is part of the script. Set `nix-bitcoin.revision = null;` to opt out ([#&#8203;243](bitcoinix/bitcoinix#243)).

See [Upgrading to config version 0.1.6](https://docs.bitcoinix.net/upgrading.html#upgrading-to-config-version-016).

#### New

- **[Unbeholden Wallet](https://docs.bitcoinix.net/services.html#connect-to-unbeholden-wallet):** a watch-only wallet that runs in the browser and hands transactions to an air-gapped signer over QR codes. Enable it with `services.unbeholden-wallet.enable = true;` ([#&#8203;230](bitcoinix/bitcoinix#230)).
- **nodeinfo** shows the bitcoinix revision and the package version of each service. `nodeinfo --version` prints only the revision, `nodeinfo NAME ...` only the given entries ([#&#8203;243](bitcoinix/bitcoinix#243)).

#### Fixes

- lnd announces its onion address with the port Tor forwards. With a `services.lnd.port` other than 9735, peers couldn't reach the node over Tor ([#&#8203;228](bitcoinix/bitcoinix#228)).
- clnrest replaces an empty or `null` admin rune on start. Generate connection URLs from `lnconnect-clnrest` again if they were created with such a rune ([#&#8203;217](bitcoinix/bitcoinix#217)).
- btcpayserver with the clightning backend joins `services.clightning.group`, so a custom group works ([#&#8203;238](bitcoinix/bitcoinix#238)).
- The lnd seed and electrs index migration steps keep the data when an earlier step fails ([#&#8203;242](bitcoinix/bitcoinix#242)).

#### Updates

| Package                       | 0.1.5       | 0.1.6                                                                            |
| ----------------------------- | ----------- | -------------------------------------------------------------------------------- |
| lnd                           | 0.21.6-beta | [0.21.8-beta](https://github.com/lightningnetwork/lnd/releases/tag/v0.21.8-beta) |
| RTL                           | 0.15.16     | [0.15.17](https://github.com/Ride-The-Lightning/RTL/releases/tag/v0.15.17)       |
| extra-container (flake input) | 0.17        | [1.0.1](https://github.com/extra-container/extra-container/releases/tag/v1.0.1)  |
| Unbeholden Wallet             | –           | [0.4.0](https://github.com/unbeholdendev/unbeholden-wallet/releases/tag/v0.4.0)  |

Also: mempool builds with Node.js 24 ([#&#8203;246](bitcoinix/bitcoinix#246)); the docs say what netns-isolation doesn't isolate ([#&#8203;237](bitcoinix/bitcoinix#237)) and how to close public SSH without losing access ([#&#8203;234](bitcoinix/bitcoinix#234)).

Contributors: [@&#8203;msgilligan](https://github.com/msgilligan), [@&#8203;ostermayer](https://github.com/ostermayer), [@&#8203;prusnak](https://github.com/prusnak), [@&#8203;seberm](https://github.com/seberm), [@&#8203;unbeholdendev](https://github.com/unbeholdendev), [@&#8203;viberaven](https://github.com/viberaven).

Full changes: <bitcoinix/bitcoinix@v0.1.5...v0.1.6>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNDEuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjI0MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: agent <[email protected]>
Reviewed-on: https://git.home.unbeholden.dev/unbeholden/infra/pulls/140
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 breaking Changes existing user config; needs a versioning.nix entry type: bug Behaviour is wrong vs. documented or intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lndconnect and lnconnect add an onion-address entry for the operator user even when the operator is disabled, and that breaks every onion address

5 participants