The Fertilizer.sol contract has functions that do not follow the best practice of check-effects-interaction. This can lead to reentrancy vulnerabilities. Specifically, state variables are updated after external calls, which can introduce a security risk.
In the Fertilizer.sol contract, the functions _balances[id][account].lastBpf = bpf; and _balances[ids[i]][account].lastBpf = uint128(stopBpf); update state variables after making external calls. This practice can lead to reentrancy vulnerabilities where an external contract might exploit the contract's state before the state updates are finalized.
Line 58
Line 90
Not following the check-effects-interaction pattern can lead to reentrancy attacks, where an external contract can repeatedly call back into the vulnerable function, manipulating the state in ways not intended by the original contract logic. This can lead to loss of funds, unauthorized state changes, or other critical issues.
Manual code review
To mitigate these risks, ensure that state updates are made before any external calls. Here are the updated snippets following the check-effects-interaction pattern:
Updated _update Function
Updated __update Function
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.