You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 1, 2025. It is now read-only.
this challenge exploits smart contract invariants, and how total balance is not a good invariant.
contract invariants are properties of the program state that are expected to always be true. for instance, the value of owner state variable, the total token supply, etc., should always remain the same.
a state in the blockchain is considered valid when the contract-specific invariants hold true.
in this challenge, we need to find a way to forcely send ether to a contract that does not explicitly contain a payable, a receive(), or a fallback() function.
there are two ways this can be done when the destination contract is already deployed:
by using coinbase transactions or block rewards (like MEV searchers and validators rewards)
by leveraging (the now being deprecated) selfdestruct(address), which allows contracts to receive ether from other contracts.
all the ether stored in the calling contract is transferred to address (and since this happens at the EVM level, there is no way for the receiver to prevent it).
selfdestruct() can be considered a garbage collection to clean up voided contracts (and it consumes negative gas).
contractForce {/* MEOW ? /\_/\ / ____/ o o \ /~____ =ø= / (______)__m_m)*/}
discussion
Force contract has no code and its ABI is empty, so we need to figure out how we can send ether to it.
as mentioned above, we can use selfdestruct(address), a function used to delete a contract from the blockchain by removing its code and storage.
solution
we craft a very simple exploit, located at src/07/ForceExploit.sol: