Photo by Alexander Grey on Unsplash

Smart contracts vulnerability explained : Unchecked send

Simon Busch

--

The unchecked send vulnerability is a security issue that can arise in smart contracts written in Solidity, the programming language used for Ethereum. The vulnerability occurs when a contract’s functions do not properly check the return value of the built-in transfer() or send() function before proceeding, potentially leading to unexpected behavior and losses of ether.

Consider the following example of a contract that is vulnerable to the unchecked send vulnerability:

contract Vulnerable {
function sendEther(address payable recipient) public payable {
recipient.transfer(msg.value);
}
}

In this example, the sendEther() function accepts an address and sends the entire message value (i.e., the amount of ether sent with the transaction) to that address using the transfer() function. However, the function does not check the return value of the transfer() function to see if the transfer succeeded. If the recipient’s address is the zero address, the transfer will fail and the ether will be lost, but the function will continue executing as if the transfer succeeded, possibly leading to unintended consequences.

To mitigate this vulnerability, the return value of the transfer() function should be checked, and proper action should be taken in case the transfer…

--

--

Simon Busch

Full Stack JS/TS @code4rena building the future of smart contract auditing. Solidity/blockchain security learner 🚀