mirror of https://github.com/crytic/slither
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.0 KiB
54 lines
1.0 KiB
3 years ago
|
interface I{
|
||
|
function external_call() external;
|
||
|
}
|
||
|
|
||
|
contract ReentrancyAndWrite{
|
||
|
|
||
|
/// @custom:security non-reentrant
|
||
|
/// @custom:security write-protection="onlyOwner()"
|
||
|
I external_contract;
|
||
|
|
||
|
modifier onlyOwner(){
|
||
|
// lets assume there is an access control
|
||
|
_;
|
||
|
}
|
||
|
|
||
|
mapping(address => uint) balances;
|
||
|
|
||
|
function withdraw() public{
|
||
|
uint balance = balances[msg.sender];
|
||
|
|
||
|
external_contract.external_call();
|
||
|
|
||
|
balances[msg.sender] = 0;
|
||
|
payable(msg.sender).transfer(balance);
|
||
|
}
|
||
|
|
||
|
function set_protected() public onlyOwner(){
|
||
|
external_contract = I(msg.sender);
|
||
|
}
|
||
|
|
||
|
function set_not_protected() public{
|
||
|
external_contract = I(msg.sender);
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
contract Internal {
|
||
|
/// @custom:security write-protection="onlyOwner()"
|
||
|
address owner;
|
||
|
|
||
|
|
||
|
|
||
|
modifier onlyOwner(){
|
||
|
// lets assume there is an access control
|
||
|
_;
|
||
|
}
|
||
|
|
||
|
function buggy() public {
|
||
|
internal_write();
|
||
|
}
|
||
|
|
||
|
function internal_write() internal {
|
||
|
owner = msg.sender;
|
||
|
}
|
||
|
}
|