2023 | Hard | EVM
assertEqual
Objective of CTF¶
You need to write a smart contract that accepts two unsigned integers as inputs. The contract should return 1 if the input numbers are equal; otherwise, it should return a different number.
QuillCTF Challenges - assertEqual
Vulnerability Description¶
- Most arithmetic opcodes are banned
- We can not simply push
0x04
onto the stack in order to load the first parameter - We can not use opcode EQ to compare the two numbers
- We can not simply push
- As an alternative, ISZERO can be used to compare
- 4 wei is send for each call
- Since v0.8.7 does not support PUSH0, we can use RETURNDATASIZE as an alternative
Attack Steps¶
- We can leverage CALLVALUE to get the first parameter
- Using the first parameter as the key, store any value that is greater than 0 in that storage slot
- Using the second parameter as the key, load the value of that storage slot. If the value is not 0, the two numbers are equal
Proof of Concept¶
最后更新:
2023年6月9日 11:05:44
Contributors: