Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: low
Invalid

unexpected revert due to an out-of-bounds array access

Summary

The function performUpkeep in LSTRewardsSplitterController.sol . If splittersToCall.length is larger than accounts.length, it could indeed lead to an unexpected revert due to an out-of-bounds array access.

Vulnerability Details

function performUpkeep(bytes calldata _performData) external {
bool[] memory splittersToCall = abi.decode(_performData, (bool[]));
bool splitterCalled;
for (uint256 i = 0; i < splittersToCall.length; ++i) {
if (splittersToCall[i] == true) {
splitters[accounts[i]].performUpkeep(""); // here
splitterCalled = true;
}
}
if (splitterCalled == false) {
revert InvalidPerformData();
}
}

When the length of splittersToCall provided by the user exceeds the length of accounts, it will attempt to access non-existent data in accounts, leading to potential issues.

Recommendations

We introduce a new variable iterationLength which is set to the smaller of splittersToCall.length and accounts.length.

function performUpkeep(bytes calldata _performData) external {
bool[] memory splittersToCall = abi.decode(_performData, (bool[]));
bool splitterCalled;
// Ensure we don't iterate beyond the smaller of the two arrays
uint256 iterationLength = splittersToCall.length < accounts.length ? splittersToCall.length : accounts.length;
for (uint256 i = 0; i < iterationLength; ++i) {
if (splittersToCall[i] == true) {
splitters[accounts[i]].performUpkeep("");
splitterCalled = true;
}
}
if (splitterCalled == false) {
revert InvalidPerformData();
}
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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