Chainflip - Rekt



Chainflip built its vaults so that 100 of 150 validators had to sign before a single coin moved.

On November 21, by Chainflip's account, an attacker used a registered-but-inactive validator account to reach the real validators, extracted their key shares, and signed away almost everything in the Bitcoin and Ethereum vaults outside the network.

A day earlier, an account funded with 20,500 FLIP registered as a validator, never joined the active set, and the network's validators accepted its connections like any other newcomer's.

The attacker then exploited a use-after-free flaw in libzmq, the open-source messaging library under the validators' peer-to-peer software, to run code inside validator processes.

It copied key shares from enough validators to sign for the vaults, and the signatures it produced were ones the protocol never requested.

133.34 BTC left the Bitcoin vault in two withdrawals, and the Ethereum vault gave up its ETH, USDC and USDT in one, roughly $12.6 million by Chainflip's count.

An internal monitor flagged the Bitcoin vault eight minutes after the first withdrawal, but nothing was set up to escalate it.

The last 10.48 BTC walked out three hours after the keys were rotated, still accessible via the stolen key.

A week and a half later, the protocol remains paused, and Chainflip is replacing every validator machine that was online during the attack.

When a 100-of-150 key sat on validator machines that accepted connections from any account that registered as a validator with the minimum stake, who was the threshold ever built to stop?

Credit: Chainflip, Bitquery, Defimon, AMLBot, GoPlus Security, BitOK, Trail of Bits, THORChain

The first alarm went off inside Chainflip, into an internal channel that escalated nothing.

At 06:41:01 UTC on November 21, about 122.86 BTC left the Bitcoin vault in a single transaction. Eight minutes later, an automated monitor posted a warning about the Bitcoin vault to an internal channel.

Chainflip's incident report explains why the warning went nowhere: The monitor was still being evaluated, had produced false positives, and wasn't connected to automated escalation.

Bitcoin Vault Withdrawal (about 122.86 BTC), 06:41:01 UTC:
20262de39ec3331d78be2b87f18c90cb2ee30363311dd43def14c3aecf155b7a

At 07:01:27, the stolen BTC moved again, to a second address.

Then the attacker turned to Ethereum.

At 07:09:59, a brand-new wallet received 0.99 ETH from Tornado Cash to pay for gas. Sixty seconds later, it sent one signed request to Chainflip's Ethereum vault, and the vault paid out 520.2 ETH, 3.25 million USDC and 758,141 USDT.

Bitquery found the vault had held exactly those amounts. It was left with none of the three.

Signer Wallet (sent the drain):
0x78fa4ac270db14886033e95b9b9e93f887aa2db0

Ethereum Vault Drain Transaction, 520.22 ETH at 07:10:59 UTC:
0xc928950f79b4e4697af674310d1f3a08c2659adc4d60e719f3af90ab023ff20f

Receiver Wallet:
0x7d14a719072da80076b4edcec3e3401209d21eaf

By 07:19:11, the stablecoins had been sold for ETH on Uniswap and 2,909 ETH had landed in Tornado Cash.

From gas money to mixer, the Ethereum leg took under ten minutes.

The public alarm arrived after the money had already gone dark. Defimon flagged the Ethereum drain about 22 minutes after it cleared, valued it at $4.86 million and pointed to a compromise of the aggregate signing key.

AMLBot later said the laundering looked scripted from start to finish.

Inside Chainflip, the first recorded alarm from a person came at 07:41, when a team member raised it in the team Discord, an hour after the first withdrawal.

At 07:50:27, the next escalation through Chainflip's AllQuiet incident response system came from a community member, not from Chainflip's own tooling. The first protocol responder came online at 07:52:49.

Governance moved next. A forced key rotation was proposed at 08:10:12 and executed at 08:14:54, with new keys active by 08:21:48.

Safe mode was proposed at 08:22, and swaps, deposits and withdrawals were paused by 08:31.

The State Chain's rotation had completed, but the vault's key change hadn't yet been confirmed on Ethereum. Bitquery saw the validators keep signing ordinary payouts with the same key for almost two hours after the drain, until Ethereum switched to the new key at 08:53:35, about 13 hours ahead of the regular schedule.

Chainflip says that change was held up behind earlier payouts that could no longer succeed, and had to be submitted manually.

At 09:14 UTC, Chainflip spoke publicly for the first time. It was aware of a "potential exploit" affecting its vaults, it said, and had put the protocol into full safe mode, disabling deposits, withdrawals, swaps and quoting.

That post came two hours and 33 minutes after the first withdrawal.

At 10:00:11, the governance multisig suspended the Ethereum vault contract, blocking any further vault-key transaction on it.

The chain held a clue from the start. Bitquery went through all 299,677 signatures Chainflip's Ethereum key contract had accepted since 2023. Each carried a number from a running count that climbed one step at a time, with occasional gaps.

The drain was the only one off the count: A 39-digit number that had never been used before.

A number off the count meant the payment never came through Chainflip's usual process. What it couldn't say was why. A leaked key, stolen shares or a failed check would all leave the same trace.

Through at least late morning UTC, the public figures covered Ethereum alone: $4.86 million.

That changed later in the day, when Chainflip posted a bounty offer aimed at whoever held its stolen bitcoin.

The Bitcoin vault, it turned out, had been hit first.

By November 23, estimates had climbed to roughly $12 million, well over double the early figure.

Chainflip's own count came with its incident report: About 133.34 BTC in two transactions, about $12.6 million in all, "effectively the entire vault balance at the time."

If the account behind it never joined the signing set, how did it get close enough to take the keys?

A Fix From 2020

20,500 FLIP got the attacker a seat in the waiting room.

At 11:00:18 UTC on November 20, the account registered as a validator, 79 seconds after it was funded.

Seven minutes later it registered a peer-to-peer identity, and validators started taking its calls.

Attacker Validator Account:
cFMH2YX722cFGNemZ5tbZnq7XvYZ3xWyTRdLrW1cLgyrJtEKe

That access was by design. A new validator has to be able to talk to the authority set before it can join it, so the network let it.

The entry point was the validators' peer-to-peer software, built on the open-source libzmq library.

By Chainflip's account, the attacker used a use-after-free flaw in libzmq to run code inside validator processes, then copied vault key shares from enough validators to sign transactions without the network.

Chainflip says the flaw was corrected in libzmq 4.3.3 and later, a release dated September 7, 2020. It hasn't said which version its validators were running.

If validators were running a version from before that fix, the library answering strangers predates Chainflip's mainnet by more than three years.

Even the version validators run now isn't the newest. Chainflip says every active validator runs a release built on libzmq 4.3.4, but libzmq released 4.3.5 on October 9, 2023, before Chainflip's mainnet launched.

The risk had been written down before. Chainflip's own docs name the real supermajority threat as someone with no skin in the game who finds an exploit in the validator software that lets them hijack the network.

The same docs list vault funds being lost if the Chainflip engine is "compromised or exploited" as a risk that could cost liquidity providers and swappers "potentially serious or even complete losses."

Trail of Bits' April 2023 review carried a related warning, rating vulnerable dependencies in Chainflip's back end and smart contracts a medium-severity finding.

Part 2 of Chainflip's incident report says it has not identified any flaws in the vault smart contracts, the threshold signature scheme or the State Chain's logic as a cause of the attack.

Chainflip's docs pitch FROST as the step up from GG20, the scheme THORChain was running when a malicious node pulled its vault key apart in May.

Chainflip hasn't identified a flaw in the threshold signature scheme. It didn't need one: Once enough shares were copied out of the validator processes, the scheme could no longer protect the keys.

What Chainflip still hasn't said is how many validators' shares were copied, or which advisory covers the flaw. It says it is confident in the main vectors used but hasn't yet confirmed the entire exploit chain with full confidence, and is holding back a detailed technical report while it strengthens its guardrails.

The Ethereum vault was drained at 07:10 UTC on November 21.

Why was there still bitcoin to steal at 11:24?

The Spare Key

On Ethereum, Chainflip had something to lock. On Bitcoin, it didn't.

Chainflip's docs say governance can freeze its smart-contract vaults, and at 10:00:11 it did, suspending the Ethereum vault contract.

Chainflip Ethereum Vault:
0xf5e10380213880111522dd0efd3dbb45b9f62bcc

Chainflip KeyManager (Ethereum key contract):
0xcd351d3626dc244730796a3168d315168ebf08be

Ethereum Key Change, 08:53:35 UTC:
0xc9585068e49afee59ac68b3972acc17c8be3a47aff42f0e4ea61a94a882610f8

Ethereum Vault Suspension, 10:00:11 UTC:
0xe1da5d56301ca4cf91c5b1808662985e9084554f21368786bf112b75b0fb8ffd

The Bitcoin vault is simply another Bitcoin address, so there is no contract to suspend. It spends whatever a valid Schnorr signature from its key tells it to.

Ethereum's vault had a freeze button. Bitcoin's had no brake that works against whoever holds the key.

At 11:24:18, three hours after the rotation completed, 10.48288011 BTC left that vault, "still accessible via the stolen key," in Chainflip's words. Why the stolen key still worked, neither report says.

Chainflip's Bitcoin vault docs describe rotation as moving the old vault's funds in a single transaction to an address under a different key.

Chainflip's Bitcoin vault docs describe rotation as moving the old vault's funds in a single transaction to an address under a different key. Funds sent to an old deposit address can only be unlocked with the old key, so the docs describe a "handover" of key shares to keep that access alive.

Second Bitcoin Vault Withdrawal, 10.48288011 BTC at 11:24:18 UTC:
bc010685d63ac43477eda016118cb5e0f164d3836577ef920851af374a122b01

Both Bitcoin hauls still sit at the attacker's two addresses as of December 2nd.

BTC Holding Address 1 (122.86136932 BTC):
bc1qm777twlzmelyutungyfw65ykn2l5kn68e6v4g6

BTC Holding Address 2 (10.48283731 BTC):
bc1qp5r8aemhg8pxytlhcn43k8ptc6l6y03vxud5pr

The Ethereum side never sat still. Within four minutes of the drain, every USDC and USDT token had been swapped for ETH, which nobody can freeze.

It had started a minute before the drain. The wallet that sent the signed request was brand new, funded with 0.99 ETH from Tornado Cash, and the drain was the only thing it ever did.

Signer Wallet (Submitted the signed drain transaction, funded by Tornado Cash): 0x78fa4aC270DB14886033e95b9B9E93F887aA2db0

Gas Funding from Tornado Cash (0.99 ETH), 07:09:59 UTC:
0xd6d3554c88eb1d39c4471c82c6aa4b65f3180d9e6b0d5a09140cf1643d517fa8

The receiver sold 3.25 million USDC for 1,910 ETH, then 758,141 USDT for 457 ETH, both on Uniswap.

USDC Swap, 07:12:59 UTC:
0xca19dc5fc4c06ac352cb401926472213c382c8c498760ed45568d4ba91f57d70

USDT Swap, 07:14:23 UTC:
0x7d06e292d061c2afa794f2af068b8a36eba6ffa3647ebf989922b7bb5acad18d

The receiver swapped on Uniswap, and the ETH went straight to a third wallet, the collector. The receiver then forwarded the ETH it had taken from the vault. Part of what reached Tornado Cash, about 22 ETH, appears to be a refund on the trades from the block builder Titan, not Chainflip money.

Collector Wallet (paid into Tornado Cash):
0xfd24197ef8503dd5dd18f30c7b86a77910d3b080

In three transactions, the collector put 2,909 ETH into Tornado Cash: 29 deposits of 100 ETH and nine deposits of 1 ETH.

Tornado Cash Deposits, Batch 1 (1,102 ETH), 07:18:23 UTC:
0xc0cda816eb8cc1d02222ff2a3710e6c8653516504085480bb0574e2fd4c55ba4

Tornado Cash Deposits, Batch 2 (1,003 ETH), 07:18:47 UTC:
0xf099723577705720873851c727704061c26c7790c12883212d05c4eb13c3860e

Tornado Cash Deposits, Batch 3 (804 ETH), 07:19:11 UTC:
0x5813fe3cd5c5f7cc5e112ebf7f8ee4953c0eeb4fd63b9e604c78bbe062428838

Bots then sent the receiver fake ETH tokens from look-alike addresses, an address-poisoning play aimed at the thieves. Nobody, it seems, was off limits.

At 20:12 UTC that night, Chainflip made its offer. An on-chain message to the address holding the stolen BTC read in part "Chainflip: return 90%, keep 10%."

Chainflip's return page set the terms: Keep 10% as a bounty and return 90%, which came to 110.57523337 BTC and 2,618.1 ETH, both due by 18:38 UTC on November 23. In exchange, Chainflip promised to treat it as a white hat recovery, "ask no further questions" and withdraw its reports and complaints to law enforcement.

Bitcoin OP_RETURN Message to the Attacker:
0f75dbd50f247d4d29ffb5d19dae9907f0322f9ef504720b7e27d2453624f004

Chainflip Return Address (Ethereum):
0x38a4BCC04f5136e6408589A440F495D7AD0F34DB

Chainflip Return Address (Bitcoin):
bc1qux4nruxvwfxyv2n5d4fw0a363d4lxn5f45rats

The deadline passed. Part 2 of their incident report says that if the funds aren't returned, Chainflip will keep pursuing the exploiter.

Chainflip also says it holds identifying information on the validator and the servers used, and that the attacker exposed IP addresses in the weeks before the exploit.

The attacker hasn't blinked. As of Chainflip's November 27 update, the bitcoin hadn't moved and the ether disappeared into Tornado Cash.

If the money isn't coming back, who refills the vaults, and what does Chainflip have to give up to reopen them?

The Guest List

Chainflip's answer to an open door is a guest list.

Every validator that was online during the attack is being rotated out, and its operator is rebuilding on fresh machines with all new credentials.

Chainflip has also sent validators a proposal to whitelist operators to "the known, existing set." It calls the result still decentralized, with "a permissioned layer" on top.

On November 20, the attacker's validator account was funded with 20,500 FLIP. Under the proposal, an unknown operator couldn't join the critical parts of the network at all.

Part 2 frames the hardening as a response to a cybersecurity environment "evolving more quickly than any of us imagined."

Chainflip's investigation points to a flaw in libzmq, the open-source messaging library behind validators' peer-to-peer communication.

Part 2 says it's corrected in version 4.3.3 and later, and 4.3.3 was released in September 2020.

Part 2 doesn't say which version the validators were running before.

The protocol stays paused until the security review and remediation are done. Chainflip hasn't decided which further measures must land before relaunch and which can wait for a reprioritized roadmap.

The money side is further along: Chainflip says its accounting is complete, outstanding loans will be settled at prices from the time of the attack, and a protocol-managed user recovery fund is being drafted.

Chainflip says its accounting is complete, covering swappers who were using the protocol at the time of the incident, regular account holders and LPs.

It says it will share recovery proposals for each affected group: Swappers, active LPs, non-active LPs in boost and stablecoin strategies, and Chainflip Labs itself.

Chainflip says all of the major active liquidity providers are willing to return, on two conditions: Security review and remediation carried out to a high standard, and an enacted recapitalization plan.

It's the second vault loss in ten weeks. In September, a Tron memo bug let the same deposit be paid out twice, costing 736,442.17 USDT in six unauthorized payouts, and Chainflip said it would make users whole.

That September bug was in Chainflip's own code.

The November exploit, Chainflip says, used a use-after-free flaw in libzmq, a third-party networking library used by the validator software.

Until the network reopens, the Crosschain Association, which runs swap.chainflip.io, is [working with Chainflip to integrate SwapKit into the app as "a temporary replacement service."

Chainflip says swappers will get best available route, quoted across providers, including NEAR Intents, THORChain, Maya Protocol and more.

Swaps may come back before the protocol does. For the protocol itself, Chainflip says hardening is "the number one priority ahead of any restart."

A guest list can keep strangers from connecting.

What keeps the next library flaw off the machines already inside?

One registered stranger, one messaging library, and enough stolen key shares to clear the documented 100-of-150 threshold, without the network.

By Chainflip's account, the investigation has identified no flaw in the vault contracts, the signing scheme or the State Chain's logic as a cause of the attack.

What was exploited, was a flaw in a library Chainflip didn't write, reached through a registration step that let any validator account start the conversation.

An automated warning from a monitor not yet wired to escalation landed in an internal channel, and the stolen key still opened the Bitcoin vault about three hours after the keys were rotated.

About $12.6 million at November 21 prices left the vaults, and as of December 2nd, the bitcoin hasn't moved.

The release Chainflip says corrected the flaw shipped in September 2020, and the further remedy it proposes is a door only known faces can open.

Chainflip's docs call its validator slots "entirely permissionless," open to any operator who can outbid the rest in FLIP auctions.

The same page says up to 150 validators "jointly control all funds in the system."

If one library flaw reached enough of its validators, and the further remedy is a guest list, how decentralized was Chainflip to begin with?


partager cet article

REKT sert de plateforme publique pour des auteurs anonymes, nous déclinons toute responsabilité quant aux opinions ou contenus hébergés sur REKT.

faites un don (ETH / ERC20): 0x3C5c2F4bCeC51a36494682f91Dbc6cA7c63B514C

avertissement:

REKT n'est responsable en aucune manière du contenu publié sur notre site Web ou en lien avec nos Services, qu'il soit publié ou occasionné par l'Auteur Anon de notre site Web, ou par REKT. Bien que nous fournissions des règles pour la conduite et les publications de l'Auteur Anon, nous ne contrôlons pas et ne sommes pas responsables de ce que l'Auteur Anon publie, transmet ou partage sur notre site Web ou nos Services, et ne sommes pas responsables de tout contenu offensant, inapproprié, obscène, illégal ou autrement répréhensible que vous pourriez rencontrer sur notre site Web ou nos Services. REKT ne saurait être tenu responsable de la conduite, en ligne ou hors ligne, de tout utilisateur de notre site Web ou de nos services.