Skip to content

fix(payments): refuse an LNURL verify URL on a private address - #1392

Merged
cameri merged 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/lnurl-verify-url-ssrf
Dec 4, 2026
Merged

cameri merged 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/lnurl-verify-url-ssrf

Conversation

@Priyanshubhartistm

@Priyanshubhartistm Priyanshubhartistm commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The LNURL payments processor requested the verify URL from the provider's invoice response as it was. It now refuses a verify URL on a private, loopback or link-local address, and does not follow a redirect from it. A verify URL on the origin of the configured invoiceURL is requested as before.

Related Issue

#1022, finding F-031.

Motivation and Context

The verify URL is not something the operator configured: it comes from the provider's answer to an invoice request, and the relay then sends a GET to it every time it checks the invoice. A provider that returns http://169.254.169.254/... or http://127.0.0.1:8080/... makes the relay request services it can reach. I did not find a destination check on this request.

  • On the origin (scheme, host and port) of paymentsProcessors.lnurl.invoiceURL, the URL is requested as before. A provider hosted on a private network, such as an LNbits container, still works, and the operator already chose that origin.
  • On any other origin, the host is resolved by the relay with the lookup the NIP-05 check uses (createSafeLookup), which refuses a host with a private address, and an IP literal is checked with isBlockedAddress. The request is direct, with no proxy, on agents of its own so that NODE_USE_ENV_PROXY cannot send it through a proxy that resolves the host itself.
  • No redirect is followed on either path, since its target would not be checked. The verify endpoint of LNURL-verify answers with JSON directly.
  • A verify URL that is not http: or https:, is empty or is not a URL is refused before any request.

A provider that serves its verify URL from another origin on a private address, or redirects it, stops working. I know of no such provider and it is documented in docs/PAYMENTS.md.

How Has This Been Tested?

  • Unit tests with a stubbed client: the configuration passed for the invoice origin and for another origin, a port that differs counting as another origin, a private network invoice URL, the lookup refusing localhost, eight private or loopback literals (127.0.0.1, 10.0.0.5, 192.168.1.1, 169.254.169.254, [::1], [::ffff:127.0.0.1] and others) and five unusable URLs (file:, ftp:, text, empty, undefined), none of which makes a request.
  • Three tests with the real axios against a local server: a verify URL on the invoice origin is reached, a redirect from it is not followed, and a host that resolves to loopback on another origin is never connected to.
  • Taking out the redirect limit, the lookup, the literal check or the origin comparison each fails 3, 4, 8 and 12 of these tests.
  • pnpm run test:unit (3802 passing), pnpm run test:cli (194 passing), pnpm lint, pnpm run build:check, pnpm run check:deps, commitlint and changeset status.

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Summary by CodeRabbit

  • Security
    • LNURL payment verification requests are blocked when a URL points to a private, loopback, or link-local address on a different origin from the configured invoice URL.
    • Verification URLs must use HTTP or HTTPS. Requests do not follow redirects, and DNS-resolved addresses are checked for other origins.
    • URLs on the configured invoice URL’s origin may use private-network addresses.
  • Documentation
    • Updated LNURL setup guidance to describe the verify URL requirements and restrictions.

Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
@changeset-bot

changeset-bot Bot commented Dec 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9921537

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The LNURL payment processor now configures provider-supplied verify-URL requests. It allows same-origin URLs, checks addresses for other origins, rejects invalid URLs, and does not follow redirects. Tests and payment setup documentation cover these restrictions.

Changes: LNURL verify URL handling

Layer / File(s) Summary
Verify URL request controls
src/payments-processors/lnurl-payments-processor.ts, test/unit/payments-processors/lnurl-payments-processor.spec.ts, docs/PAYMENTS.md, .changeset/lnurl-verify-url-private-addresses.md
getInvoice now supplies a request configuration for verify URLs. The configuration validates the URL and protocol, disables redirects, and applies address checks to URLs outside the configured invoiceURL origin. Tests cover request options, URL validation, DNS results, and redirect refusal. The payment setup documentation and changeset describe the restrictions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Processor as LnurlPaymentsProcessor
  participant Config as verifyRequestConfig
  participant Axios
  participant Lookup as Safe lookup
  Processor->>Config: Configure request for verify URL
  Config-->>Processor: Return request configuration or reject URL
  Processor->>Axios: Request verify URL with configuration
  alt URL matches invoice origin
    Axios->>Processor: Return verification response without redirects
  else URL has another origin
    Axios->>Lookup: Resolve host and check addresses
    Lookup-->>Axios: Return permitted addresses or reject
    Axios->>Processor: Return verification response without redirects
  end
Loading

Possibly related issues

  • cameri/nostream#1022: Finding F-031 describes unrestricted GET requests to provider-supplied verify URLs. This change adds origin and address checks for that request path and refuses redirects.
Merge Risk: Minimal · up to 99215

This change stops the LNURL payments processor from requesting provider-supplied verify URLs that point at private, loopback, or link-local addresses on another origin. It also stops following redirects on those requests. URLs on the configured invoice origin behave as before, and the new rules are documented. No unresolved merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the LNURL payments processor now refuses a provider-supplied verify URL that resolves to a private address. The changeset, docs, processor code, and tests all match th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the LNURL payments processor now refuses a provider-supplied verify URL that resolves to a private address. The changeset, docs, processor code, and tests all match this. The fix prefix matches the behavior change. The title does not mention the same-origin exception or the redirect refusal, but it does not need to cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each URL with care
Same-origin paths may travel there
Other hosts must pass the test
No private address gets a request
Redirects stop before they roam
Safe polling hops back home

Recent review info

Automatic approval policy

Commit: 992153739951.

Setting Effective value Source
Automatic approvals Enabled Global configuration
Merge risk Minimal Global configuration
Security risk Not set Global configuration

Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89af7df8-fecb-4a81-b226-e4f480b743de
Commits

Reviewing files that changed from the base of the PR and between a13d1da and 9921537.

Files selected for processing: 4

  • .changeset/lnurl-verify-url-private-addresses.md
  • docs/PAYMENTS.md
  • src/payments-processors/lnurl-payments-processor.ts
  • test/unit/payments-processors/lnurl-payments-processor.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@greptile-apps

greptile-apps Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge.

Summary

Restricts where the LNURL processor can send verify requests.

  • LNURL invoice polling now checks provider-supplied verify URLs.

Priyanshubhartistm explicitly acknowledged that cross-origin private endpoints and endpoints that redirect will stop working.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Invoice verify URL] --> B{Valid HTTP or HTTPS URL?}
  B -->|No| C[Refuse request]
  B -->|Yes| D{Same origin as configured invoiceURL?}
  D -->|Yes| E[Request without redirects]
  D -->|No| F{Private IP literal?}
  F -->|Yes| C
  F -->|No| G[Request directly with safe DNS lookup]
  G --> H{Any resolved address blocked?}
  H -->|Yes| C
  H -->|No| I[Connect without redirects]
Loading

Reviews (1) · Last reviewed commit: "fix(payments): refuse an LNURL verify UR..." · Reviewed by Greptile

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 47408586734

Coverage increased (+0.02%) to 81.13%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (21 of 22 lines covered, 95.45%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/payments-processors/lnurl-payments-processor.ts 22 21 95.45%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15736
Covered Lines: 13279
Line Coverage: 84.39%
Relevant Branches: 8710
Covered Branches: 6554
Branch Coverage: 75.25%
Branches in Coverage %: Yes
Coverage Strength: 705.98 hits per line

💛 - Coveralls

@chappie-daemon chappie-daemon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at 9921537. The guard reuses src/utils/safe-lookup.ts — the checker added for NIP-05 in 85d0481d — instead of inventing a second one, which is the right seam.

What I checked:

  • Origin exception is exact. It compares new URL(...).origin, so pay.example.com@evil.com, a different scheme or a different port all take the checked path; the spec covers the port case.
  • Literals before the request. isIP catches http://[::ffff:127.0.0.1]/, 0.0.0.0 and the metadata address; createSafeLookup refuses a hostname whose A/AAAA record points inward, so a name never dials a private address even after rebinding.
  • No redirects, proven by a real server. maxRedirects: 0 on both paths, and the spec's 302 to /target shows only /redirect was fetched.
  • proxy: false with own agents is the same posture NIP-05 takes (src/utils/nip05.ts:201): with NODE_USE_ENV_PROXY the global agent would resolve the host itself and skip the lookup.

One tradeoff, stated rather than fixed: an off-origin verify URL now always connects directly, so a deployment that can only reach the internet through a proxy gets a refusal where it used to get a request. That fails closed and matches the NIP-05 default (proxy: disabled ignores HTTPS_PROXY), and if it ever matters the seam is PinnedProxyAgent, not a third agent.

Coveralls - Integration is -0.03% on the integration suite; non-required, and the unit suite that this PR touches is up.

Approving.

@cameri
cameri merged commit 17c9d51 into cameri:main Dec 4, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants