在使用Slither测试一些合同时,我遇到了2件奇怪的事情。
EtherStore.sol中,它最初具有重入漏洞,我想出了一个想法,我将添加ReentrancyGuard并再次用Slither测试它,以查看漏洞是否消失,但它没有.知道为什么吗?Slither没有实现可重入保护,或者他只是在指出这个函数中存在重入性,我们应该用ReentrancyGuard来覆盖它吗?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract EtherStore is ReentrancyGuard {
mapping(address => uint256) public balances;
function deposit() external payable {
balances[msg.sender] += msg.value;
}
function withdraw() external nonReentrant {
uint256 balance = balances[msg.sender];
require(balance > 0);
(bool success, ) = msg.sender.call{value: balance}("");
require(success, "Failed to send Ether");
balances[msg.sender] = 0;
}
// Helper function to check the balance of this contract
function getBalance() external view returns (uint256) {
return address(this).balance;
}
}
谢谢您的反馈!
发布于 2023-04-27 10:30:29
实际上,Slither提供的大多数漏洞都是可以忽略的。它只是打印出每一个可能的漏洞,其中很少有实际可以被认为是漏洞。
它还指出了OZ合同中存在的许多漏洞,这些漏洞并不易受攻击。你可以忽略它们,除非那些突出的线条看起来很脆弱。
https://ethereum.stackexchange.com/questions/149535
复制相似问题