Breaking Down the Thala DeFi Hack & Move's Decompilation Risks

Updated at: December 13, 20245 Mins Read

Author:QuillAudits Team

What Just Happened?

Thala, a prominent DeFi project on the Aptos blockchain, faced a major exploit in its v1 farming contracts. The attacker exploited a vulnerability in the contract logic to withdraw liquidity pool (LP) tokens fraudulently, leading to a total loss of $25.5M.

Through quick intervention, Thala paused related contracts, froze token assets, and negotiated a $300K bounty for the return of user funds.

Too Long; Didn't Read (TL;DR)

  • Exploiter withdrew $25.5M in liquidity due to a vulnerability in the updated v1 farming contract.
  • Exploiter used a manipulated withdraw amount (arg2) to bypass stake checks.
  • Thala froze $9M MOD and $2.5M THL tokens and negotiated for the return of funds.
  • Root cause: Insufficient checks in the contract logic for validating withdraw amounts.
  • Move contracts, despite added safety guarantees, remain susceptible to decompilation risks if best practices aren't followed.

What Does Thala DeFi Do?

Thala is a decentralized finance protocol built on the Aptos blockchain. It offers liquidity provision and staking opportunities through its LP tokens, allowing users to earn rewards. The protocol focuses on farming pools for MOD and THL tokens, catering to the growing Aptos DeFi ecosystem.

Thala Defi

How Did the Attack Go Down?

Step 1: Funding the Exploit

The attacker funded their account with 10 APT tokens and added liquidity to the MOD/lzUSDC pool, receiving 23 Thala-LP tokens in return.

Later the exploiter removed 13,000 THALA-LP and swapped back to lzUSDC

image (44).png

image (45).png

Step 2: The Exploit

Using a manipulated arg2 (withdraw amount) value of 1E12, the exploiter bypassed checks for the staked amount and effectively received LP tokens they were not entitled to.image (46).png

Step 3: Draining Pools

The attacker drained the THL/MOD farm and swapped the stolen tokens back into lzUSDC, ultimately converting into 400K APT.

Step 4: Mitigation Efforts

Thala froze related assets, paused the affected contracts, and identified the attacker. The exploiter accepted a $300K bounty and returned 400K APT to the treasury.image (47).png

 

What Was the Root Cause?

The vulnerability stemmed from inadequate parameter validation in the unstake function of the updated v1 farming contract.

Specifically, the contract failed to ensure that the withdraw amount (arg2) provided by the user was less than or equal to their actual staked balance.

This oversight allowed the attacker to manipulate the arg2 parameter, essentially tricking the contract into returning a massive amount of LP tokens (1E12) they never staked. The unchecked withdraw logic cascaded into the draining of liquidity pools and farms, amplifying the damage.

What’s the Risk with Move Contracts?

Move, the programming language for Aptos, emphasizes resource safety and type safety, but it’s not immune to vulnerabilities.

One significant issue with Move contracts is decompilation risks, which make it easier for attackers to analyze and reverse-engineer bytecode compared to Solidity.

How Could Thala Have Prevented This Exploit?

  1. Stronger Parameter Validation

    Ensuring the withdraw amount (arg2) is always checked against the user’s actual staked tokens would have stopped this attack in its tracks.

  2. Audits from Experts

    A comprehensive audit from a trusted partner like QuillAudits could have caught this vulnerability before it became a $25.5M disaster.

  3. Bug Bounty Programs

    Establishing ongoing bounty programs encourages ethical hackers to report vulnerabilities rather than exploit them.

  4. Secure Contract Design

    For Move, consider obfuscation techniques, stricter function constraints, and ensuring all storage operations are rigorously checked.

  5. Automated Monitoring

    Integrate real-time tools to detect unusual patterns, like oversized withdraw amounts, and trigger emergency halts.

What’s the Lesson Here?

  1. Move Contracts Aren’t Invincible

    While Move introduces advanced safety features, these don’t eliminate vulnerabilities introduced by developer error.

  2. Decompilation Risks Are Real

    Unlike Solidity, Move contracts are easier to decompile, exposing project logic to attackers. Teams must account for this with more robust design and security practices.

  3. Don’t Skip Audits

    Assuming safety because of a platform’s inherent features is dangerous. Audits are essential, especially for high-stakes protocols.

Why QuillAudits?

Choosing a reputable audit firm like QuillAudits ensures that your protocol undergoes rigorous scrutiny from experienced security professionals. QuillAudits specializes in uncovering critical vulnerabilities and providing actionable remediation strategies. Our expertise helps safeguard your project from attacks, ensuring that security issues are addressed proactively.

image (42) (1).png

QuillAudits Team

QuillAudits Team

The QuillAudits team, comprises of expert security researchers & auditors in Web3 security, has completed 1,000+ audits across Ethereum, Polygon, Solana, Arbitrum, BSC, and more, securing $30B+ with 0 exploits, advancing the blockchain ecosystem.

TwitterLinkedInTelegram

Get an audit done today for your
Smart Contract

Join 1000+ leaders who secured themselves from losing Billion Dollars.

Request An Audit

Subscribe to our Newsletter

Get Pure Alpha Straight to Your Inbox. Miss this, and you’re missing out. Insider Secrets - Delivered Right to You. Subscribe now.

Telegram