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

The slot mismatch (tload(1), tstore(0, 1)) in modifier nonReentrant, InheritanceManager.sol

Summary

Slot mismatch due to incorrect use of (tload(1), tstore(0, 1)).

Vulnerability Details

The original code has a slot mismatch (tload(1), tstore(0, 1)) which is incorrect, and use different slot.

This means the check doesn't properly detect reentrancy, same slot must be used for checking and storing.

modifier nonReentrant() {
assembly {
if tload(1) { revert(0, 0) } // @ audit incorrect slot (1)
tstore(0, 1)
}
_;
assembly {
tstore(0, 0)
}
}

The check (tload(1)) is always false initially (since slot 1 is never set).

The lock (tstore(0,1)) is stored in the wrong place (slot 0), so it doesn’t actually prevent reentrancy.

Impact

Doesn't prevent reentrancy

Tools Used

Manual review

Recommendations

Fixed code:

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

Lead Judging Commences

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