Repository navigation
Description
Commit: 67f53b6 (master). Files: modules/rtl.nix, pkgs/rtl (RTL 0.15.8).
What I found
RTL talks to lnd's REST API and to clnrest over HTTPS on loopback: https://127.0.0.1:8080 for lnd (the services.lnd.restAddress and restPort defaults) and clnrest's address and port for clightning (modules/rtl.nix:133). RTL 0.15.8 sets rejectUnauthorized: false on every one of these requests (backend/utils/common.js:141, 175, 202, 233, 474, backend/controllers/lnd/webSocketClient.js:85, backend/controllers/cln/webSocketClient.js:57) and has no option to pin a certificate. Each request carries the full admin macaroon in the Grpc-Metadata-macaroon header, read from the copy bitcoinix makes at modules/rtl.nix:207, or the admin rune from modules/rtl.nix:212.
RTL only wants and is after lnd and clightning (modules/rtl.nix:193-195), so it keeps running when they stop, and Restart = "on-failure" keeps it up through backend errors.
Both ports are unprivileged and bound on 127.0.0.1. Without netns-isolation, any local user can bind them while the real service is down.
Attack
A local unprivileged user waits for lnd to stop (an update, systemctl stop lnd, a crash), binds 127.0.0.1:8080 with a self-signed certificate and answers RTL's next poll. RTL accepts the certificate and sends the admin macaroon. With it the attacker can send payments and withdraw on-chain funds once lnd is back. lnd exits when it can't bind its REST listener and Restart=always loops it, so holding the port also decides how long the window stays open. The same works against clnrest's port for the admin rune.
I verified this against the pinned RTL source (the 0.15.8 tarball) and the module. BTCPay does this right, for comparison: modules/btcpayserver.nix:219-222 pins lnd's certificate with certfilepath and uses a restricted macaroon.
Fix
- Stop RTL when its backend stops:
bindsTo(orpartOf) lnd and clightning inmodules/rtl.nix, so RTL never sends credentials while the real listener is gone. This is the cheap change and closes most of the window. - Make RTL verify the backend certificate. RTL has no option for it, so a small patch in
pkgs/rtlcan setrejectUnauthorized: truewithcafromservices.lnd.certPathand clnrest's certificate, or RTL can be asked upstream for a CA option. - Give RTL a scoped macaroon instead of a copy of
admin.macaroon, as BTCPay and charge-lnd get. RTL needs more than read-only, but not everything admin grants. - netns-isolation moves the listeners to per-service addresses, which blocks the takeover from the root namespace. Worth a sentence in the RTL docs until the above lands.
The RTL web UI itself is plain HTTP on 127.0.0.1:3000 with one shared password. The same port trick while RTL is down lets a local user serve a copy of the login page to an operator coming in over an SSH tunnel and collect the password. Lower impact, and bindsTo doesn't help there. TLS or a unix socket for the UI would.
Found by DeepSeek V4.1 Flash 1017 (max) in the audit of master b7ebfdc (GLM 5.3 (max) ran too), graded by Codex (GPT-6 Astra, xhigh), and verified by hand against RTL 0.15.8 and the module.
Activity
rtl: stop RTL when lnd or clightning stops
rtl: stop RTL when lnd or clightning stops (#250)
prusnak commentedon Nov 13, 2026
#250 has been merged
@ostermayer what else needs to be done to close this issue?
ostermayer commentedon Nov 14, 2026
#250 closed most of the window, but not all of it. clightning's start only waits until clnrest's port accepts a connection, and any listener passes that check. So a local user who takes the port first still gets the rune. RTL also never checks the backend's cert.
PR #258 fixes that part: RTL now pins lnd's cert and clnrest's server cert, and checks all other HTTPS connections against the system CAs. It says "Fixes #151".
The other two ideas in the issue, a scoped macaroon for RTL and TLS for RTL's web UI, are hardening and don't fix the leak. I can open separate issues for them if you want them.
rtl: pin the TLS certificates of lnd and clnrest (bitcoinix#258)