Skip to content

rtl: give RTL its own lnd macaroon and clightning rune - #291

Merged
prusnak merged 1 commit into
bitcoinix:masterfrom
ostermayer:rtl-scoped-credentials
Nov 21, 2026
Merged

prusnak merged 1 commit into
bitcoinix:masterfrom
ostermayer:rtl-scoped-credentials

Conversation

@ostermayer

@ostermayer ostermayer commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #261.

RTL used lnd's admin macaroon and clnrest's admin rune. Whoever controls the RTL process, for example through a bug in RTL or Node before login, had full control of both backends. The admin macaroon can bake new macaroons and the admin rune can create new runes, so that access could outlast a fix in RTL. RTL still has to send funds and open and close channels, so a takeover can still move funds. This PR takes away the rest.

This PR:

  • gives RTL services.lnd.macaroons.rtl with a uri permission for each lnd RPC that RTL calls. These are the 40 RPCs of the lnd REST routes in RTL's backend/controllers/lnd. Entity permissions would allow more, like offchain:write for DeleteAllPayments. So an RTL update that calls another RPC has to add it to the list. rtl-copy-macaroon reads /run/lnd/rtl.macaroon as the rtl user and doesn't follow a symlink, because the lnd user can write /run/lnd.
  • adds services.lnd.macaroons.<name>.optionalPermissions for uri permissions that a macaroon gets only when lnd has their RPC. lnd has the RPCs of invoicesrpc and walletrpc only when its package has their build tags, and it refuses to bake a permission for an RPC that it doesn't register. So RTL's 7 permissions for these RPCs are optional, and the other 33 stay required. Only for optional permissions does lnd-create-macaroons ask lnd for its RPCs, with lncli listpermissions. It leaves out each optional permission whose RPC lnd lacks, and logs a warning. permissions stays exact, so lnd's start still fails for a misspelled URI. The root key ID covers both lists. Without optional permissions, a macaroon keeps its ID, and lnd-create-macaroons is the same as on master.
  • gives RTL a rune that allows only the 32 clightning methods it calls, including listclnrest-notifications, which clnrest checks for RTL's websocket. A second restriction is the comment bitcoinix-rtl#, which marks RTL's runes. RTL's start creates the rune once and keeps it at rtl-rune in clightning's network dir, where RTL can't write. It keeps the rune while clightning has it stored with these restrictions and not blacklisted. It blacklists every other rune with the marker, so after a method change, a failed start or a lost rtl-rune, only one RTL rune stays valid. A rune without the marker, like the admin rune, is never blacklisted. Then, if it didn't keep the rune, it makes a new one. clightning gives a new rune the next unique ID, also when that ID is blacklisted. So the start checks each new rune the same way, and creates up to 10 until one passes, or fails.
  • keeps the paths of RTL's copies, so RTL's next start overwrites the admin credentials that earlier versions copied. When RTL uses only one backend, its start removes the old copy for the other one.
  • adds a 0.2.0 notice for RTL users, release and upgrade note drafts, and a "Backend credentials" section to the RTL part of docs/services.md. The section says how to revoke RTL's rune. clnrest checks the rune of a websocket client only when it connects, so you blacklist the rune and then restart clightning, which also starts RTL again. When only RTL enables clightning, you revoke the rune before the deploy that disables RTL.

The only new option is optionalPermissions. An app that reads RTL's copies of the admin credentials needs its own credentials now, and the notice says so.

The rune handling follows #288, with two differences. RTL had the admin rune in its data dir until now, so a file that RTL can write must not decide which rune gets revoked. That's why the rune lives in clightning's network dir. The script also finds RTL's rune in the output of showrunes with jq, so the rune never shows up in a command line, and runes that clightning doesn't store, like ones derived with createrune rune=..., are never blacklisted.

