diff options
| author | Adam Soltys <[email protected]> | 2026-11-13 16:11:02 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-13 16:11:02 -0700 |
| commit | b8b409910f71976959135b336b409c4923cf4c87 (patch) | |
| tree | 21115643c3bed3c967a9bdc2fe1c75fa9cdfa07d /routes/lnurl.ts | |
| parent | 589519f2556b2d434ed23f26c705df73b6149d7c (diff) | |
| download | coinos-server-b8b409910f71976959135b336b409c4923cf4c87.tar.gz coinos-server-b8b409910f71976959135b336b409c4923cf4c87.zip | |
lnurl: fetch user-supplied URLs through the SSRF guard, relay only protocol fields
Lightning address sends (pay() and POST /send/<lnaddr>) now validate the
name and domain and fetch through safeGot instead of plain got. Zap receipt
relays from the zap request must resolve to public hosts. The LNURL decode
and proxy routes return only LNURL protocol fields instead of whatever JSON
the upstream sent, and the proxy logs failures rate-limited with a generic
error to the client. Also blocks the 172.42.0.0/16 docker range.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'routes/lnurl.ts')
| -rw-r--r-- | routes/lnurl.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/routes/lnurl.ts b/routes/lnurl.ts index 7f04db5d..e28bb510 100644 --- a/routes/lnurl.ts +++ b/routes/lnurl.ts @@ -5,6 +5,7 @@ import { serverPubkey2 } from "$lib/nostr"; import { SATS, bail, fail, getInvoice, getUser } from "$lib/utils"; import { bech32 } from "bech32"; import { safeGot } from "$lib/safe-fetch"; +import { lnurlPayload } from "$lib/lnurl-payload"; import { verifyEvent } from "nostr-tools"; import { v4 } from "uuid"; @@ -99,7 +100,7 @@ export default { bech32.fromWords(bech32.decode(text, 20000).words), ).toString(); - const r = await safeGot(url); + const r = lnurlPayload(await safeGot(url)); res.send(r); } catch (e) { bail(res, e.message); @@ -240,11 +241,12 @@ export default { const { url } = req.query; if (!url) return bail(res, "url required"); try { - const r = await safeGot(url); + const r = lnurlPayload(await safeGot(url)); res.send(r); } catch (e) { - warn("lnurl proxy failed", url, e.message); - bail(res, e.message); + const n = quiet("lnurl-proxy-failure", 5 * 60 * 1000); + if (n !== null) warn("lnurl proxy failed", url, e.message, suppressed(n)); + bail(res, "Unable to resolve a valid LNURL response"); } }, |
