Toutes les vulnérabilités
HIGHWeb3

WEB3-UNCHECKED-CALL-2016

Web3 · Ethereum · Solidity low-level call/send/transfer

Résumé

Unchecked low-level call return value (SWC-104) is a contract that ignores the boolean returned by call, send, or delegatecall, so a failed external call is treated as success and state advances anyway. The canonical incident is King of the Ether Throne, whose post-mortem was published February 20, 2016. The contract paid the dethroned monarch with currentMonarch.etherAddress.send(compensation); send forwards only a 2300-gas stipend, which was insufficient for a contract-based wallet that reached an expensive opcode, so send returned false and refunded the ether to the contract. Because the code never checked that boolean, the contract crowned the new king without ever compensating the previous one, who was left empty-handed. The fix was a single require(success) (or a pull-payment pattern); the same class causes silent token transfers and accounting drift wherever a returned false is discarded.

Comment l’éviter dans votre code

  • Check every low-level return value: (bool ok, ) = addr.call{value: v}(""); require(ok).
  • Prefer pull-over-push withdrawals so a single failed transfer cannot block or falsify state.
  • Wrap ERC-20 transfers in SafeERC20 to handle missing or false return values.
  • Avoid bare send/transfer for value to unknown contracts; use a checked call with explicit gas.
  • Run Slither/Mythril detectors for unchecked-call and revert-on-failure in CI.

Références

Vulnérabilités liées

Tout Web3 →