Project

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

Input validation vulnerabilities in viewWhitelistedCurrencies()

Summary

Input validation vulnerabilities in viewWhitelistedCurrencies().

Vulnerability Details

The viewWhitelistedCurrencies() function lacks essential input validation checks, exposing it to potential exploits and unintended behavior.

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);
}

https://github.com/Cyfrin/2024-11-one-world/blob/1e872c7ab393c380010a507398d4b4caca1ae32b/contracts/dao/CurrencyManager.sol#L86C2-L103C4

Cursor Validation

  • No bounds checking for cursor parameter

  • Function proceeds even when cursor >= array length

  • Can lead to arithmetic underflow in length calculation

Size Parameter

  • No maximum limit defined

  • No minimum value validation

  • Could trigger out-of-gas errors with large values

Impact

  • Potential contract failures during pagination

  • Inconsistent data retrieval

  • Possible DOS attacks through gas exhaustion

  • Unreliable cursor positioning

Tools Used

Manual review

Recommendations

function viewWhitelistedCurrencies(uint256 cursor, uint256 size) external view returns (address[] memory, uint256) {
require(cursor < _whitelistedCurrencies.length(), "Invalid cursor");
require(size > 0 && size <= MAX_PAGE_SIZE, "Invalid size");
// ... rest of the function
}
Updates

Lead Judging Commences

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

Support

FAQs

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