Fallback function attacks exploit various technical characteristics of
Ethereum's
execution model and common implementation patterns. In
Solidity versions prior to 0.6.0, fallback functions were defined using the function() external payable syntax, serving both as the default function for handling unmatched function calls and receiving
Ether transfers. This dual responsibility created significant vulnerability surfaces where developers frequently implemented complex logic in fallback functions to handle various scenarios.
Post-0.6.0
Solidity implementations separate these concerns with distinct fallback() and receive() functions, with receive() handling plain
Ether transfers and fallback() managing unmatched function calls. While this separation improved clarity, both functions remain potential attack vectors when improperly implemented.
Technical exploitation typically follows several patterns: function selector forgery involves sending transactions with function selectors (the first 4 bytes of the
function signature hash) that don't match any contract function but are designed to trigger specific behaviors when processed by fallback logic. Manipulated call data attacks include specially crafted
transaction data designed to be misinterpreted by fallback functions attempting to process unmatched calls as alternative function invocations.
For
Ether handling vulnerabilities, attacks often exploit the send() and transfer() methods which invoke the recipient's receive() function with 2300
gas stipend. If these functions implement complex logic exceeding this
gas limitation, they may partially execute before failing, creating inconsistent
state conditions. Low-level call.value() operations with unrestricted
gas forwarding create particularly dangerous attack surfaces when used in fallback functions.
Reentrancy-based fallback attacks typically exploit contracts that make external calls to untrusted addresses from within fallback functions before completing
state updates. Since the
fallback function is triggered on
Ether receipt, this creates circular
execution paths where malicious contracts can repeatedly call back into the vulnerable contract, draining funds or manipulating
state before initial operations complete.