Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: low
Invalid

`viewWhitelistedCurrencies` missing important check for `cursor` which can lead to unintentional behavior

Summary

viewWhitelistedCurrencies missing important checks for cursor which can lead to unintentional behavior

Vulnerability Details

Here you can see the cursor is not checking whether it is in the correct length.

/**
* @notice See whitelisted currencies in the system
* @param cursor cursor (should start at 0 for first request)
* @param size size of the response (e.g., 50)
*/
function viewWhitelistedCurrencies(
uint256 cursor,
uint256 size
) external view override returns (address[] memory, uint256) {
uint256 length = size;
if (length > _whitelistedCurrencies.length() - cursor) {
length = _whitelistedCurrencies.length() - cursor;
}
address[] memory whitelistedCurrencies = new address[]();
for (uint256 i = 0; i < length; i++) {
whitelistedCurrencies[i] = _whitelistedCurrencies.at(cursor + i);
}
return (whitelistedCurrencies, cursor + length);
}

Impact

Passing greater or equal value to _whitelistedCurrencies.length() can lead to unintentional behavior

Tools Used

Manually Reviewed

Recommendations

Add the following lines of code here.

/**
* @notice See whitelisted currencies in the system
* @param cursor cursor (should start at 0 for first request)
* @param size size of the response (e.g., 50)
*/
function viewWhitelistedCurrencies(
uint256 cursor,
uint256 size
) external view override returns (address[] memory, uint256) {
+ if (cursor >= _whitelistedCurrencies.length()) {
+ revert("Invalid cursor value");
+ }
uint256 length = size;
if (length > _whitelistedCurrencies.length() - cursor) {
length = _whitelistedCurrencies.length() - cursor;
}
address[] memory whitelistedCurrencies = new address[]();
for (uint256 i = 0; i < length; i++) {
whitelistedCurrencies[i] = _whitelistedCurrencies.at(cursor + i);
}
return (whitelistedCurrencies, cursor + length);
}
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
0xbrivan2 Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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