Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Wrong logic in nonReentrant modifier

Summary

This modifier helps ensure that a function cannot be re-entered while it is still executing.

Vulnerability Details

In the nonReentrant modifier's code is if statement which check value stored in transient storage at location 1.

modifier nonReentrant() {
assembly {
if tload(1) { revert(0, 0) }
tstore(0, 1)
}
_;
assembly {
tstore(0, 0)
}
}

it is wrong assumption because this slot is never filed in the code. In addition only first slot is tstore(0, 1) using.

Impact

The function not working properly, and not protect aginst reetrant atacks. And what more, tstore(0, 1) overwrite value stored at slot 1 in transient storage.

Tools Used

manual review

Recommendations

Please use the reetrant function from openzepllin insted of custom solution.

Updates

Lead Judging Commences

0xtimefliez Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Wrong value in nonReentrant modifier

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!