Levyathan Hack
What happened
On July 30, 2021, an attacker took over the Levyathan yield farm on BNB Smart Chain and minted a vast amount of LEV. Levyathan developers had left the private key of the deployer wallet, which could queue actions on the protocol's timelock, in the project's public GitHub. It sat there for about four months before it was used.
The attacker used that key to queue a MasterChef ownership transfer through the timelock, which enforced a 48-hour delay (DeFiHackLabs indexes the incident under July 28, 2021). Once the delay passed they executed it, took ownership of the MasterChef and the LEV token, minted LEV, sold part of it and bridged the proceeds to Ethereum. The first bridged ETH arrived on Ethereum at 11:50 UTC on July 30. LEV fell from about $0.15 to about $0.00000147.
A second bug made things worse. emergencyWithdraw() paid out rewardDebt instead of user.amount, so early users could withdraw more than they had staked and drained the pools before others got out. The farm's TVL of about $1.5 million was lost. Levyathan had been audited by CertiK.
Attacker: 0x7507f84610f6d656a70eb8cdec044674799265d3
Timelock schedule: 0xfd30def124c1345606598ae4817ae184fc1918fc638111c6e71bc9752361fd87
Timelock execute: 0xe6e504208ba90d121c3212a4f2547ae28e69790ab541d459c080ec8b1f3efab2
Mint: 0x86ddfd9864199ea78c1e6dc2a83c033f5900e00d3826cd39044a0ef7fcd2135e
Sales: 0xe3faf5bfab37bf335b7850dab966a448d8e41bc06f56d5b6185ac6f3af068230, 0x06498e85588bb0e6083ca01ff7f9e9393bd0944697540c523aec5c7f43ddca3f
Remaining tokens burned: 0x2893474012d4438260e757679544af58027b9ba84ce6bfc44c0cc78c6a5710b0
Swaps to ETH: 0xfba3cd6046ac669fdb5d9217f2ca6cb2c735ac4009ab1def2a0b84511f87bf2e, 0x692d4a6a1f074b2c082202d56b4d88a8f8f57f1b7f04d10fad8b0bf39debf3a8
Bridge to Ethereum: 0x7643893ee149277fe6dc08881f329ac03cbd012719dfd40907a2570211949166, 0x6ee8444d2436eff636ce64d42f74dc12766f38bd25c3dbd439d7401ac032877b
Tornado Cash deposits: 0x50a243cf3bc2024f9231dd0976f232f991d5f66f8b16d4d6536f1c744ba0fcca, 0xffbabbe3f484a025f27ecd343171abfa30c63ecac245aa487207d03232d53c3f, 0xcd715f0148706f89decbbc7294a0862825f52bc3dce7ed69853847a667b4f9cb
How it happened
- The private key of the Levyathan deployer, which could propose timelock transactions, was committed to the project's public GitHub repository.
- The key was used to
schedule()a timelock transaction transferring MasterChef ownership (tx0xfd30def1...fd87). - After the 172,800-second (two-day) delay, the transaction was
execute()d (tx0xe6e50420...efab2). The new owner calledrecoverLevOwnership()to take theLEVtoken back from the MasterChef. - As token owner, the attacker minted a large amount of
LEV, sold part of it, swapped the proceeds to ETH and bridged them to Ethereum on July 30. - Normal
withdraw()andleaveStaking()calls reverted, while the buggyemergencyWithdraw()paid outrewardDebtand could be called repeatedly, so the remaining stake went to whoever withdrew first.
Protocol details
Security review history
- CertiK No public report
Evidence
Proof of concept
1 availableSources
- report Post-Mortem levyathan-index.medium.com
- report Levyathan - REKT rekt.news
- transaction Etherscan transaction 0x7643893ee149277fe6dc08881f329ac03cbd012719dfd40907a2570211949166 etherscan.io
- transaction bscscan.com transaction 0x0649…ca3f bscscan.com
- transaction bscscan.com transaction 0x2893…10b0 bscscan.com
- transaction bscscan.com transaction 0x692d…f3a8 bscscan.com
- transaction bscscan.com transaction 0x86dd…135e bscscan.com
- transaction bscscan.com transaction 0xe3fa…8230 bscscan.com
- transaction bscscan.com transaction 0xfba3…bf2e bscscan.com
- transaction etherscan.io transaction 0x50a2…fcca etherscan.io
- transaction etherscan.io transaction 0x6ee8…877b etherscan.io
- transaction etherscan.io transaction 0xcd71…f9cb etherscan.io
- transaction etherscan.io transaction 0xffba…3c3f etherscan.io
- address bscscan.com address 0x7507…65d3 bscscan.com
- code DeFiHackLabs past/2021 README github.com
- analysis Web Archive web.archive.org
- analysis DeFiLlama defillama.com
- analysis DeFiHackLabs Levyathan_exp.sol PoC raw.githubusercontent.com
- analysis Documented Timeline of DeFi Exploits (Levyathan entry) chainsec.io
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.