Rob Behnke
November 18th, 2024
In November 2024, Thala — a large DeFi platform on the Aptos blockchain — suffered a hack. The attacker exploited a vulnerability in the project’s smart contracts to steal an estimated $25.5 million from it.
The Thala hack was enabled by a vulnerability introduced in a recent update to one of its v1 farming contracts. The root cause of the incident appears to have been a failure to properly validate that a user’s requested withdrawal of staked tokens was less than the total number of tokens that they had staked.
The attacker began by adding liquidity to a vulnerable pool, receiving THALA-LP tokens in return. They then staked and unstaked these tokens, establishing themselves as someone who had held a stake in the protocol but had a zero balance at the end of these actions.
The attacker then attempted to unstake a significant number of THALA-LP tokens despite the fact that they had no staked balance remaining. This attempt was successful, and the attacker was able to swap these tokens to lzUSDC and drain an estimated $25.5 million from the project in total.
Since this project was implemented with Move, Thala Labs was able to quickly act to freeze approximately half of the stolen assets. A later deal with the attacker resulted in a return of all of the stolen assets in return for a $300K bounty.
The Thala hack was made possible by a vulnerability in a recent update to the project’s smart contract code. A missing sanity check for withdrawing staked assets — validating that the user in question actually had a stake of the requested size — could have cost the project $25.5 million and ended up with a price tag of $300,000 in bounty payments.
One key takeaway from this incident is the impact that various blockchain programming languages have on attack analysis and exploitability. One postmortem of the attack called out the fact that Move is very easy to decompile. While this aids in post-incident analysis, it also makes it easier for attackers to identify and exploit vulnerabilities in a protocol.
This incident also demonstrates that comprehensive security audits really are critical when releasing new code on-chain. This type of error is not uncommon in smart contracts of this type and is something that auditors will specifically check for. Performing an audit before release could have prevented this hack entirely. For help in protecting your protocol against these types of attacks, get in touch with Halborn.