-
Notifications
You must be signed in to change notification settings - Fork 62
/
unprotected_initialize_test.sol
54 lines (44 loc) · 1.18 KB
/
unprotected_initialize_test.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
interface I {
function initialize() external;
}
contract unprotected_initialize {
uint256 toSet;
bool isProtected = true;
address owner = 0xFeebabE6b0418eC13b30aAdF129F5DcDd4f70CeA;
modifier onlyOwner() {
require(isProtected);
_;
}
function initialize_ok1(uint256 setter) external onlyOwner {
uint256 a = 10;
toSet = setter + a;
}
function initialize_ok2(uint256 setter) external {
require(msg.sender == owner);
uint256 a = 10;
toSet = setter + a;
}
function initialize_vuln(uint256 setter) external {
toSet = setter;
}
function init_ok1(uint256 setter) external onlyOwner {
uint256 a = 10;
toSet = setter + a;
}
function init_ok2(uint256 setter) external {
require(msg.sender == owner);
uint256 a = 10;
toSet = setter + a;
}
function init_vuln(uint256 setter) external {
toSet = setter;
}
function init_ok3(uint256 setter) external {
if (msg.sender != owner) {
revert("Not owner");
}
toSet = setter;
}
}