You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(payments): refuse an LNURL verify URL on a private address - #1392
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.
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.
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.
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.
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: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
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]
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The LNURL payments processor requested the
verifyURL 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 configuredinvoiceURLis 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/...orhttp://127.0.0.1:8080/...makes the relay request services it can reach. I did not find a destination check on this request.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.createSafeLookup), which refuses a host with a private address, and an IP literal is checked withisBlockedAddress. The request is direct, with no proxy, on agents of its own so thatNODE_USE_ENV_PROXYcannot send it through a proxy that resolves the host itself.http:orhttps:, 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?
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.axiosagainst 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.pnpm run test:unit(3802 passing),pnpm run test:cli(194 passing),pnpm lint,pnpm run build:check,pnpm run check:deps, commitlint andchangeset status.Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit