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

The `nonReentrant` modifier in `InheritanceManager`contract has major flaw making it not work as intended

Summary

The assembly code in the nonReentrantmodifier has a major flaw.

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

The tloadchecks if slot 1 is true or false and then sets slot 0 to true in tstore(0, 1). If there is a reentrancy attack the wrong storage slot is being checked( 1 instead of 0 ) making the modifier useless.

Vulnerability Details

Because of this flaw the nonReentrantmodifier does not protect against reentrancy attacks.

Impact

These functions would not be protected against reentrancy attacks: sendERC20, sendETH, and contractInteractions.

Tools Used

Manual code review

Recommendations

Make these changes to the nonReentrantmodifier:

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

Lead Judging Commences

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