sherlock-audit / 2024-06-magicsea-judging

2 stars 0 forks source link

slowfi - `BribeRewarder` contract Creates a Bigger `_rewards` Array Than It Should #679

Closed sherlock-admin3 closed 1 month ago

sherlock-admin3 commented 2 months ago

slowfi

Medium

BribeRewarder contract Creates a Bigger _rewards Array Than It Should

Summary

The BribeRewarder contract creates a bigger _rewards array. This array should have the length of the valid periods. Failing to set the adequate number of period affects in different scenarios to reward distribution.

Vulnerability Detail

The _bribe function of the BribeRewarder contract creates a one extra index for a period that cant be voted.

Impact

This disrupts the normal function of the contract and helps to increase severity on other vulnerabilities. It mainly affects to reward distribution.

Code Snippet

BribeRewarder.sol#L249-L251

    for (uint256 i = 0; i <= bribeEpochs; ++i) {
        _rewards.push();
    }

Tool used

Manual Review

Recommendation

Cha

    for (uint256 i = 0; i < bribeEpochs; ++i) {
        _rewards.push();
    }

Duplicate of #689