Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

False positive SWC-101 #245

Open
area opened this issue Oct 4, 2019 · 2 comments
Open

False positive SWC-101 #245

area opened this issue Oct 4, 2019 · 2 comments

Comments

@area
Copy link

area commented Oct 4, 2019

With the following contract

pragma solidity 0.5.8;

contract Resolver {
  function f(string memory sig) public pure returns(bytes4) {
    return bytes4(keccak256(abi.encodePacked(sig)));
  }
}

running yarn truffle run verify --mode quick ./contracts/Resolver.sol I get the report:


5:33  error    The binary addition can overflow                                                                                                                      SWC-101
   8:81  error    integer overflow                                                                                                                                      SWC-101

replacing sig with a uint (rather than string) causes the error to disappear. This is minimum working example from a larger contract, where the line numbers were very wrong in the report (referring to a comment block at the start of the file with licensing information).

EDIT: Example report UUID: 9ca79e99-d5d6-4ffc-8268-3c01a0307857

@nbanmp
Copy link
Contributor

nbanmp commented Oct 4, 2019

Thanks for reporting the issue and for finding a minimal working example. That's very helpful.

We are looking into the false positive.

@nbanmp
Copy link
Contributor

nbanmp commented Oct 4, 2019

Here is an even simpler example:

pragma solidity 0.5.11;

contract Resolver {
    function f(string memory sig) public payable {
        abi.encodePacked(sig);
    }
}

It looks like there is a real integer overflow occurring here, but it is generated by the compiler.

We will decide whether or not we want to hide those overflows in the response, as they are unfixable by the user.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants