DEV Community

qanzhi111
qanzhi111

Posted on

BTCPay Server Macaroon Exploit: How a Stolen Credential File Drained Lightning Nodes in Hours

The Alert That Came Too Late

At 11:51 AM ET on August 7, 2026, BTCPay Server posted a one-line warning that sent shockwaves through the Bitcoin merchant community:

"There is a critical vulnerability being actively exploited on BTCPay Server, which can result in the loss of funds."

By the time Foundation — the company behind the Passport hardware wallet — read the alert, it was already too late. Their Lightning node had been drained overnight. Every channel force-closed, every balance swept clean.

"How many BTCPay Lightning nodes were swept?" asked Zach Herbert, Foundation's CEO, on X. "Our Foundation node was drained overnight by attackers."

Citadel21, the Bitcoin publication run by pseudonymous commentator hodlonaut, reported the same pattern: node emptied, funds gone, before anyone could react.

This wasn't a theoretical risk. It was the third major Bitcoin infrastructure attack in nine days.

What Actually Happened: The Macaroon Theft

The vulnerability targeted .macaroon files — credential tokens that function as API keys for LND (Lightning Network Daemon) nodes. Whoever holds these files controls the entire Lightning node: opening channels, closing them, routing payments, and moving funds.

The BTCPay flaw allowed unauthenticated remote attackers to retrieve these .macaroon files without any login or access credential. No password needed. No exploit chain required. Just a request to the right endpoint, and the credentials were handed over.

From there, draining the node was trivial. Attackers force-closed all payment channels and swept the balances to wallets they controlled.

Why This Is Different From a Typical Smart Contract Exploit

In DeFi, attacks usually target contract logic — a reentrancy bug, an oracle manipulation, a flash loan exploit. The attacker interacts with on-chain code.

Here, the attack bypassed the blockchain entirely. It went after the infrastructure layer — the server running the payment processor. No smart contract was involved. No transaction was front-run. The attackers simply stole the keys to the front door.

This is closer to a traditional server compromise than a DeFi exploit, and that's what makes it so dangerous. Security audits that focus on Solidity code will never catch a vulnerability in how credentials are exposed by a payment server.

Patching Alone Does Not Make You Safe

Here is the part most operators will miss, and it's the reason this incident is still unfolding:

Updating to BTCPay Server v2.4.2 stops new credential theft. It does nothing to invalidate credentials already stolen.

BTCPay's own advisory is explicit about the three-step remediation:

  1. Update to v2.4.2 — closes the vulnerability
  2. Revoke all LND macaroons at the node level — this destroys the root signing key, not just deletes files. Stolen macaroons survive a software update.
  3. Move funds from any BTCPay-generated on-chain hot wallet and recreate the wallet

An operator who patches but skips steps 2 and 3 remains fully compromised. As Evan Kaloudis, developer of the ZEUS wallet, put it bluntly: "Don't assume you're safe after upgrading."

Why AI Audits Missed This Bug

The Bitcoin Red Team — a volunteer group formed in response to the Coldcard crisis — spent the week running AI-assisted security audits across Bitcoin's open-source codebases. Using Moonshot's Kimi K3 model at $10,000 per day in compute, they found approximately 5,000 vulnerabilities across 390 projects in 27.5 hours, including 85 critical and 635 high-severity issues.

They submitted their findings to BTCPay. But the critical macaroon vulnerability? It wasn't in their report.

BTCPay founder Nicolas Dorier credited Sparrow Wallet developer Craig Raw for finding the actual bug — not through AI scanning, but by losing money:

"We got extremely lucky that a dev was impacted who could analyze the logs to understand what was going on. Somehow, this wasn't found by AI scans, but by him losing money."

When challenged about why the Red Team's AI missed it, Dorier explained: "The AI report we got from Red Team didn't include this one. But this bug was really sneaky. I am not surprised a simple scan didn't find it, or thought it was low risk."

This is a crucial lesson for the growing AI-audit industry: automated tools excel at finding pattern-matched vulnerabilities in code logic. But authentication bypasses in credential handling — especially those involving how files are served over HTTP — require understanding the full system architecture, including deployment configurations and file access patterns.

Nine Days, Three Attacks: Bitcoin's Infrastructure Crisis

The BTCPay exploit is the third major Bitcoin infrastructure attack in nine days, forming a pattern that should concern every Bitcoin user and developer:

Date Target Loss Vector
July 30 Coldcard firmware ~$115M from 5,200+ addresses Weak RNG in seed generation (firmware v4.0.1)
August 3 Boltz swap bridge Indefinite suspension Attackers "iterate faster than we can patch"
August 7 BTCPay Server Multiple Lightning nodes drained Unauthenticated macaroon file theft

Each attack targets a different layer:

  • Coldcard: Hardware wallet firmware (key generation)
  • Boltz: Cross-chain swap infrastructure (service logic)
  • BTCPay: Payment processing server (credential management)

The common thread: none of these attacks compromise the Bitcoin protocol itself. They exploit the peripheral infrastructure that users trust to interact with Bitcoin safely.

The Self-Hosting Paradox

BTCPay Server's architecture — self-hosted, open-source, non-custodial — is simultaneously its greatest strength and its most dangerous weakness.

Unlike a centralized payment processor, there is no operator who can patch on behalf of users. Every merchant, exchange, and wallet running the software must apply the fix on their own machine. BTCPay sits behind Bitcoin checkout for Namecheap (which processed $73 million in BTC revenue across 1.1 million transactions), along with hundreds of smaller merchants.

The thefts were already underway before the warning went out. The public advisory passed 550,000 views within five hours — but for node operators like Foundation, the damage was done hours earlier.

Self-hosting gives you sovereignty. It also gives you the full maintenance burden of enterprise infrastructure security, with no dedicated security team watching your back.

What DeFi and Bitcoin Infrastructure Can Learn From Each Other

The DeFi world has developed sophisticated monitoring tools — real-time exploit alerts, automated fund freezing, bug bounty programs. Bitcoin infrastructure has historically relied on slower, more deliberate security processes.

The Coldcard-Boltz-BTCPay sequence suggests this gap needs to close fast:

  1. Credential rotation should be routine, not emergency-only. Macaroon files should be rotated on a schedule, not just after an incident.
  2. Automated monitoring for credential access — any unexpected access to .macaroon endpoints should trigger immediate alerts.
  3. Incident response plans for infrastructure operators should exist before the incident happens, not after the advisory goes live.

The Bottom Line

The BTCPay exploit is a wake-up call for the entire Bitcoin ecosystem. As the industry celebrates AI-powered audits finding thousands of vulnerabilities, this incident proves that the most dangerous bugs are still the ones that require human understanding of system architecture.

For BTCPay operators: update now, revoke macaroons, move hot wallet funds. All three steps. Not just the first one.

For the broader ecosystem: the next attack won't wait for you to read the advisory.


ChainSentinel provides AI-driven on-chain security monitoring and smart contract auditing. If you're operating Lightning infrastructure or DeFi protocols, continuous security assessment isn't optional — it's survival.

Follow for daily blockchain security analysis and exploit breakdowns.

Top comments (0)