2024 | Ethernaut CTF | easy-solidity
Wombo Combo
Description¶
You should stake your tokens to get more tokens!
Solution¶
- To solve the challenge, we need to obtain enough rewards from the Staking contract and transfer reward tokens to
address(0x123)
- The Staking contract inherits from Multicall and ERC2771Context
-
The ERC2771Context overrides the
msgSender()
so that the actual caller will be the last 20 bytes of the call data if calls originating from a trusted forwarder -
The
multicall()
function can batch multiple calls in a single external call with user-provided data, which can be combined with the forwarder to impersonate any user calling the Staking contract -
The user's reward is related to
rewardRate
and is only updated innotifyRewardAmount()
which can only be called by the owner - We can first stake some tokens, impersonate the owner to increase the
rewardRate
, and then obtain enough rewards to solve the challenge :>
Exploitation¶
Run the script twice to give some time to accumulate rewards:
- Stake and impersonate the owner to notify the reward amount
- Get reward tokens and transfer them to
address(0x123)
Flag¶
OZCTF{M3t4_Tr4NS4ct10nS_aR4_n0T_S0_m3Ta}
References¶
最后更新:
2024年3月22日 21:42:34
Contributors: