Gatekeeper Two
EOA check
Last updated
EOA check
Last updated
This gatekeeper introduces a few new challenges. Register as an entrant to pass this level.
Things that might help:
Remember what you've learned from getting past the first gatekeeper - the first gate is the same.
The assembly
keyword in the second gate allows a contract to access functionality that is not native to vanilla Solidity. See for more information. The extcodesize
call in this gate will get the size of a contract's code at a given address - you can learn more about how and when this is set in section 7 of the .
The ^
character in the third gate is a bitwise operation (XOR), and is used here to apply another common bitwise operation (see ). The Coin Flip level is also a good place to start when approaching this challenge.
https://consensys.github.io/smart-contract-best-practices/development-recommendations/solidity-specific/extcodesize-checks/
Again, we are given three "gates" as modifiers and we should pass all these modifier to complete this level.
The msg.sender
will be the solution contract and tx.origin
will be our EOA adderss.
The caller contract must have code size 0. This check is often used as EOA check: if extcodesize(caller())
is 0, then the caller is EOA; otherwise, the caller is a contract. Here we are going to show that this check is not sufficient.
Here is the attack:
https://solidity-by-example.org/hacks/contract-size/
The idea is that extcodesize()
returns 0 during the construction phase. If we put all the code in constructor, then this check will be bypassed.
To find out _gateKey
, we need to compute:
This is because of the property of XOR: x ^ y = z
then y = x ^ z
. Note that msg.sender
should be the address of our solution contract. So in the exp, msg.sender
becomes address(this)
:
Note that unchecked{}
is required.
Way to go! Now that you can get past the gatekeeper, you have what it takes to join , a decentralized club on the Ethereum mainnet. Get a passphrase by contacting the creator on or via and use it to register with the contract at (be aware that only the first 128 entrants will be accepted by the contract).