To remove certain Plot index from account it loops through array plotIndexes
:
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/libraries/LibDibbler.sol#L385-L419
PlotIndex is removed in several sceanrios:
When User transfers his Plot, i.e. in PodTransfer.removePlot()
When User harvests that PlotIndex, i.e. in FieldFacet._harvestPlot()
Attacker can just spam victim by transferring 1 wei Plots. It will populate array plotIndexes
too much. As a result that removal will revert with out-of-gas error.
User can't transfer Plots because it tries to find and remove certain index. It will revert with out-of-gas error because Griefer transferred too many 1 wei plots previously.
Worth noting that Protocol will operate on L2 with cheap gas, so it's much easier now to perform attack from griefer's side.
At will of attacker he can poison anyone's account and block interaction with existing Plots.
Manual Review
Do not track array plotIndexes
on-chain. Track events to get array of Plot indexes off-chain
Or you can refactor to use Enumerable set instead of array.
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.