Skip to content

Write the swap confirmation as component markup, and confirm the source node before opening a channel - #682

Open
markettes wants to merge 3 commits into
mainfrom
refactor/swap-confirmation-markup-and-node-identity
Open

markettes wants to merge 3 commits into
mainfrom
refactor/swap-confirmation-markup-and-node-identity

Conversation

@markettes

Copy link
Copy Markdown
Contributor

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.

… 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.
@markettes
markettes enabled auto-merge (squash) November 23, 2026 18:11

@lunar-patrol lunar-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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.cs line 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.

Comment thread src/Services/LightningService.cs Resolved
Copilot AI balanced review requested due to automatic review settings November 25, 2026 15:29

Copilot AI 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.

🟡 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 ConfirmationModal and 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

Comment thread src/Rpc/NodeGuardService.cs Resolved
Comment thread src/Services/LightningService.cs Resolved
}
else
{
@Body

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

auto-merge was automatically disabled November 25, 2026 16:36

Head branch was modified

@Jossec101
Jossec101 enabled auto-merge (squash) November 25, 2026 16:37
auto-merge was automatically disabled November 25, 2026 16:37

Head branch was modified

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants