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("");
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;
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();
}
}