From cdd086afc3044d9c8beefb0cc1abc307d1e4557e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 25 Nov 2026 09:25:18 -0700 Subject: webhooks, zaps: send user-supplied URLs through the SSRF guard Invoice webhooks must be plain http(s) strings and are posted with safePost (checked, pinned address, no redirects). Zap requests resolve the recipient lud16/lud06 and callback through safeGot instead of fetching them as-is. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6SEnsbshZrUDtTsxAX --- lib/invoices.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/invoices.ts') diff --git a/lib/invoices.ts b/lib/invoices.ts index 835b1247..1de1f95b 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -47,9 +47,13 @@ export const generate = async ({ invoice, user }) => { single_use, type = PaymentType.lightning, usePreimage, - webhook, secret, } = invoice; + // Only a plain http(s) URL is a webhook; anything else is dropped. + const webhook = + typeof invoice.webhook === "string" && /^https?:\/\//i.test(invoice.webhook) + ? invoice.webhook.slice(0, 2048) + : undefined; amount = Number.parseInt(amount || 0); tip = tip == null ? null : Number.parseInt(tip); -- cgit v1.2.3