Testing

  • New test rtl-permissions. RTL's macaroon has exactly the 40 uri permissions (lncli printmacaroon), or those of them that the scenario's lnd has, can call getinfo and can't bake a macaroon. lnd's journal warns about exactly the left-out ones. lnd's checkpermissions confirms each of the other RPCs, and answers "permission denied" for BakeMacaroon, StopDaemon, DeleteAllPayments and SignOutputRaw. clnrest accepts RTL's rune for getinfo and refuses createrune with 401. checkrune accepts each of the 32 methods, from a separate list in the test, and refuses createrune, blacklistrune, showrunes and stop. The test also logs in to RTL's API and checks that the dashboard requests of each backend return 200.
  • rtl-credentials covers the new sources. A symlink at /run/lnd/rtl.macaroon isn't followed. After each start exactly one valid rune has the marker. A start makes a new rune for a symlink, an empty file, null, garbage, the admin rune, a rune derived from it, another app's rune, an earlier RTL rune and a rune revoked by hand. It blacklists earlier RTL runes, also one that a lost file left behind, and never the others. When RTL's rune and the next two unique IDs are blacklisted, a restart of RTL gets the ID after them, and clnrest accepts it. When RTL's rune and the next 10 free IDs are blacklisted, the start fails, keeps both files and still revokes an earlier RTL rune, and the next start gets the ID after them. With createAdminRune = false, the test uses a rune without restrictions in place of the admin rune.
  • module-config gets testRtlUnusedCredentials and testVersioningRtlCredentials, clnrest-admin-rune now checks that RTL keeps its own rune when clightning restarts with a new admin rune, and lnd-macaroon-revocation also checks macaroons that allow GetInfo through a uri permission, like RTL's.
  • New scenario lndWithoutWalletrpc, not in the CI matrix. It builds the pinned lnd without walletrpc and runs RTL on lnd. It passes, with the 35 other permissions in RTL's macaroon and a warning for each WalletKit RPC. On the previous head, rtl-permissions fails there, as it expects all 40.
  • clnrest-admin-rune now starts RTL before it reads RTL's rune. Run alone on a fresh regtest VM, it failed on an earlier head, because RTL hadn't copied its rune yet. It also resets RTL's start limit with clightning's, as RTL on clightning only hit the limit there.
  • A custom macaroon with GetInfo and a misspelled ListChannels fails lnd's start with invalid permission action on master and on this head, and no macaroon is installed. On the previous head, lnd started with a GetInfo-only macaroon. For this macaroon and for BTCPay Server, charge-lnd and Unbeholden LNURL on lnd, lnd-create-macaroons has the same store path and the same root key IDs as on master. module-config checks the root key IDs with and without optional permissions and rejects optional permissions that aren't uri permissions. lnd-macaroon-filters checks the new filter of listpermissions output against unexpected output.
  • Every new negative check fails on master. There, bakemacaroon works, checkpermissions is valid for the admin RPCs, checkrune accepts the four admin methods and clnrest answers 201 for createrune. On an earlier head of this PR, checkpermissions is valid for DeleteAllPayments, and after the restart with blacklisted IDs RTL started with a blacklisted rune.
  • default, regtest, netnsRegtest, netns and lndWithoutWalletrpc pass on a KVM host. So do regtest scenarios with clightning, lnd and RTL and createAdminRune = false, with RTL on lnd only and with RTL on clightning only.
  • module-config, test-runner, lnd-macaroon-filters, shellcheck and the release notes check pass.

Known limits. The admin macaroon and the admin rune stay valid, so a copy taken before the upgrade still works. When you disable RTL or its clightning node, its rune stays valid, and docs/services.md says how to revoke it. After clightning starts on a new or older database, a new RTL rune can get the unique ID of an older rune, and the next rotation then revokes both. RTL's start logs a line in that case, and the docs explain it. With a custom lnd package that lacks some of RTL's RPCs, RTL's features that use them fail, and lnd's journal says which permissions RTL didn't get. When the next 10 unique IDs are blacklisted, RTL's start fails, and systemd starts it again every 10 seconds. Each failed try stores 10 more runes, so the docs say to blacklist only the IDs of runes that you have. With RTL on lnd, the first deploy restarts lnd to create RTL's macaroon.

Written with Claude Opus 5.5, reviewed with Claude Fable 5.2, GPT-6 Astra, Kimi K3.1 Pro, DeepSeek V4.1 Flash, GLM 5.3 and Qwen4-Max.

@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 Nov 18, 2026
@ostermayer ostermayer added the type: security Hardening or vulnerability (public-safe only) label Nov 18, 2026
@ostermayer

Copy link
Copy Markdown
Collaborator Author

The netnsRegtest failure is a flake. lnd-wallet-init stops lnd about 0.3 s after it starts, and lnd panicked on that early stop (unable to subscribe to chans: subscription server shutting down). lnd-restart-on-clean-exit then found the failed exit in lnd's journal. The same scenario passes on this head on a KVM host. Could someone re-run it? I can't re-run jobs here.

@seberm

seberm commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

The netnsRegtest failure is a flake. lnd-wallet-init stops lnd about 0.3 s after it starts, and lnd panicked on that early stop (unable to subscribe to chans: subscription server shutting down). lnd-restart-on-clean-exit then found the failed exit in lnd's journal. The same scenario passes on this head on a KVM host. Could someone re-run it? I can't re-run jobs here.

@github-actions github-actions Bot added the status: rebase needed Merge conflicts need to be resolved label Nov 19, 2026
@prusnak prusnak added this to the v0.2.0 milestone Nov 20, 2026
@ostermayer
ostermayer force-pushed the rtl-scoped-credentials branch from e06e403 to 882f2e7 Compare November 20, 2026 11:02
@github-actions github-actions Bot removed the status: rebase needed Merge conflicts need to be resolved label Nov 20, 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.

Requesting changes on rune rotation and the scope of RTL’s lnd macaroon. I verified the rotation failure in a Core Lightning regtest VM and tested the narrower macaroon in a separate lnd regtest VM. The local module-config and test-runner flake checks passed.

Comment thread modules/rtl.nix Resolved
Comment thread modules/rtl.nix Resolved
Comment thread docs/services.md Resolved
Comment thread test/suite/security.py Resolved
prusnak added a commit that referenced this pull request Nov 20, 2026
`netnsRegtest` failed once on #291 because lnd panicked.
`lnd-wallet-init` stopped lnd right after a new wallet came up, and lnd
crashed on that early stop with `unable to subscribe to chans:
subscription server shutting down`. `lnd-restart-on-clean-exit` then
found the failed exit in lnd's journal.

lnd answers RPCs and notifies systemd before its server has started all
subsystems, so neither `lncli getinfo` nor `systemctl start` closes that
window. This PR:

- adds `wait_for_lnd_server` to `test/suite/helpers.py`. When the
regtest fixture has mined blocks (`num_blocks`), it waits until `lncli
state` reports `SERVER_ACTIVE`. lnd starts its server only once its
chain has synced. Without these blocks, as on the test mainnet, lnd
never starts its server and can't panic this way, so the helper keeps
the `getinfo` wait there. The fixture's data doesn't change when a run
selects a subset of the tests.
- uses it in the tests that run before `lnd-restart-on-clean-exit` and
stop, restart or terminate lnd. These are `config-replace`,
`lnd-wallet-init` and `rtl-stops-with-backend`.
- also waits before `restart-bitcoind` and `config-replace` stop
bitcoind, because lnd requires bitcoind and stops with it. Both start
lnd before that wait, because lnd can be down there. `restart-bitcoind`
reads whether lnd is enabled from a new
`test.data.restart-bitcoind.lnd`, so this also works when a run leaves
out test `lnd`.
- tells test authors about the helper in `test/README.md`.

## Testing

- `netnsRegtest` and `default` pass on a KVM host. In the `netnsRegtest`
log, the `SERVER_ACTIVE` wait comes right before each stop of bitcoind
in `restart-bitcoind` and `config-replace`.
- These focused runs on `regtestBase` with lnd also pass.
  - `lnd-wallet-init` alone. All three of its waits use `lncli state`.
  - `config-replace` alone, with lnd down when the test starts.
- `restart-bitcoind` and `lnd-restart-on-clean-exit`, without test
`lnd`. Both stops of bitcoind wait for `SERVER_ACTIVE`. Right after
boot, the first wait took about 2.5 s, so the stop used to land in that
window.
- The panic is a race, so I can't trigger it on demand.

`lnd-macaroon-revocation` runs after `lnd-restart-on-clean-exit` and has
its own failure check, so I left its stops of lnd for a separate change.
`lnd-create-macaroons` also restarts lnd right after a start once it
deletes stale root keys. Only a module change can close that window, and
that wait needs a timeout, because a node that's still syncing never
starts its server. `backups` stops bitcoind too, but it runs only on the
test mainnet.

Written with Claude Opus 5.5, reviewed with Claude Fable 5.2.
@ostermayer
ostermayer force-pushed the rtl-scoped-credentials branch from 882f2e7 to 8528361 Compare November 20, 2026 20:14
@ostermayer

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All in 8528361.

  • RTL's start now checks each new rune the same way as the stored one, so it never installs a rune with a blacklisted ID. It creates up to 10 runes until one passes. Otherwise it fails with an error that names the last ID, and systemd's next start 10 seconds later tries the next IDs. rtl-credentials has two new steps. The first blacklists RTL's rune and the next two IDs, restarts RTL, and checks that the new rune has the ID after them and that clnrest answers 201. The second blacklists RTL's rune and the next 10 free IDs, and checks that the start fails and keeps both files, and that the next start gets the ID after them. A failed start still revokes RTL's earlier runes. On the previous head the first step fails. RTL started with a blacklisted rune.
  • RTL's macaroon now has a uri permission for each of the 40 RPCs. I mapped every lnd call in RTL 0.15.17's backend/controllers/lnd and backend/utils/common.js, including the websocket client, through lnd 0.21.8's REST yaml files. They give exactly the 40 RPCs in RTL_LND_RPCS. genseed, unlockwallet and initwallet go to the wallet unlocker, which takes no macaroon. rtl-permissions now checks with lncli printmacaroon that the macaroon has only these 40 permissions, and that checkpermissions refuses DeleteAllPayments. On the previous head lnd answered valid: true for it.
  • The docs now say to blacklist the rune and then restart clightning, which closes clnrest's websocket clients. clightning's start starts RTL again, and RTL makes a new rune. With RTL or its clightning node disabled in the config, the restart doesn't start RTL.
  • With createAdminRune = false, rtl-credentials now mints a rune without restrictions in place of the admin rune. A regtest scenario with clightning, lnd, RTL and createAdminRune = false passes. On the previous head it failed at cat admin-rune.
  • Added the notice modules/versioning/0.2.0/rtl-credentials.nix, an upgrade note draft and testVersioningRtlCredentials. The notice applies to every RTL config and says that lnd restarts once when RTL uses lnd. I checked that lnd's unit changes only in lnd-create-macaroons. The release note links to the upgrade note.
  • Rebased on master (cbc2310). default, netns, regtest and netnsRegtest pass on a KVM host, and so do a regtest scenario with RTL on lnd only, module-config, test-runner, shellcheck and the release notes check.

@ostermayer
ostermayer requested a review from viberaven November 20, 2026 20:15
@github-actions github-actions Bot added the type: feature New capability or service label Nov 20, 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.

The five earlier findings are addressed on the packaged backends. The local module-config, test-runner, and release-note checks passed. In a two-backend regtest VM with createAdminRune = false, rtl-credentials and rtl-permissions also passed, including the blacklisted-ID rotation cases and the denial of DeleteAllPayments.

I’m requesting changes because enabling RTL now prevents a previously working custom lnd build from starting. The inline comments include the base-versus-head result, a separate cold-start test race, and a correction to the decommissioning instructions.

Comment thread modules/rtl.nix Resolved
Comment thread test/suite/restarts.py Resolved
Comment thread docs/services.md Resolved
@seberm

seberm commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Nothing to add beyond viberaven's open threads. The change only narrows RTL's access, and the new rune/macaroon steps fail closed and keep the rune out of command lines.

Tested: compared the 40 lnd RPCs and 32 clightning methods with RTL 0.15.17's backend/controllers/{lnd,cln} and utils, HTTP verbs included: they match. module-config passes on this head merged with current master. CI scenarios on 8528361 are green.

Assisted-by: Claude Code (Claude Opus 5.5)

@ostermayer
ostermayer force-pushed the rtl-scoped-credentials branch from 8528361 to 8f82639 Compare November 21, 2026 04:24
@ostermayer

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All in 8f82639.

  • lnd-create-macaroons now gets the RPCs that lnd registers with lncli listpermissions, once per start. For each macaroon it leaves out the uri permissions of RPCs that lnd doesn't register, logs a warning for each that names the macaroon and says that lnd's package may lack the RPC's build tag, and bakes and checks the rest. Entity permissions don't change. It fails only when no permission is left. The root key ID still comes from the configured permissions, so after an update to a package with the tag, lnd bakes all permissions with the same root key. This covers every custom macaroon, also unbeholden-lnurl's. On a KVM host, with the pinned lnd built without walletrpc and RTL on lnd, 8528361 fails as you saw. On master and on this head, lnd and RTL start and lncli getinfo works. On this head lnd's journal has a warning for each of the 5 WalletKit RPCs, and RTL's macaroon has the other 35 permissions and the configured root key ID. The "Custom macaroons" docs say so too. They also say that lnd's start fails when a macaroon has no permission left, and that a service with such a macaroon should also restart when lnd's package changes.
  • clnrest-admin-rune now waits for RTL before it reads RTL's rune. Run alone on a fresh regtest VM with both backends, it failed on 8528361 with No such file or directory, and it passes now.
  • The revocation docs now cover a config where only RTL enables clightning. You stop RTL and blacklist its rune while clightning still runs, and then deploy. I checked the evaluated config too. Disabling RTL or its clightning node then removes clightning's unit and lightning-cli. A start of lnd or clightning before the deploy starts RTL again, so the docs also say to check right before the deploy that RTL is stopped and its runes are blacklisted.
  • Rebased on master (8a678bb). default, netns, regtest and netnsRegtest pass on a KVM host. So do regtest scenarios with createAdminRune = false, with RTL on lnd only and with RTL on clightning only. module-config, test-runner, lnd-macaroon-filters, shellcheck and the release notes check pass too.

@ostermayer
ostermayer requested a review from viberaven November 21, 2026 04:24

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

I verified the three findings from the last review. The custom lnd build now starts with RTL, clnrest-admin-rune passes on a fresh two-backend VM, and the decommissioning instructions cover the case where disabling RTL removes Core Lightning. With the pinned packages and createAdminRune = false, both rtl-credentials and rtl-permissions passed.

I’m requesting two changes to the new permission filtering. It relaxes validation for unrelated custom macaroons, and the built-in permission test fails on the reduced lnd build even though the issued credential is correct.

Comment thread modules/lnd-macaroons.nix Resolved
Comment thread test/suite/security.py Resolved
@ostermayer
ostermayer force-pushed the rtl-scoped-credentials branch from 8f82639 to 07069f9 Compare November 21, 2026 16:26
@ostermayer

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All in 07069f9.

  • permissions is exact again, as on master. The new option services.lnd.macaroons.<name>.optionalPermissions takes uri permissions that a macaroon gets only when lnd has their RPC, and only these can be left out. lnd-create-macaroons runs lncli listpermissions only when a macaroon has optional permissions, and it accepts only one object with a non-empty method_permissions object. RTL's 7 grants for invoicesrpc and walletrpc are optional, as lnd 0.21.8 builds these subservers only with their tags. The other 33 stay required, also the 2 routerrpc ones, which have no build tag. A macaroon without optional permissions keeps its root key ID, and its lnd-create-macaroons has the same store path as on master. I checked this on a KVM host for BTCPay Server, charge-lnd and Unbeholden LNURL on lnd, and for your case, GetInfo with a misspelled ListChannels. In a VM with your case, lnd's start fails with invalid permission action on master and on this head, and there's no /run/lnd/app.macaroon. On 8f82639, lnd starts with the GetInfo-only macaroon.
  • rtl-permissions now leaves out the RPCs of the services that the scenario's lnd lacks (test.data.lnd-missing-services), in the exact-set check and in the authorization loop. It also checks that lnd's journal warns about exactly these RPCs. The new scenario lndWithoutWalletrpc builds the pinned lnd without walletrpc and runs RTL on lnd. It isn't in the CI matrix. It passes on this head with the 35 grants. With 8f82639's test, it fails at the 40-grant assertion.
  • Tests on a KVM host. default, netns, regtest, netnsRegtest and lndWithoutWalletrpc pass. So do regtest scenarios with createAdminRune = false, with RTL on lnd only and with RTL on clightning only. A correction to my last reply. Its "lnd only" and "clightning only" runs had both backends, because the test base enables both of RTL's nodes with mkDefault. This round's runs turn the other node off. With RTL on clightning only, clnrest-admin-rune failed once because RTL hit its start limit, so the test now resets it with clightning's and starts RTL before it reads the rune. module-config, test-runner, lnd-macaroon-filters, shellcheck and the release notes check pass too.

