Hi team,
An issue was identified in the findWhitelistStatusIndex
function within the LibWhitelistedTokens
library of the Beanstalk protocol. The function is designed to find the index of a given token's whitelist status within the whitelistStatuses
array. However, the local variable i
, which is used to iterate through the array, is not initialized before its first use. This uninitialized state could lead to unpredictable behavior, as i
could potentially hold any value, leading to out-of-bounds array access or incorrect iteration.
Clone the Beanstalk protocol repository from GitHub: https://github.com/Cyfrin/2024-02-Beanstalk-1
.
Navigate to the LibWhitelistedTokens.sol
file located at protocol/contracts/libraries/Silo/LibWhitelistedTokens.sol
.
Locate the findWhitelistStatusIndex
function.
Observe that the local variable i
is declared but not initialized before it is used in the loop.
The uninitialized local variable i
could lead to unpredictable behavior, including potential out-of-bounds array access or incorrect iteration, which could compromise the integrity and security of the contract. This issue could be exploited by malicious actors to manipulate the contract's state or to cause the contract to revert unexpectedly.
Manual code audit
The local variable i
should be initialized to 0
before it is used in the loop. This ensures that the loop starts from the beginning of the whitelistStatuses
array and prevents any unpredictable behavior due to the variable holding an unexpected value.
This fix ensures that the findWhitelistStatusIndex
function behaves as expected, providing a reliable way to find the index of a token's whitelist status within the whitelistStatuses
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.