-
Notifications
You must be signed in to change notification settings - Fork 981
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reentrancy-no-eth: do not count staticcalls as reentrant (#1119)
* reentrancy-no-eth: do not count staticcalls as reentrant * change can_reenter of low-level-calls to false for staticcall
- Loading branch information
1 parent
c57e272
commit bab44b7
Showing
10 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/detectors/reentrancy-no-eth/0.5.16/no-reentrancy-staticcall.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
library MyLibrary { | ||
|
||
function aViewCall(address token) internal view { | ||
(bool success ,) = token.staticcall(abi.encodeWithSignature("decimals")); | ||
require(success, "call failed"); | ||
} | ||
} | ||
|
||
contract A { | ||
uint256 private protectMe = 1; | ||
function good() external { | ||
MyLibrary.aViewCall(0x6B175474E89094C44Da98b954EedeAC495271d0F); | ||
protectMe += 1; | ||
} | ||
function good1() external { | ||
(bool success,) = address(MyLibrary).staticcall(abi.encodeWithSignature("aViewCall(address)")); | ||
require(success, "call failed"); | ||
protectMe += 1; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...trancy-no-eth/0.5.16/no-reentrancy-staticcall.sol.0.5.16.ReentrancyReadBeforeWritten.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
[] | ||
] |
26 changes: 26 additions & 0 deletions
26
tests/detectors/reentrancy-no-eth/0.6.11/no-reentrancy-staticcall.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
interface IERC20 { | ||
function decimals() external view returns (uint8); | ||
} | ||
|
||
library MyLibrary { | ||
|
||
function aViewCall(address token) internal view { | ||
(bool success , ) = token.staticcall( | ||
abi.encodeWithSelector(IERC20.decimals.selector) | ||
); | ||
require(success, "call failed"); | ||
} | ||
} | ||
|
||
contract A { | ||
uint256 private protectMe = 1; | ||
function good() external { | ||
MyLibrary.aViewCall(0x6B175474E89094C44Da98b954EedeAC495271d0F); | ||
protectMe += 1; | ||
} | ||
function good1() external { | ||
(bool success,) = address(MyLibrary).staticcall(abi.encodeWithSignature("aViewCall(address)")); | ||
require(success, "call failed"); | ||
protectMe += 1; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...trancy-no-eth/0.6.11/no-reentrancy-staticcall.sol.0.6.11.ReentrancyReadBeforeWritten.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
[] | ||
] |
25 changes: 25 additions & 0 deletions
25
tests/detectors/reentrancy-no-eth/0.7.6/no-reentrancy-staticcall.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface IERC20 { | ||
function decimals() external view returns (uint8); | ||
} | ||
|
||
library MyLibrary { | ||
|
||
function aViewCall(address token) internal view { | ||
(bool success , ) = token.staticcall( | ||
abi.encodeWithSelector(IERC20.decimals.selector) | ||
); | ||
require(success, "call failed"); | ||
} | ||
} | ||
|
||
contract A { | ||
uint256 private protectMe = 1; function good() external { | ||
MyLibrary.aViewCall(0x6B175474E89094C44Da98b954EedeAC495271d0F); | ||
protectMe += 1; | ||
} | ||
function good1() external { | ||
(bool success,) = address(MyLibrary).staticcall(abi.encodeWithSignature("aViewCall(address)")); | ||
require(success, "call failed"); | ||
protectMe += 1; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...entrancy-no-eth/0.7.6/no-reentrancy-staticcall.sol.0.7.6.ReentrancyReadBeforeWritten.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
[] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters