eth-sri / securify

[DEPRECATED] Security Scanner for Ethereum Smart Contracts
Apache License 2.0
216 stars 50 forks source link

UnrestrictedWrite for certain Authorization Patterns #93

Open ritzdorf opened 5 years ago

ritzdorf commented 5 years ago

Certain authorization patterns, do not use a direct

require(msg.sender == owner);

and instead perform a mapping-based authorization lookup that leads to the branch condition. An example is provided below. This currently leads to violations for UnrestrictedWrite.

contract AuthTest {
    mapping(address => bool) isAuthorized;
    uint internal secret;

    constructor() public {
        isAuthorized[msg.sender] = true;
    }

    function setAuthorization(address a, bool v)
        public
        auth
    {
        isAuthorized[a] = v;
    }

    modifier auth {
        require(isAuthorized[msg.sender]);
        _;
    }

    function sensitiveFunc(uint x) public auth returns (bool) {
        secret = x;
    }
}