mcp
- Type
- MCP server
- Scanned
- Nov 17, 2026
- Version
- 1df86cca5733
- Files read
- 37
This MCP server connects an AI agent to a Bitcoin Lightning wallet via Nostr Wallet Connect to check balances, manage invoices, send payments, and fetch paid web resources. Its biggest risk is financial loss and internal network exposure, because fetch_l402 automatically pays any invoice amount a remote server demands with no spending limit, and request_invoice can be tricked into making requests to local or private network addresses.
What it can reach
- Other
- Controls the connected Bitcoin Lightning wallet account, including reading balances and transaction history, creating invoices, and sending irreversible Bitcoin payments.
- Secrets
- Reads
NWC_CONNECTION_STRING(the wallet's Nostr Wallet Connect secret) and server settings from environment variables, or from HTTPAuthorizationheaders andnwcquery parameters when running in HTTP mode. - Files
- Reads environment variables from a
.envfile in the current working directory at startup. - Network
- Connects to Nostr relays for wallet operations, makes outbound HTTP requests to L402 endpoints, Lightning Address servers, and exchange-rate APIs, and listens on TCP port 3000 (
127.0.0.1by default, or all interfaces in Docker) whenMODE=HTTPis enabled.
Findings
-
HighUncapped automatic Bitcoin payment on HTTP 402 responses in fetch_l402
src/tools/lightning/fetch_l402.ts:58
When
fetch_l402requests a URL that responds with HTTP402 Payment Required,l402.fetchWithL402immediately pays whatever BOLT-11 invoice the remote server places in itsWWW-Authenticateheader, with no maximum amount parameter and without showing the price to the user or AI agent first. Even when a user intentionally asks to fetch a resource expecting a tiny microtransaction, a malicious or compromised server can return an invoice for the wallet's entire available balance (subject only to any wallet-side NWC budget) and drain funds irreversibly in one call.Fix: Add a required
max_amount_in_sats(or small default cap) parameter tofetch_l402and wrap thewebln.sendPaymentcall to parse the BOLT-11 invoice and reject any payment that exceeds the allowed maximum. -
MediumUnauthenticated SSE message endpoint and session hijacking in HTTP mode
When the server is started with
MODE=HTTP(the default in the providedDockerfile),POST /messageslooks up an active wallet session solely byreq.query.sessionIdwithout checking the caller's NWC authorization secret. In addition,GET /sselets any caller register a customreq.query.sessionIdkey (which can set a predictable ID or overwrite another user's session) and never deletes sessions when connections close, allowing anyone who obtains, predicts, or fixes asessionIdto callpay_invoiceagainst the victim's wallet.Fix: Require and verify the same NWC secret on
POST /messagesas onGET /sse, remove support for client-suppliedreq.query.sessionIdonGET /sse, store sessions in aMap, and delete and close the session onres.on('close'). -
MediumServer-side request forgery (SSRF) via Lightning Address resolution in request_invoice
src/tools/lightning/request_invoice.ts:39
Unlike
fetch_l402, therequest_invoicetool does not validate target addresses withassertPublicUrlor disable HTTP redirects. If an agent is tricked by prompt injection into callingrequest_invoicewith an attacker-controlled Lightning Address (user@attacker.com),ln.fetch()follows HTTP redirects and reads an attacker-suppliedcallbackURL from the LNURL response, whichln.requestInvoicethen fetches directly even if it points to127.0.0.1, private LAN hosts, or cloud metadata endpoints (169.254.169.254).Fix: Validate both the initial
.well-known/lnurlpURL and the returnedcallbackURL withassertPublicUrl, and perform both fetches withredirect: 'error'and a pinned DNS lookup. -
LowDNS rebinding can bypass SSRF filtering in fetch_l402
assertPublicUrlresolves the hostname withdns.lookupto block loopback, link-local, and private IPs, butl402.fetchWithL402subsequently callsfetchwith the original URL, causing a second independent DNS lookup. If an agent is tricked into callingfetch_l402on an attacker-controlled domain with a zero-TTL DNS record, the server can resolve to a public IP during the check and to127.0.0.1or169.254.169.254during the fetch, returning the internal HTTP response body to the agent.Fix: Use a custom
undiciAgentdispatcher with aconnect.lookupcallback that validates the resolved IP address withisPublicAddressat socket connection time so DNS is only resolved once. -
LowWallet spending secret accepted in URL query parameters in HTTP mode
In HTTP mode,
getConnectionSecretaccepts thenostr+walletconnect://URI (which contains the private key authorizing wallet payments) via thenwcURL query parameter, and the README demonstrates configuring clients this way. Query strings are routinely recorded in plaintext in reverse proxy, load balancer, and client logs, which can expose full spending access to the wallet.Fix: Accept the NWC secret only via the
Authorization: Bearerrequest header by default, or gate query-parameter authentication behind an explicit opt-in flag with a clear warning about URL logging.
