MorpheusAI

MorpheusAI
Foundry
22,500 USDC
View results
Submission Details
Severity: medium
Invalid

Lack of Bounds Checking in User Management, it could lead to accessing non-existing elements and result in array out-of-bounds

Summary

The manageUsersInPrivatePool function in the Distribution contract lacks bounds checking when iterating over the users_ and amounts_ arrays, which may result in array out-of-bounds errors.

Vulnerability Details

POC

function manageUsersInPrivatePool(
uint256 poolId_,
address[] calldata users_,
uint256[] calldata amounts_
) external onlyOwner poolExists(poolId_) {
// No bounds checking for 'users_' and 'amounts_'
require(!pools[poolId_].isPublic, "DS: pool is public");
require(users_.length == amounts_.length, "DS: invalid length");
// ...
}

Description

The function manageUsersInPrivatePool iterates over the users_ and amounts_ arrays without verifying that the array lengths match. If the lengths differ, it could lead to accessing non-existing elements and result in array out-of-bounds errors.

Impact

The lack of bounds checking may lead to runtime errors, causing unexpected behavior or contract failure. An attacker could potentially exploit this vulnerability to manipulate the array lengths and cause the contract to behave in unintended ways.

Tools Used

No specific tools were used to identify this issue; it was identified through manual code review.

Recommendations and Mitigation

Implement bounds checking to ensure that the lengths of users_ and amounts_ arrays match before iterating over them. Additionally, consider handling potential length mismatches gracefully by reverting with a descriptive error message if the lengths do not match.

Adding the check require(users_.length == amounts_.length, "DS: array lengths do not match"); ensures that the array lengths are consistent before proceeding with the iteration, preventing array out-of-bounds errors.

function manageUsersInPrivatePool(
uint256 poolId_,
address[] calldata users_,
uint256[] calldata amounts_
) external onlyOwner poolExists(poolId_) {
require(!pools[poolId_].isPublic, "DS: pool is public");
require(users_.length == amounts_.length, "DS: array lengths do not match");
for (uint256 i = 0; i < users_.length; i++) {
address user_ = users_[i];
uint256 amount_ = amounts_[i];
// Perform operations on user and amount
// ...
}
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.