[CTF] Verilog CTF (Offchain)
Introduction
0. Borrow k MATIC such that k > balance() / 10
1. depositMATIC() with k MATIC
2. redeem(k * 1e18) -- reentrancy contract --> getBounty()
3. Return k MATICUsing ItyFuzz to Solve
...
+ event AssertionFailed(string message);
function getBounty() public returns (bool) {
uint256 delta = WMATICV2.totalSupply() >= WMATICV2.balance()
? WMATICV2.totalSupply() - WMATICV2.balance()
: WMATICV2.balance() - WMATICV2.totalSupply();
uint256 tolerance = WMATICV2.balance() / 10;
if (delta > tolerance) {
// reward the first finder
isHacked = true;
+ emit AssertionFailed("we hacked it!");
- IERC20(WMATIC).transfer(msg.sender, IERC20(WMATIC).balanceOf(address((this))));
winner = address(msg.sender);
}
return isHacked;
}
Last updated