Description:
Every function in the smart contract should follow the CEI (Checks-Effects-Interactions) pattern, in order to avoid potential reentrancy attack from malicious actors. The CEI pattern is one of the best practices to follow when writing a smart contract, which provides that state variables should be updated before any interactions with external contracts.
Impact:
Reentrancy attacks are one of the most common attack vectors in smart contracts. An attacker could create a malicious smart contract which has some custom logic in the receive
or fallback
function, which are triggered when receiving native tokens. It is crucial to avoid smart contracts to reenter functions before their completion.
Tools Used:
Slither, manual review
Recommended Mitigation:
It is recommended to rephrase the code of TokenDivider::divideNft
function, in order to relfect the above mentioned CEI pattern.
Additionally, to increase the security level of the contract, TokenDivider
could inherit from ReentrancyGuard
contract from OpenZeppelin, which already has a battle-tested nonReentrant
modifier approved by the community to be added in TokenDivider::divideNft
.
For reference, see ReentrancyGuard.sol
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.5/contracts/security/ReentrancyGuard.sol
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.