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

Transient Storage in nonReentrant Modifier

Summary

The nonReentrant modifier in the InheritanceManager contract uses transient storage (tload and tstore) to prevent reentrancy. However, the implementation is incorrect, which could lead to reentrancy vulnerabilities.

Vulnerability Details

  • Code:

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

Impact

The modifier uses transient storage (tload and tstore) incorrectly. Specifically:

  • The code checks slot 1 (tload(1)) but writes to and clears slot 0 (tstore(0, 1) and tstore(0, 0)).

  • Since slot 1 is never written to, tload(1) always returns 0, and the reentrancy guard never triggers.

Tools Used

Manual review

Recommendations

modifier nonReentrant() {
assembly {
if tload(0) { revert(0, 0) } // Check slot 0
tstore(0, 1) // Store in slot 0
}
_;
assembly {
tstore(0, 0) // Clear slot 0
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 9 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!