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.
There was a problem hiding this comment.
🟡 Changes recommended
Active findings include a critical managed-node identity-validation bypass, an unbounded identity RPC that can stall node admission and channel opening, and confirmation rendering regressions.
3 open issues
What changed in this PR
This PR moves swap confirmations from HTML strings into Blazor component markup and adds LND identity checks before channel funding and gRPC node admission.
Changes:
- Adds formatted child content to
ConfirmationModaland record-backed markup for quote, quote-error, and Spark confirmations. - Checks the source LND’s reported pubkey before opening a channel and when adding a managed node through gRPC.
- Adds tests for identity comparison and rejected operations, and updates existing channel-opening mocks.
| File | Description |
|---|---|
test/NodeGuard.Tests/Services/LightningServiceTests.cs |
Tests identity matching, lookup failure, and refusal before channel funding. |
test/NodeGuard.Tests/Rpc/NodeGuardServiceTests.cs |
Tests that an identity mismatch prevents node insertion and worker scheduling. |
src/Shared/NewSwapModal.razor |
Replaces confirmation HTML strings with records and component markup. |
src/Shared/ConfirmationModal.razor |
Supports plain-text bodies or formatted child content. |
src/Services/LightningService.cs |
Adds identity comparison and checks the source before channel funding. |
src/Rpc/NodeGuardService.cs |
Adds an identity check before managed-node insertion. |
Review effort: Balanced
| } | ||
| else | ||
| { | ||
| @Body |
Head branch was modified
Head branch was modified


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.