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

The anti-reentrancy code section(nonReentrant modifier) is incorrectly implemented.

Summary

The anti-reentrancy code section(nonReentrant function) is incorrectly implemented.

Vulnerability Details

The anti-reentrancy code section is incorrectly implemented.

modifier nonReentrant() {
assembly {
if tload(1) { revert(0, 0) } // check 1 slot and revert when 1 slot is set.
tstore(0, 1) // set 0 slot as value "1"
}
_;
assembly {
tstore(0, 0) // reset 0 slot as value "0"
}
}

The first argument in tload is a slot address, but since tload(0,1) is used below, the set slot number and the slot number being checked are different.

Impact

Since the anti-reentrancy code is incorrect, an attacker (one of the beneficiaries) can claim funds and perform a reentrancy attack to steal all the funds in the contract, causing financial losses to other beneficiaries, and making it vulnerable to reentrancy attacks.

Tools Used

Manual Review

Recommendations

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 9 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Wrong value in nonReentrant modifier

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!