On October 13, 2022, according to Beosin’s EagleEye Web3 security monitoring platform, FTX exchange was under a gas stealing attack where it was manipulated to pay all the gas fees to mint a large amount of XEN tokens for the hacker.
In response to this attack, Coinlive invited Beosin, a Singapore-based Web3 security firm, to analyze the specific process of the exploit.
1. Event-related information
A few transactions of the attacks: 0xc96b84cd834655290aa4bae7de80a3c117cc19d414f5bcf2fb85b8c5544300890x8eb73bd5c08318a4cfd233940c3a58744830cda999e59ecbc56f094618a91d690x6bada8e084f8d3b62311f0b6eda10f2690e7542dab75a0de436a640036bccf94
One of the attacker's addresses: 0x1d371CF00038421d6e57CFc31EEff7A09d4B8760
One of the attacked contracts: 0xCba9b1Fd69626932c704DAc4CB58c29244A47FD3
The attacked FTX hot wallet address: 0xC098B2a3Aa256D2140208C3de6543aAEf5A94444
2. Attack flow
We will focus on one specific attack transaction as an example: (0x8eb73bd5c08318a4cfd233940c3a58744830cda999e59ecbc56f094618a91d69)
In the first step, the attacker deployed a malicious contract address on the chain (0xCba9b1Fd69626932c704DAc4CB58c29244A47FD3)
In the second step, the hacker used his FTX hot wallet address to transfer a small amount of funds to the malicious contract address (0xCba9...7FD3) and subsequently used this contract to create sub-contracts in batches.
Since many contracts are created in the entire attack, and each time the sub-contract is executed, the sub-contract will self-destruct, so the following figure is shown as an example.
In the third step, the sub-contract’s fallback() function would initiate a mint request to the $XEN contract. The claimRank() function passes in a term (>= 1 day) for minting, requiring only to pay gas fee of calling without any other costs associated.
The claimMintRewardAndShare() function is for claiming, which only determines whether the term is reached or not (in this case set to 1 day by the hacker), then it can be withdrawn unconditionally to any address. However, in this call process, the transaction initiator is the FTX hot wallet address, so the gas of the whole call process is paid by the FTX hot wallet address, and the $XEN mint address is the attacker's address.
The above three steps are repeated continuously in a cycle. Each time withdrawing the expired tokens and initiating a new minting request simultaneously.
3. Vulnerability Analysis
This attack mainly takes advantage of the fact that FTX does not impose any restrictions on the recipient contract address, nor does it impose restrictions on the gas limit of ETH, this allows the hacker to exploit and mint $XEN tokens for profit.
At the time of publication, FTX exchange lost a total of 81 ETH and the hacker exchanged $XEN token for ETH transfer through decentralized exchanges like DODO and Uniswap.
Beosin’s Fund Movement and Tracing Chart