opyn Hack
What happened
The example transaction of the attack:
https://etherscan.io/tx/0xd06378b7…9ef000
This exploit was carried out by using exercise() function with more than two vaults containing ETH as the underlying asset. Because the implementation interprets the same batch of ETH as many batches of ETH receptions, the hacker re-uses that batch of ETH to recover the collateral USDC and profit. Opyn allowed anyone to exercise a vault with underlying assets and oTokens. By burning the oTokens and taking in the underlying assets, the Option Contracts payout collateral assets to the caller of exercise().
The Opyn ETH Put contract must take in the underlying assets and burn oTokens inside the _exercise() method before paying out collateral assets. The transferFrom() function is used to transfer assets from the msg.sender to address(this), which is a very typical approach. When the underlying asset is ETH, the treatment is completely different. In Solidity, msg.value refers to the amount of ETH carried by the current transaction that would be collected by the smart contract with a payable interface (in this example, exercise()).
Case & protocol details
Security review history
- OpenZeppelin No public report
Funds Recovery
Recovered
$371K
Net Loss
$0
Evidence & learning
Sources and on-chain records
- report Post-mortem medium.com
- report Report blog.peckshield.com
Practice this exploit pattern safely
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.