The addFertilizer()
function in LibFertilizer.sol
harbors a discrepancy deviating from its inline documentation. It consistently invokes push(id)
without appropriate verification, leading to undesired outcomes within the nextFid
mapping.
The flaw manifests when push(id)
is invoked for an existing id
, thereby disrupting the integrity of the nextFid
mapping. For instance, in a scenario where sequential mappings are as follows:
If an existing mapping other than the first or last, such as 10, is called, the mapping undergoes alterations:
Consequently, this breakdown in the chain could potentially induce bugs if utilized elsewhere in the codebase.
The aberrant behavior exhibited by the nextFid
mapping might propagate misinformation if accessed for frontend purposes or induce computational anomalies if utilized off-chain.
Remix IDE was used to test this because of the absence of a foundry testing suite in the protocol.
The following code can be used to cross check.
The following changes can be made
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.