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

Wrong reentrancy guard implementation

Summary

Reentrancy guard not working due to custom implementation of the transient storage reentrancy guard

Vulnerability Details

The contract implements a custom reentrancy guard using transient storage:

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



Right implementation:

modifier nonreentrant {
assembly {
if tload(0) { revert(0, 0) }
tstore(0, 1)
}
_;
// Unlocks the guard, making the pattern composable.
// After the function exits, it can be called again, even in the same transaction.
assembly {
tstore(0, 0)
}
}

Impact

Reentrancy guard is not protection external function from reentrant calls that could manipulate transactions

Tools Used

Manual code review

Recommendations

1.implement openzeppelin implementatnion

or

2.Fix the reentrancy guard:

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

Lead Judging Commences

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

Wrong value in nonReentrant modifier

0xtimefliez Lead Judge 4 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.