-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create exploits for sb-curated reentrancy vulnerabilities #6
Comments
https://github.com/LearnWeb3DAO/Re-Entrancy |
FYI: console.log for solidity |
I found the contract 0x627fa62ccbb1c1b04ffaecd72a53e37fc0e17839.sol to be not exploitable for reentrancy. It does have a reentrancy vulnerability on line 94, but the function has a onlyOwner tag. Which means external contracts can not withdraw money and therefore it is not exploitable. @mokita-j Could you confirm this analysis? function WithdrawToHolder(address _addr, uint _wei)
public
onlyOwner
payable
{
if(Holders[_addr]>0)
{
// <yes> <report> REENTRANCY
if(_addr.call.value(_wei)())
{
Holders[_addr]-=_wei;
}
}
} This case is particularly interesting because this is the “duplicated” contract (both in reentrancy and unchecked_low_levels) |
@sofiabobadilla My bet is that Ownable's |
Contract etherbank.sol is label with reentrancy, but the methods for adding balance and withdraw do not have the modifier payable and therefore no correct function calls can be made. Thus, the contract is not exploitable. It could be interesting though to see how tools can handle this error while creating a patch. |
By doing the experiment and after our discussion on Tuesday 13th, the contract is not exploitable since the variable owner that can be modified is not the same as the one used by the modifier which does not allow an external actor to perform an attack. |
This can be fix, on the contract side, by using a different pragma version where modifiers was not require to send ether, but for the version that Hardhat can handle, this won't be possible. Then the contract falls under the category of contracts that are exploitable on version that are not compatible with the testing framework. |
A note for future reviews: Basically, the reentrancy is performed through the modifier by having an initial call to airDrop() and then override supportsToken on the malicious contract to keep calling airDrop(). The test are different compare to the other patterns, here we test the balance of the hacker inside the victimbalance. |
reentrancy_cross_function.sol Another not exploitable contract due to the lack of a deposit function where the user can have funds. |
reentrancy_insecure.sol similar to the previous one , does not have a deposito function so the vulnerable function (withdrawBalance) is not exploitable due to the design of the contract. Major reason: is an example contract and therefore authors did not make it functional |
Total reentrancy contracts 31
|
Inspiration: https://coinsbench.com/the-correct-way-to-write-tests-for-your-smart-contracts-using-hardhat-and-ethers-js-reentrancy-5438006e90a0
The text was updated successfully, but these errors were encountered: