sherlock-audit / 2023-04-ajna-judging

4 stars 3 forks source link

XDZIBEC - XO-`getBucketStateStakeInfo` function get Incorrect `bucketId_` check #81

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

XDZIBEC

medium

XO-getBucketStateStakeInfo function get Incorrect bucketId_ check

Summary

}

-The vulnerability is in the `getBucketStateStakeInfo` function it's returns the `LP` amount and the exchange rate for a given bucket and a given stake, at stake time, the function does not check if the bucket exists.  means that if an attacker calls the function with a bucket ID that does not exist, the function will return incorrect information.
## Impact
- the vulnerability can cause a material loss of funds.
## Code Snippet
- https://github.com/sherlock-audit/2023-04-ajna/blob/main/ajna-core/src/interfaces/rewards/IRewardsManagerState.sol#L70C4-L75C2
## Tool used

Manual Review

## Recommendation
This can be fixing this problem :
```solidity
if (bucketId_ >= stakeInfo.snapshot.length) {
    // Bucket does not exist
    return (0, 0);
}