sherlock-audit / 2024-06-boost-aa-wallet-judging

3 stars 1 forks source link

Odd Cedar Mantis - Missing Bounds Checking in getBoost() Function #488

Closed sherlock-admin2 closed 1 month ago

sherlock-admin2 commented 1 month ago

Odd Cedar Mantis

Low/Info

Missing Bounds Checking in getBoost() Function

Summary

In the getBoost() function located in boostCore.sol:185 Here The vulnerability arises from the lack of bounds checking on the index parameter when accessing the _boosts array. If the provided index is out of bounds, the function will revert, but this could lead to confusion or unexpected behavior for users interacting with the contract.

Root Cause

In boostCore.sol:185 Here the function getBoost() does not implement bounds checking for the index parameter. This could lead to situations where users unintentionally pass an invalid index, resulting in a revert without a clear error message.

Internal pre-conditions

No bounds checking exists in the getBoost() function for the index parameter.

External pre-conditions

A user or external contract can provide an out-of-bounds index to the getBoost() function.

Attack Path

No response

Impact

The absence of explicit bounds checking could lead to user confusion when the function reverts unexpectedly, impacting user experience. While Solidity reverts on out-of-bounds access, a clearer implementation would enhance robustness.

PoC

No response

Mitigation

It is recommended to add a check that verifies the index is within the bounds of the _boosts array before accessing it. This can be done by comparing the index with the length of the array, preventing out-of-bounds access and ensuring clearer error handling.