In this challenge, you need to unlock a flag protected by four (!!) distinct locks involving storage privacy, contract balances, and controlled receipt of Ether.
The mintFlag function is protected by four modifiers:
lock1: Requires a password that matches a masked private storage variable.lock2: Requires msg.sender to have a balance of at least 2 wei.lock3: Requires a send(1) to msg.sender to fail.lock4: Requires a send(2) to msg.sender to succeed.
lock3 and lock4 depend on how your contract responds to receiving Ether. Remember that send only provides a fixed amount of gas (2,300 gas) to the recipient.
send call fail? A contract can refuse to accept Ether by reverting in its receive() function.
This challenge covers several critical security concepts:
eth_getStorageAt make it easy to inspect any contract’s internal state.lock3 demonstrates how a contract can intentionally (or unintentionally) break another contract’s logic by refusing to receive Ether. If a protocol requires sending Ether to a user to proceed, a user with a malicious contract can freeze the protocol. This is a common Denial of Service (DoS) vector.send and transfer only provide 2,300 gas. While they were originally intended to prevent reentrancy, they can cause transfers to fail if the recipient’s receive function is too complex. Modern security best practices recommend using call instead (in fact, Solidity gives you a warning!), along with explicit reentrancy guards.