-
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
Incorrect assertions: reentrancy #40
Comments
Hi @mokita-j In that case the function Collect asks you for an amount to collect, the oracle I follow is that in a normal behavior you should only get the amount you used as input for the function. Considering what you wrote now, I understand that it can be the case that a reentrant called won't fail if the hacker has enough money. But in this case the second call should fail as the hacker had originally 5ether, so for the second call it will also need the state to not be updated, otherwise it will revert from lack of funds. Is it more clear now? |
I have to disagree with you on this point. Here's why: The assertions are supposed to detect exploitation caused by reentrancy, like an attacker withdrawing more ether than they deposited.
This patch prevents exploitation by updating the balance before the external call and adding a revert. Yet, the current assertions wrongly label it as exploitable. This same assertion issue happens for the following exploits:
@sofiabobadilla Does this explanation clarify what I mean? |
Hi Monica
I understand your point, I'll correct the oracle for those cases. Good catch! |
Ack. I created the PR with the fixes. |
Why are these assertions with constants like 7 and 3?
If the attacker has deposited 5 ether. He should be able to collect 5 ether.
@sofiabobadilla Could you give me some insights on this question?
https://github.com/ASSERT-KTH/solidity-hack-labs/blob/b41877052e41ace88aaa21e72531c25de80fe900/smartbugs-curated/0.4.x/test/reentrancy/0x4320e6f8c05b27ab4707cd1f6d5ce6f3e4b3a5a1_test.js#L86
https://github.com/ASSERT-KTH/solidity-hack-labs/blob/b41877052e41ace88aaa21e72531c25de80fe900/smartbugs-curated/0.4.x/test/reentrancy/0x4320e6f8c05b27ab4707cd1f6d5ce6f3e4b3a5a1_test.js#L89
The text was updated successfully, but these errors were encountered: