solidity-audit-ai / samples /vulnerable /UncheckedCall.sol
LaelaZ's picture
Deploy Solidity Audit AI to HF Spaces (Docker)
31ea9b2 verified
raw
history blame contribute delete
747 Bytes
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Payouts
/// @notice Ignores low-level call return values.
contract Payouts {
mapping(address => uint256) public credits;
function credit(address who) external payable {
credits[who] += msg.value;
}
// VULNERABLE: the return value of call is discarded; a failed transfer is
// treated as success and the credit is still cleared.
function payout(address payable who) external {
uint256 amount = credits[who];
credits[who] = 0;
who.call{value: amount}("");
}
// VULNERABLE: send() returns a bool that is ignored.
function refund(address payable who, uint256 amount) external {
who.send(amount);
}
}