Level 6 - Delegation ⏺⏺
Level Setup
The goal of this level is for you to claim ownership of the instance you are given.
Things that might help
Look into Solidity's documentation on the
delegatecall
low level function, how it works, how it can be used to delegate operations to on-chain libraries, and what implications it has on execution scope.Fallback methods
Method ids
Level Contract
Exploit
The contract forwards any unmatched function calls through to the Delegate
contract through the fallback()
function. As pwn()
is only on the Delegate
contract, it's as simple as calling pwn()
and having it execute the function on the Delegate
instead of the Delegation
contract.
Call
pwn()
.
Submit instance... 🥳
Completion Message
Usage of delegatecall
is particularly risky and has been used as an attack vector on multiple historic hacks. With it, your contract is practically saying "here, -other contract- or -other library-, do whatever you want with my state". Delegates have complete access to your contract's state. The delegatecall
function is a powerful feature, but a dangerous one, and must be used with extreme care.
Please refer to the The Parity Wallet Hack Explained article for an accurate explanation of how this idea was used to steal 30M USD.
Notes
delegatecall in Solidity
Last updated