-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
我有一个已经修复过的合约,通过人工核验发现不存在重入和上溢问题
为此我使用了两种工具
- Oyente
- CONFUZZIUS
结果不相同,其中
Oyente
并没有检测出任何问题(我认为是正确的)
CONFUZZIUS
检测出了重入和上溢,但是我尝试了模拟这种漏洞攻击,但发现无法实现
控制变量:
1.版本:0.4.26
2.框架:都使用的是最新Docker容器
3.CONFUZZIUS命令:python3 fuzzer/main.py -s tmp/sample.sol -c Reentrance --solc v0.4.26 --evm byzantium -t 10
4.Oyente命令:python oyente.py -s sample.sol
结果:
合约文件:
pragma solidity ^0.4.16;
contract Reentrance {
mapping(address => uint) public balances;
bool private locked;
function Reentrance() {
locked = false;
}
function sub_uint256(uint256 a, uint256 b) pure returns (uint256) {
require(b <= a);
return a - b;
}
function add_uint256(uint256 a, uint256 b) pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function donate(address _to) public payable {
balances[_to] = add_uint256(balances[_to], msg.value);
}
function balanceOf(address _who) public view returns (uint balance) {
return balances[_who];
}
function withdraw(uint _amount) public {
if(balances[msg.sender] >= _amount) {
// <yes> <report> REENTRANCY
require(!locked);
locked = true;
if(msg.sender.call.value(_amount)()) {
_amount;
}
locked = false;
balances[msg.sender] = sub_uint256(balances[msg.sender], _amount);
}
}
function() public payable {}
}
实验流程
直接就将当前合约在Docker里跑
问题:
1.为什么CONFUZZIUS所产生的结果不是预期的?
2.这种预期之外的结果是否表明Orancle编写方面有问题?
Metadata
Metadata
Assignees
Labels
No labels