Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive on contracts-that-lock-ether #163

Closed
mrice32 opened this issue Feb 4, 2019 · 1 comment
Closed

False positive on contracts-that-lock-ether #163

mrice32 opened this issue Feb 4, 2019 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@mrice32
Copy link
Contributor

mrice32 commented Feb 4, 2019

The ether locking detector doesn't seem to be able to follow library calls, so if the withdraw is implemented via a delegatecall to a library, the detector fires despite the contract implementing a perfectly valid withdraw function. Here's a sample contract that illustrates the problem:

/*
  Test
*/
pragma solidity ^0.5.0;

library Lib {
    struct State {
        uint balance;
    }

    function _deposit(State storage state) external {
        state.balance += msg.value;
    }

    function _withdraw(State storage state, uint value) external {
        require(value <= state.balance);
        state.balance -= value;
        msg.sender.transfer(value);
    }
}

contract Test {
    using Lib for Lib.State;

    Lib.State public state;

    function deposit() external payable {
        state._deposit();
    }

    function withdraw(uint value) external {
        state._withdraw(value);
    }
}

The following error message is generated by slither:

INFO:Detectors:
Contract locking ether found in OracleMock.sol:
        Contract Test has payable functions:
         - deposit (OracleMock.sol#27-29)
        But does not have a function to withdraw the ether
Reference: https://github.com/trailofbits/slither/wiki/Vulnerabilities-Description#contracts-that-lock-ether

cc @ptare

@montyly
Copy link
Member

montyly commented Feb 5, 2019

Hi @mrice32 , that's a good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants