opyn Hack
Incident Overview
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()).
Incident Report
Protocol Information
What the Attacker Needed to Succeed
Understanding the prerequisites for this type of attack helps auditors identify protocols that are most at risk and helps developers build better defenses.
What Auditors Should Check
If you're auditing a protocol with similar architecture to opyn, these are the critical security checks that could have prevented this incident (August 2020).
- Verify all logic paths related to Other are guarded by proper access controls and input validation
- Review privileged functions (owner, admin, governance) for potential abuse vectors - centralization risks should be documented and bounded with timelocks or multi-sigs
Master these auditing techniques with hands-on labs and real exploit scenarios in the Smart Contract Hacking course.
Free TrialFunds Recovery
Recovered
$371K
Net Loss
0
Security Audit History
- OpenZeppelin Report
Sources & References
Learn to Prevent the Next opyn
The opyn hack is one of many attacks that skilled auditors are trained to detect before deployment. Master real exploit patterns and defense techniques with hands-on Web3 security training.