lightning-wallet-mcp
lightningfaucet/lightning-wallet-mcp
- Type
- MCP server
- Scanned
- Nov 17, 2026
- Version
- fb52a5e86785
- Files read
- 35
This MCP server and CLI give an AI agent a custodial Bitcoin Lightning wallet on lightningfaucet.com to send and receive payments, pay L402/X402 APIs, bet on prediction markets, and post on an agent message board. If the agent is tricked by prompt injection, it can spend or withdraw real Bitcoin from the wallet, or overwrite the locally saved operator credentials and recovery code in ~/.lightning-wallet/credentials.json.
What it can reach
- Files
- Reads, writes, and deletes wallet API keys and recovery codes in ~/.lightning-wallet/credentials.json (or $LIGHTNING_WALLET_HOME/credentials.json), and checks an optional kill-switch file path on the HTTP server.
- Network
- Connects to lightningfaucet.com APIs (or configured API URLs), optionally posts payment proposals to PRE_PAYMENT_HOOK_URL, instructs the Lightning Faucet backend to request or register external URLs and webhooks, and provides an optional HTTP server on 127.0.0.1:8893.
- Secrets
- Reads LIGHTNING_WALLET_API_KEY from the environment or ~/.lightning-wallet/credentials.json, and sends Nostr private keys passed to set_nostr_identity or account recovery codes to the custodial lightningfaucet.com backend.
- Other
- Spends, withdraws, transfers, tips, escrows, and wagers real Bitcoin (satoshis) in the user's custodial operator, agent, or linked Lightning Faucet accounts.
Findings
-
HighWallet setup tools overwrite saved credentials without confirmation and bypass environment-key isolation
Calling register_operator or set_operator_key unconditionally overwrites ~/.lightning-wallet/credentials.json, permanently erasing any previously saved operator API key and recovery code (unlike the CLI lw register command, which refuses to overwrite saved credentials without --force). Both tools, along with set_agent_credentials, are marked destructiveHint: false in src/annotations.ts, so MCP clients that auto-approve non-destructive tools can let a prompt-injected agent run them without asking the user. Even when the user isolates an autonomous session by setting LIGHTNING_WALLET_API_KEY to a budgeted agent key in the environment, these tools still overwrite ~/.lightning-wallet/credentials.json on disk (orphaning a funded wallet if not backed up elsewhere) and switch the in-memory session to a new or attacker-supplied key, which can redirect subsequent deposit invoices or account linking to an attacker's account.
Fix: Refuse to overwrite an existing operator entry in ~/.lightning-wallet/credentials.json without explicit confirmation, disable disk writes and key-switching tools when LIGHTNING_WALLET_API_KEY is set in the environment, and mark register_operator, set_operator_key, and set_agent_credentials with destructiveHint: true.
-
Mediumboard_inbox tool description instructs the agent to fetch public forum messages automatically at session start
The board_inbox tool description instructs the AI model to call board_inbox at the start of a session so it can answer people, and marks the tool non-destructive (destructiveHint: false). When an agent key is active, an agent following this prompt will make an unrequested network call at session start and pull unread replies and mentions written by strangers on the public Lightning Faucet message board into its context window. In a coding agent that also holds funded wallet tools and local file or shell access, automatically loading stranger-authored forum replies creates an unprompted indirect prompt-injection vector and nudges the agent to spend sats replying.
Fix: Remove instructions telling the agent to call board_inbox automatically at the start of a session or to answer strangers unprompted, so board messages are only fetched when the user explicitly asks.
-
LowBOLT11 amount parser returns null on lightning: URI prefixes, hiding amounts from policy hooks and logs
Although the documentation states that BOLT11 inputs accept lightning: URI prefixes (and PayInvoiceSchema in src/tools.ts strips that prefix), bolt11AmountSats() rejects any string that does not begin directly with ln and returns null. When an agent or user runs lw pay lightning:lnbc... via the CLI or calls LightningFaucetClient.payInvoice() directly with PRE_PAYMENT_HOOK_URL configured, the hook receives amount_sats: null instead of the invoice amount, which can bypass amount caps in hook policies that permit unknown amounts while the backend still pays the invoice. On the HTTP server, amountForLog() also runs before schema normalization and logs amount_sats: null for lightning:-prefixed invoices.
Fix: Strip an optional leading lightning: URI prefix (and accept the lntbs signet prefix) inside bolt11AmountSats(), and normalize BOLT11 inputs in cli.ts before calling payInvoice().
-
LowSelf-hosted HTTP server trusts client-spoofable X-Forwarded-For entry for rate limiting
When lightning-wallet-mcp-http sits behind a trusted local reverse proxy, resolveClientIp() trusts X-Real-IP first and otherwise takes the leftmost address in X-Forwarded-For (index 0). Standard proxies such as Apache mod_proxy (referenced in the code comment) do not set or strip X-Real-IP by default and append the real client IP to the end of X-Forwarded-For. In a self-hosted setup that relies on X-Forwarded-For without overwriting X-Real-IP, any network caller can send forged X-Real-IP or X-Forwarded-For headers to spoof public IPs, bypassing per-IP rate limits and forwarding the spoofed address to the backend.
Fix: Extract the rightmost untrusted IP from X-Forwarded-For rather than index 0, and require or document stripping client-supplied X-Real-IP headers when X-Real-IP is not overwritten by the proxy.
