Skip to content

lndconnect: another local user can take lnd's and clnrest's REST ports while they are down #342

Done

Description

@sebsgent

Without netns-isolation, lnd's REST server (127.0.0.1:8080 by default) and clnrest (127.0.0.1:3010) listen on the host's loopback address. While a daemon is down, for example during a restart or an update, any other local user can bind its port. This is the same problem #293 fixed for RTL.

The onion services from lndconnect.onion and clnrest.lnconnect.onion forward to these ports, and the WireGuard helpers connect to the same ports on the WireGuard address. The connection URLs use --nocert, so a wallet that connects during the downtime sends lnd's admin macaroon or clnrest's admin rune to whoever holds the port.

Adding the certificate to the URLs doesn't help ZEUS, the wallet our docs name:

  • Its lndconnect and clnrest parsers don't use the cert/certs parameter (utils/ConnectionFormatUtils.ts).
  • Over Tor it accepts any certificate for https .onion hosts (isOnionHttpsUrl).
  • Without Tor, certVerification is off by default.

So the fix has to stop other users from taking the ports.

Options so far:

  1. lnd onion service: lnd also serves REST on a Unix socket (restlisten=unix://…), and Tor forwards the onion service to it. Only lnd and tor can access the socket's directory. lnd keeps its TCP listener for RTL and local clients. The onion address and port stay the same, so wallets don't need to pair again.
  2. clnrest only accepts an IP address in clnrest-host, and the WireGuard URLs need the TCP ports, so option 1 doesn't cover them. Candidates:
    • netns-isolation, where the daemons listen on their namespace's address. This needs no new code, but it's optional today.
    • A firewall rule that accepts connections on the port only for the daemon's own sockets (nftables socket cgroupv2). Untested. It must keep working while the daemon is stopped and after a restart.
  3. Enable netns-isolation by default in the secure-node preset. This also covers other onion services that forward to loopback ports, such as electrs and fulcrum, where a wallet would send its addresses to whoever holds the port. It is a breaking change and needs a versioning notice.

Until this is fixed, netns-isolation prevents it.

@prusnak, what do you think about option 3? Reported by @ostermayer, who has a branch for option 1 ready.

Assisted-by: Claude Code (Claude Opus 5.5)

Activity

  1. added
    area: modules
    type: security
    status: needs decision
    on Nov 27, 2026
  2. ostermayer commented on Nov 27, 2026

    @ostermayer
    Collaborator

    A small correction. The branch I had ready put the certificate in the URLs, and I've dropped it. I'm building option 1 for lnd's onion service now and will link the PR here.

  3. ostermayer commented on Nov 27, 2026

    @ostermayer
    Collaborator

    #343 forwards lnd's onion service to a Unix socket. clnrest and the WireGuard URLs aren't part of it, so they stay open here.

  4. added this to the v0.2.1 milestone on Nov 27, 2026
  5. sebsgent commented on Nov 28, 2026

    @sebsgent
    ContributorAuthor

    #347 will close this issue. For v0.2.1:

    WireGuard and whether the secure-node preset should enable netns-isolation by default continue in #349.

    Assisted-by: Claude Code (Claude Opus 5.5)

  6. added a commit that references this issue on Nov 29, 2026
    7a6dc3b
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: modulesstatus: needs decisiontype: security

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions