DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: low
Invalid

Index Out-of-Bounds Risk in removePlot Function of PodTransfer.sol in Beanstalk

Summary

The PodTransfer.sol contract in the Beanstalk project has a potential vulnerability in the removePlot function. This function does not check if the index of the plot is within the valid range of the plotIndexes array, leading to the risk of accessing an element outside the array (index out-of-bounds) and causing errors in the contract

Vulnerability Details

The removePlot function in PodTransfer.sol contains the following code:

delete s.accts[account].fields[fieldId].plots[index];
LibDibbler.removePlotIndexFromAccount(account, fieldId, index);

This code removes a plot at index index from the plots array and calls the removePlotIndexFromAccount function to remove this index from the plotIndexes array. However, there is no check to ensure that index is within the valid range of the plotIndexes array. If index is greater than or equal to the length of the array, accessing plotIndexes[index] will cause an "index out-of-bounds" error.

Impact

If the error occurs during the execution of a transaction, the entire transaction will be reverted (undone), wasting gas fees for the user.

Tools Used

Manual

Recommendations

add a check to ensure that index is within the valid range of the plotIndexes array before accessing it

function removePlot(
// ...
) internal {
// ...
// Add index check
require(index < s.accts[account].fields[fieldId].plotIndexes.length, "Field: Invalid Plot index");
delete s.accts[account].fields[fieldId].plots[index];
LibDibbler.removePlotIndexFromAccount(account, fieldId, index);
// ...
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational/Gas

Invalid as per docs https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.