The nonReentrant modifier uses transient storage (tload and tstore) to prevent reentrancy attacks. However, it contains a critical flaw where different storage slots are used for checking and setting the reentrancy lock, leading to an ineffective protection mechanism.
Mismatch Between tload and tstore Slots
The modifier checks slot 1 (tload(1)) but sets and clears slot 0 (tstore(0, 1), tstore(0, 0)).
As a result, the lock is never properly checked, making the reentrancy guard ineffective.
Potential Slot Collision
Using hardcoded slots (0 or 1) without ensuring their uniqueness may lead to unintended conflicts with other transient storage variables.
Reentrancy Protection Fails
Since the function checks one slot (1) but locks/unlocks another (0), reentrancy is not actually prevented.
A malicious attacker could re-enter all the function relying on this modifier without triggering the guard.
The corrected implementation should use a single storage slot for checking, locking, and unlocking.
Manual Code Review
Static Analysis
Foundry Tests
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.