What the Heck am i Doing Wrong? Openzeppelin Ethernaut Re-entrancy
#10
#204
Replies: 8 comments 31 replies
-
This seems interesting to look into. I will advise you to import |
Beta Was this translation helpful? Give feedback.
-
The error is in the Reentrance Contract you modified. ScenarioThe attacker has 1 ether in their balance (balances[attacker] is 1 ether). Step-by-Step ExecutionFirst Call to withdraw (Initial Balance: 1 ether):
Second Call to withdraw (Still Initial Balance: 1 ether):
Third Call to withdraw (Still Initial Balance: 1 ether):
Completing the Calls:
Underflow and Its ConsequencesUnderflow: When the balance goes negative, it wraps around to a very large value in unsigned integer arithmetic. I did this balances[msg.sender] -= 0; But that is tampering with the integrity of the contract. |
Beta Was this translation helpful? Give feedback.
-
We Might Need the Master Here. Where r u Patrick. |
Beta Was this translation helpful? Give feedback.
-
Your first assertion |
Beta Was this translation helpful? Give feedback.
-
then |
Beta Was this translation helpful? Give feedback.
-
It won't fail, try it. The overflow/underflow popping in your test its because your assertions are wrong and not from the contract itself. This is also implying that there is a mistake from either your |
Beta Was this translation helpful? Give feedback.
-
I must confess this is an interesting discussion so far. I am still trying to research and confirm if it is true that a contract state updates the number of times we re-enter into it. |
Beta Was this translation helpful? Give feedback.
-
Interesting, just came across with your issue @justAWanderKid, I changed the challenge to 0.8.26 version and I was really puzzled why couldn't I drain the funds! I initially thought that that In summary, here's what's happening (and correct if I'm wrong):
|
Beta Was this translation helpful? Give feedback.
-
it's Just an Simple Reentrancy Vulnerablity Exploitation, but it seems like there's something im doing wrong.
Link to the Openzeppelin Ethernaut
10-Re-entrancy
: https://ethernaut.openzeppelin.com/level/10Now First of all, i made couple of Changes to the original
Reentrance
Contract that importsSafeMath
and uses 0.6.0 solidity version.here's the changes i made to
Reentrance
Contract:and this is the attacker contract:
and this is the test i wrote for it:
what the heck am i doing wrong that the transaction gets reverted for overflow/underflow?
Beta Was this translation helpful? Give feedback.
All reactions