#38458 [BC-Critical] The coordinator can submit empty BTC transactions to drain BTC tokens in the mu
Submitted on Jan 3rd 2025 at 22:23:07 UTC by @f4lc0n for Attackathon | Stacks
Report ID: #38458
Report Type: Blockchain/DLT
Report severity: Critical
Target: https://github.com/stacks-network/sbtc/tree/immunefi_attackaton_0.9/signer
Impacts:
Direct loss of funds
Description
Brief/Intro
When a signer acts as a coordinator, he will initiate BTC transactions to transfer the deposited BTC to the signer's multi-wallet. The structure of these transactions is as follows.
tx_in | tx_out
signers utxo | signers utxo
deposit 1 |
deposit 2 |
deposit 3 |
... |The transaction fees for these transactions are shared by all deposits. And the signer will check each deposit to ensure that the transaction fee does not exceed the user's expectations.
The bug now is that a malicious signer can initiate a BTC transaction without deposits, then all checks on deposits will be bypassed (including transaction fees). And, this BTC transaction will be paid by the multi-sign wallet.
The attacker can use this to make the multi-sign wallet lose all BTC, which will be rewarded to BTC miners. So the attacker can cooperate with BTC miners to steal all BTC.
Vulnerability Details
The signer/src/bitcoin/validation.rs::to_input_rows code is as follows.
Please see the above code. For signer, all checks are done based on deposits. But it does not check whether deposits is empty. An attacker can submit an attack transaction (as shown below) to drain all BTC in the multi-sign wallet.
Impact Details
All BTC deposited by users are at risk.
And If the attacker cooperates with the BTC miner, the attacker can steal these BTC.
References
None
Proof of Concept
Proof of Concept
Base on: https://github.com/stacks-network/sbtc/releases/tag/0.0.9-rc4
Patch
signer/src/config/mod.rs, add attacker flag configPatch
signer/src/main.rs, load attacker flagPatch
docker/docker-compose.yml, add attacker flagPatch
signer/src/transaction_coordinator.rs, add attack action. It will ignore all deposits and initiate an attack BTC transaction.Run docker
Add this code to
signer/src/bin/poc9.rsPatch
signer/Cargo.toml, addpoc9binWaiting for the sBTC contract to be deployed. Then run the
poc9tool. It will send 40 BTC to the signers BTC address and trigger deposits every 10 seconds.Wait until the trigger the coordinator is sbtc-signer-3. You can check the logs marked with
"@audit;"to confirm that the attack was triggeredIn BTC explorer, you will find that the BTC transaction initiated by sbtc-signer-3 is malicious. It does not carry any deposits and withdrawals, but only consumes BTC.
Last updated
Was this helpful?