@ostermayer
ostermayer requested a review from viberaven November 21, 2026 16:27

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

Both findings from my previous review are resolved in 07069f9a. I verified that a misspelled required RPC makes lnd startup fail and leaves the client without a macaroon. The generated startup script skips listpermissions when no optional grants are configured.

rtl-permissions passed with exactly 40 RPC grants on the pinned lnd and exactly 35 in lndWithoutWalletrpc. The reduced build logged each of the five omitted WalletKit RPCs, and RTL’s dashboard requests succeeded. The Core Lightning credential and cold-start rune checks also passed.

@prusnak
prusnak enabled auto-merge November 21, 2026 17:15

@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

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

No must/should items. The allowlists match RTL 0.15.17's backend source exactly: the 32 clightning methods, and the lnd REST paths and verbs (websocket and backup job included), which map to the 40 RPCs. optionalPermissions is opt-in: macaroons without it keep their root key IDs and make no listpermissions call, and permissions is still validated exactly. The new rune and macaroon steps fail closed and keep the rune out of command lines.

Tested: module-config passes on 07069f9 merged with current master; CI is green on 07069f9.

Assisted-by: Claude Code (Claude Opus 5.5)

RTL got lnd's admin macaroon and clnrest's admin rune, which has no
restrictions. So whoever controls the RTL process had full control of
both backends, and could bake new lnd macaroons and create new runes.

lnd: RTL gets `services.lnd.macaroons.rtl`, with a `uri` permission for
each lnd RPC that the REST routes in RTL's `backend/controllers/lnd`
call. Entity permissions would allow more, like `offchain:write` for
`DeleteAllPayments`. `rtl-copy-macaroon` copies `/run/lnd/rtl.macaroon`
to the file name that RTL reads. It reads as the rtl user and doesn't
follow a symlink, as the lnd user can write `/run/lnd`.

lnd registers the RPCs of `invoicesrpc` and `walletrpc` only when its
package has their build tags, and it refuses to bake a permission for
an RPC that it doesn't register. So RTL's permissions for these RPCs go
to the new option `services.lnd.macaroons.<name>.optionalPermissions`.
Only when a macaroon has optional permissions, lnd-create-macaroons
asks lnd for its RPCs. It leaves out each optional permission whose RPC
lnd lacks, and logs a warning. A required permission that lnd refuses
still fails lnd's start. The root key ID covers both lists. Without
optional permissions, a macaroon keeps its ID, and lnd-create-macaroons
doesn't change.

clightning: RTL gets a rune with one restriction that allows only the
methods in RTL's `backend/controllers/cln` and the method that clnrest
checks for RTL's websocket, and a comment restriction that marks it as
RTL's. RTL's start creates the rune once at `rtl-rune` in clightning's
network dir, which RTL can't write, and keeps it while clightning has it
stored with these restrictions and not blacklisted. It blacklists all
other stored runes with the marker, so only one RTL rune stays valid.
Runes without the marker, like the admin rune, are never blacklisted.
Then, if it didn't keep the rune, it creates a new one. clightning gives
a new rune the next unique ID, also when this ID is blacklisted. So the
start checks each new rune, and creates up to 10 until one isn't
blacklisted, or fails.

RTL's copies keep their paths, so its next start overwrites the admin
credentials that it had. When RTL uses only one backend, its start
removes the old copy for the other backend. A 0.2.0 notice tells RTL
users that apps which read these copies need their own credentials.

Fixes bitcoinix#261.

Assisted-by: Claude Code (Claude Opus 5.5)
@prusnak
prusnak force-pushed the rtl-scoped-credentials branch from 07069f9 to eb790ad Compare November 21, 2026 22:38
@prusnak
prusnak merged commit 4c68ceb into bitcoinix:master Nov 21, 2026
28 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 type: security Hardening or vulnerability (public-safe only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtl: RTL gets lnd's admin macaroon and an unrestricted clightning rune instead of scoped credentials

4 participants