You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a method calls back into the same contract by using this, Slither picks that up as a potential reentrancy bug. See this example [1] and the error produced [2].
Calling into the same contract isn't giving control to some external, untrusted contract, so this pattern could be considered safe. On the other hand, I do understand what the detector is flagging, so please feel free to close this issue if the behavior is intended. (Is there a way to suppress or workaround the warning?)
Thanks!
/*
A self-contained example of false positive on calling back into the contract.
*/
pragma solidity ^0.5.0;
contract SelfCaller {
uint public stateVariable;
uint public stateVariable2;
function a() external {
this.b();
stateVariable = 0;
}
function b() external {
stateVariable2 = 5;
}
}
Reentrancy in SelfCaller.a (MinimalThisExample.sol#10-13):
External calls:
- this.b() (MinimalThisExample.sol#11)
External calls sending eth:
State variables written after the call(s):
- stateVariable (MinimalThisExample.sol#12)
The text was updated successfully, but these errors were encountered:
That's another interesting corner case, thank for reporting it!
So I think that the right way to prevent this FP, is for slither to consider external calls to this as internal function calls. The reason is that this.b() could potentially do a call to an external contract and so be a true positive (but slither can determine if it does)
When a method calls back into the same contract by using
this
, Slither picks that up as a potential reentrancy bug. See this example [1] and the error produced [2].Calling into the same contract isn't giving control to some external, untrusted contract, so this pattern could be considered safe. On the other hand, I do understand what the detector is flagging, so please feel free to close this issue if the behavior is intended. (Is there a way to suppress or workaround the warning?)
Thanks!
The text was updated successfully, but these errors were encountered: