code-423n4 / 2024-05-munchables-validation

0 stars 0 forks source link

flaw Due to Uninitialized Loop in getLockedWeightedValue #559

Open c4-bot-9 opened 6 months ago

c4-bot-9 commented 6 months ago

Lines of code

https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L466

Vulnerability details

Root of the bug

The bug arises from the uninitialized loop variable i in the for loop ---->https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L466

  /// @inheritdoc ILockManager
    function getLockedWeightedValue(
        address _player
    ) external view returns (uint256 _lockedWeightedValue) {
        uint256 lockedWeighted = 0;
        uint256 configuredTokensLength = configuredTokenContracts.length;
        for (uint256 i; i < configuredTokensLength; i++) {
            if (
                lockedTokens[_player][configuredTokenContracts[i]].quantity >
                0 &&
                configuredTokens[configuredTokenContracts[i]].active
            )

This function is called to calculate the total weighted value of a player's locked tokens. so If the loop does not execute correctly, the function will return an incorrect value or fail, impacting the accuracy of the locked weighted value.

Impact

The getLockedWeightedValue function fails to run correctly cause the loop variable i is uninitialized. and this can lead to incorrect calculations or a failure to execute the loop, impacting the calculation of the locked weighted value for a player.

Proof of Concept

here

for (uint256 i; i < configuredTokensLength; i++) {

Assessed type

Other