aibtc-mcp-server
- Type
- MCP server
- Scanned
- Nov 17, 2026
- Version
- 429caf077751
- Files read
- 245
This MCP server gives an AI agent its own Bitcoin, Lightning, and Stacks cryptocurrency wallets to check balances, trade on DeFi protocols, sign messages, and automatically pay for x402 and L402 API calls. Its biggest risks are a shell command injection flaw in the Pillar browser-handoff tools that can run arbitrary commands on your computer, and bypasses in its wallet spending-limit safety rail that could let a tricked agent or malicious endpoint drain wallet funds.
What it can reach
- Files
- Reads and writes encrypted wallet keystores, credentials, settings, and spend/nonce ledgers in ~/.aibtc/; edits MCP client config files (~/.claude.json, ~/.cursor/mcp.json, ~/.codex/config.toml, etc.) during --install; scaffolds Cloudflare Worker project folders into user-specified directories; and lists digest files in ~/.aibtc/arxiv-research/digests/.
- Secrets
- Creates, unlocks, and signs with Bitcoin, Taproot, Lightning, Stacks, Pillar, and Nostr private keys; reads wallet passwords and API keys (CLIENT_MNEMONIC, AIBTC_WALLET_PASSWORD, AIBTC_WALLET_PASSWORD_FILE, ARC_CREDS_PASSWORD, HIRO_API_KEY, SPONSOR_API_KEY, OPENROUTER_API_KEY, MAGIC_EDEN_API_KEY, UNISAT_API_KEY) from environment variables or ~/.aibtc/; and manages an encrypted credential store at ~/.aibtc/credentials.enc.
- Network
- Broadcasts live Bitcoin, Lightning, sBTC, and Stacks transactions; queries blockchain indexers, DeFi APIs, Nostr WebSocket relays, OpenRouter, Magic Eden, arXiv, TaskMarket, and AIBTC services; and sends HTTP requests with automatic micropayments to any HTTPS URL given to the x402 tools.
- Browser
- Opens the user's default web browser to pillarbtc.com for passkey-based Pillar smart-wallet operations.
- Shell commands
- Executes OS shell commands (open, xdg-open, start) via child_process.exec to open browser URLs, and spawns a child Node server process in the OpenRouter bridge CLI subcommand.
- Other
- Moves real cryptocurrency funds (BTC, Lightning sats, STX, sBTC, SIP-010 tokens, Ordinals, Runes, and NFTs), deploys and calls smart contracts, and posts signed public messages to Nostr, AIBTC inboxes, and bounty boards.
Findings
-
HighTwo-request TOCTOU in postWithX402Payment bypasses spend limits and auto-reply caps
Both send_inbox_message_direct and inbox_auto_reply (enabled in the default core toolset) call postWithX402Payment. This helper first probes the URL with fetch, checks the 10-sat per-reply ceiling and wallet SpendLimiter against that first 402 response, and then—when extra.feePayer is present—creates a fresh Axios client wrapped with x402-stacks's wrapAxiosWithPayment and posts to the URL a second time. Because wrapAxiosWithPayment makes a new unauthenticated request and blindly signs whatever payment the second 402 response demands without enforcing SpendLimiter, per-payment caps, asset type checks, or matching the probed quote, a compromised or malicious endpoint (or another aibtc.com route reached via unencoded ../ segments in recipientBtcAddress) can serve a tiny quote on the probe and a wallet-draining STX/sBTC/USDCx amount on the second request.
Fix: Do not issue a second unauthenticated request through an uncapped payment wrapper; build and sign the sponsored transaction directly from the probed and verified accept object (enforcing canonical asset type, max amount, and SpendLimiter), and URL-encode/validate recipientBtcAddress.
-
MediumShell command injection in Pillar browser launcher
The openBrowser helper builds a shell command string with double quotes around the URL and passes it to child_process.exec. In pillar_create_wallet, the optional referral argument is an unvalidated string concatenated directly into that URL, and all Pillar handoff tools also interpolate the remote API's opId response field into the URL without encoding. If prompt injection tricks the agent into calling pillar_create_wallet with shell metacharacters in referral (such as $(...) on macOS/Linux or " & ... on Windows), or if the Pillar API returns a crafted opId, arbitrary OS commands run on the user's computer. The pillar tool group is off under --install's lean core profile, but enabled when AIBTC_TOOLS is unset (such as manual configs) or includes pillar.
Fix: Avoid invoking a shell: use child_process.execFile (for example execFile('open', [url]) on macOS and execFile('xdg-open', [url]) on Linux), validate referral and opId against strict allowlists, and encode query parameters with URLSearchParams.
-
MediumPer-input PSBT signing and unmetered broadcast bypass the Bitcoin spending limit
The server documents a default-on spending cap (50,000 sats per session and per day) covering psbt_sign and Bitcoin broadcasts. However, psbtOutflowSats sums input amounts only for the subset of inputs signed in the current psbt_sign call (signInputs), while subtracting the entire transaction's change outputs returning to the wallet (ownOutputSats). A tricked agent can construct a multi-input PSBT with a change output equal to one input and call psbt_sign one input at a time (signInputs: [0], then [1], and so on); every call computes zero net outflow and books 0 sats against the spend limiter. Calling psbt_broadcast then broadcasts the finalized transaction via mempool.broadcastTransaction directly without calling meteredBtcBroadcast, draining the wallet past the spending cap. The ordinals group is off under --install's core profile, but enabled when AIBTC_TOOLS is unset or includes ordinals.
Fix: In psbtOutflowSats, sum witnessUtxo amounts across all wallet-owned inputs in the PSBT (including inputs already signed in earlier calls) rather than only the current signInputs subset, and route psbt_broadcast through meteredBtcBroadcast or verify the transaction was already metered.
-
Mediumset_stacks_api_url leaks HIRO_API_KEY to arbitrary hosts and persistently hijacks RPC data
The set_stacks_api_url tool accepts any HTTP or HTTPS URL and saves it persistently to ~/.aibtc/config.json. Every subsequent HiroApiService request sends the user's configured HIRO_API_KEY in the x-hiro-api-key header to that custom URL, even though get_hiro_api_key masks the secret so the agent cannot read it directly. If prompt injection tricks the agent into calling set_stacks_api_url with an attacker-controlled URL, the user's Hiro API key is exfiltrated on the next Stacks query, and the attacker's server persistently controls balance reads, nonces, DeFi share-conversion post-conditions, and BNS fallback name resolution across restarts. This tool is in the dev group (off under --install's core profile, on when AIBTC_TOOLS is unset or includes dev).
Fix: Only attach the x-hiro-api-key header when requesting official *.hiro.so HTTPS origins, and require custom RPC endpoints to be configured by the user via environment variables rather than a runtime tool.
-
MediumSSRF to localhost and internal networks via HTTPS-to-HTTP redirect in x402 tools
src/services/x402.service.ts:763
probe_x402_endpoint and execute_x402_endpoint are enabled by default in the core profile and check only that the initial URL starts with https://. They then issue the request with Axios's default redirect follower, which silently follows 301/302/307/308 redirects from an external https:// URL to plain http:// addresses on 127.0.0.1, private LAN ranges, or cloud metadata services (169.254.169.254), and returns non-JSON text responses verbatim to the agent. A prompt-injected agent can use probe_x402_endpoint (documented as read-only and always safe) to read internal HTTP services on the user's machine or network.
Fix: Validate resolved IP addresses against loopback, link-local, and private network ranges on both the initial request and every redirect hop, and reject protocol downgrades from HTTPS to HTTP.
-
Mediumexecute_x402_endpoint does not bind payment execution to the probed price
src/tools/endpoint.tools.ts:66
For paid x402 APIs, the server's safety model probes the endpoint first (returning the price for user approval) and instructs the agent to re-call execute_x402_endpoint with autoApprove: true. However, execute_x402_endpoint has no maxAmount parameter and does not pass the approved quote to createApiClient. A malicious third-party x402 endpoint can return a 1-sat quote on the probe and then demand up to the 10,000-sat or 1-STX per-payment ceiling on the follow-up autoApprove: true request, charging up to 10,000 times what the user approved.
Fix: Add an expectedMaxAmount (and expectedAsset/expectedRecipient) parameter to execute_x402_endpoint, populate it in the probe's callWith suggestion, and abort in onBeforePayment if the 402 challenge exceeds it.
-
MediumServer system instructions tell the agent to proactively hunt and submit public bounties
On every MCP session, the server sends top-level system instructions telling the agent to periodically call bounty_list and bounty_get, do the work described, and submit deliverables via bounty_submit (all enabled by default in the core profile), and appends similar bounty prompts to 29 tool outputs. Because anyone with an L2 account can post 4,000-character markdown bounty descriptions on aibtc.com, nudging a general-purpose coding agent (which often has local file and shell access) to autonomously fetch stranger-authored tasks and post public submissions exposes users to unrequested external actions and indirect prompt injection.
Fix: Remove imperative instructions telling the agent to periodically check and complete bounties on its own, keeping bounty tools purely user-directed and treating fetched bounty descriptions as untrusted data.
-
LowUnbounded and unmetered maxFeeSats in lightning_pay_invoice bypasses sats spend cap
src/tools/lightning.tools.ts:417
lightning_pay_invoice reserves only the BOLT-11 invoice's face amount on the wallet SpendLimiter and passes the caller-supplied maxFeeSats (an uncapped non-negative integer) directly to Spark's payLightningInvoice. If prompt injection tricks the agent into paying a 1-sat invoice routed through an attacker-controlled Lightning node with a large maxFeeSats value, routing fees can drain the Lightning balance well past the 50,000-sat session and daily spending limits. The lightning group is off under --install's core profile, but enabled when AIBTC_TOOLS is unset or includes lightning.
Fix: Cap maxFeeSats in the input schema, reserve amountSats + effectiveMaxFeeSats on SpendLimiter before paying, and release any unused fee allowance if the exact fee paid is confirmed lower.
-
LowPillar direct smart-wallet tools auto-unlock without a password and bypass SpendLimiter
src/tools/pillar-direct.tools.ts:528
Unlike the main wallet (which requires a user password and enforces SpendLimiter), the pillar_direct_* tools automatically decrypt the Pillar signing key on disk using a plaintext secret file (~/.aibtc/pillar-signing-secret) with no session timeout, and sign SIP-018 authorizations (such as pillar_direct_send to transfer sBTC and pillar_direct_add_admin to grant wallet recovery admin rights) without checking SpendLimiter. While passwordless auto-unlock is mentioned in the Pillar skill reference, bypassing the server's advertised global sBTC spending limit is undocumented. The pillar group is off under --install's core profile, but enabled when AIBTC_TOOLS is unset or includes pillar.
Fix: Meter sBTC outflows in pillar_direct_send, pillar_direct_supply, and pillar_direct_boost against SpendLimiter before signing, and gate pillar_direct_add_admin behind explicit user confirmation.
-
LowAuto-installer configures unpinned @latest package execution via npx
Running --install writes npx -y @aibtc/mcp-server@latest into the user's MCP client configuration. Every time the MCP client launches, it automatically downloads and executes the latest published npm version without version pinning, meaning a future supply-chain compromise of the npm package would immediately run on existing installations with access to ~/.aibtc/ keystores.
Fix: Pin the installed package version in generated MCP configs (or offer a --pinned install flag) so updates are reviewed rather than fetched automatically at startup.
-
LowarXiv research tools fetch paper metadata over unencrypted HTTP
src/tools/arxiv-research.tools.ts:25
arxiv_search and arxiv_compile_digest query http://export.arxiv.org/api/query over plaintext HTTP instead of HTTPS, allowing a network attacker to tamper with returned titles and abstracts fed into the agent's context.
Fix: Change ARXIV_API to https://export.arxiv.org/api/query.
