Sends eth to arbitrary user (Slither warning)

Viewed 127

How do I resolve Slither warning about the low level call in the following method:

 // A proposer calls function and if address has an allowance, recieves ETH in return.
    function getPayout(address payable addressOfProposer)
        public
        returns (bool)
    {
        // Get the available allowance first amd store in uint256.
        uint256 allowanceAvailable = _payoutTotals[addressOfProposer];
        require(allowanceAvailable > 0, "You do not have any funds available.");

        _decreasePayout(addressOfProposer, allowanceAvailable);

        (bool sent, ) = addressOfProposer.call{value: allowanceAvailable}("");
        require(sent, "Failed to send ether");

     // console.log("transfer success");
        emit Withdraw(addressOfProposer, allowanceAvailable);
        return true;
    }

1 Answers

Use //slither-disable-next-line DETECTOR_NAME:

// A proposer calls function and if address has an allowance, recieves ETH in return.
    function getPayout(address payable addressOfProposer)
        public
        returns (bool)
    {
        // Get the available allowance first amd store in uint256.
        uint256 allowanceAvailable = _payoutTotals[addressOfProposer];
        require(allowanceAvailable > 0, "You do not have any funds available.");

        _decreasePayout(addressOfProposer, allowanceAvailable);

        //slither-disable-next-line unchecked-lowlevel
        (bool sent, ) = addressOfProposer.call{value: allowanceAvailable}("");
        require(sent, "Failed to send ether");

     // console.log("transfer success");
        emit Withdraw(addressOfProposer, allowanceAvailable);
        return true;
    }

It's interesting that it gives an unchecked low-level call warning, however, given that it does appear to be checked.

Related