Repository navigation
Conversation
… the source node before opening a channel The swap confirmation is laid out in NewSwapModal's markup from a small record of the values it shows, instead of being assembled as a string. ConfirmationModal takes its body as text, or as child content for a formatted message. Before a channel is opened, the LND at the source node's endpoint is asked for its identity and the open only goes ahead when it is the node's pubkey. AddNode over gRPC makes the same check before adding a managed node.
There was a problem hiding this comment.
🔒 Automated security review
The PR reworks the swap confirmation into encoded Blazor markup — this actually removes a stored-XSS vector, since the swap provider's quote error was previously interpolated into HTML rendered via MarkupString — and adds an LND identity check before funding channel opens and before gRPC AddNode. The modal side is clean; all other ConfirmationModal callers pass plain text. The identity check is a useful misconfiguration guard, but it trusts a self-asserted GetInfo response: the endpoint being checked can simply claim the expected pubkey, so it does not stop the malicious-endpoint case its own comment describes. AddNode also now dials a caller-chosen endpoint pre-persistence, giving any API-token holder a network-probing oracle.
Reviewed Lunar-Rails/NodeGuard #682 at 223f148 — 1 inline finding(s), 0 not anchorable, 1 below the posting threshold.
1 lower-severity observation(s)
- LOW · infra — AddNode dials a caller-chosen endpoint before persisting, a probing oracle (
src/Rpc/NodeGuardService.csline 820)
The gRPC interceptor authenticates any valid unblocked API token but applies no per-RPC authorization, so any token holder can call AddNode. The new pre-persistence check makes the server open a gRPC connection to the caller-supplied Endpoint with the caller-supplied macaroon. The FAILED_PRECONDITION response distinguishes 'could not be asked' (host/port unreachable) from 'The LND at X is ' (something answering), and even reflects the answering LND's identity pubkey. The token holder can therefore sweep internal hosts and ports from NodeGuard's network position before anything is stored or audited as a node. Gain is limited to service discovery — pubkeys are public and the macaroon is the caller's own — hence LOW.
🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.
| var info = await _lightningClientService.GetInfo(node); | ||
| if (info == null) | ||
| { | ||
| return $"The LND at {node.Endpoint} could not be asked for its identity, so it cannot be confirmed to be node {node.Name}"; | ||
| } | ||
|
|
||
| if (!string.Equals(info.IdentityPubkey, node.PubKey, StringComparison.OrdinalIgnoreCase)) | ||
| { |
There was a problem hiding this comment.
MEDIUM · authn — Node identity check trusts the endpoint's self-asserted pubkey
GetInfo returns whatever IdentityPubkey the answering server claims; it is not a proof of key. An attacker who sets a node's Endpoint and ChannelAdminMacaroon (a NodeManager/Superadmin editing the node in Nodes.razor, which permits both) points the node at a modified LND or fake gRPC server that answers GetInfo with the node's real pubkey — public information advertised on the Lightning network — and accepts the configured macaroon. GetNodeIdentityError returns null, so OpenChannel proceeds: the wallet's PSBT funds a 2-of-2 channel whose entire local balance sits on the attacker's LND and is spendable by them. Multisig signers approving the request see only the node name, not the endpoint, so the switch is invisible to them. TLS does not help: CreateLightningClient accepts any server certificate (LightningClientService.cs:71), so a network-position attacker can spoof the same exchange. A real binding would require SignMessage/VerifyMessage with the node key or pinning the LND TLS cert.
Threat: a NodeGuard user with node-edit rights (NodeManager role) running their own gRPC endpoint, or a network attacker between NodeGuard and the node, starting from an authenticated NodeGuard session with the NodeManager role (can edit a node's endpoint and channel admin macaroon), or a network position on the path to the endpoint → the check passes for an attacker-controlled LND, so an approved channel open funds a channel whose balance the attacker controls — the exact fund misdirection this PR's check claims to prevent
Checks
Ruled out: Checked GetInfo (LightningClientService.cs:143): response is self-asserted, only the macaroon authenticates. Checked TLS: DangerousAcceptAnyServerCertificateValidator (line 71, pre-existing) means the connection does not authenticate the LND either. Grepped for SignMessage/VerifyMessage: only proto definitions, no proof-of-key anywhere. Checked OpenChannel reuses the same source object/endpoint after the check, so no TOCTOU — the spoof is at the check itself.
Verified: Confirmed end to end. GetNodeIdentityError (src/Services/LightningService.cs:1639-1658) trusts GetInfo's self-asserted IdentityPubkey; no proof-of-key (SignMessage/VerifyMessage) exists outside proto stubs. Nodes.razor:72,91 lets a NodeManager edit both Endpoint and ChannelAdminMacaroon, and the open flow (LightningService.cs:373) gates wallet funding on this check before OpenChannel on the same endpoint — a NodeManager pointing the node at a rogue LND that echoes the public pubkey passes the check and receives the channel's local balance. TLS is no barrier: DangerousAcceptAnyServerCertificateValidator (LightningClientService.cs:71) also enables a network-position spoof. The check is introduced by this PR and its comment explicitly claims to mitigate edited endpoints, so it is not pre-existing or out of scope.
🤖 automated review — reply not-an-issue to dismiss
The swap confirmation dialog was assembled as one long string in NewSwapModal's code and handed to ConfirmationModal. It is now laid out in NewSwapModal's markup, from a small record holding the values each variant shows (quoted fees, a failed quote, or Spark's caps). ConfirmationModal takes its body as plain text, or as child content when the message needs formatting. The wording and layout of the three swap confirmations are unchanged, and the other callers of ConfirmationModal pass plain sentences and need no change.
Opening a channel now starts by asking the LND at the source node's endpoint for its identity. The open goes ahead only when that is the pubkey NodeGuard has for the node; otherwise the request is refused with the reason logged, and it is retried on the usual schedule. AddNode over gRPC makes the same check before adding a managed node, and answers FAILED_PRECONDITION when it does not hold.
Tests cover the identity comparison, the refused channel open and the refused AddNode.