QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: low
Invalid

Absence of Array Length Validation in MultiHopOracle.sol

Summary

MultiHopOracle.sol is designed for tokens where no direct oracle/price feeds exist. However, the constructor() lacks a validation statement for the _oracles variable. If the length of _oracles is zero, the _getData() function cannot retrieve data, rendering the contract ineffective in fulfilling its purpose.

Vulnerability Details

constructor(HopConfig[] memory _oracles) {
for (uint i = 0; i < _oracles.length; i++) {
oracles.push(_oracles[i]);
}
}

This is the constructor function in MultiHopOracle.sol. As shown in the code snippet, there is no validation to ensure the _oracles array is non-empty. The issue originates from the absence of a check to confirm that _oracles.length > 0

https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/MultiHopOracle.sol#L19

Impact

If the oracles array length is zero, the _getData() function will not function correctly as there will be no valid oracles to pull data from.

Tools Used

Recommendations

We have to add a validation check in the constructor to ensure the _oracles array is non-empty

constructor(HopConfig[] memory _oracles) {
require(_oracles.length > 0, "Oracles array cannot be empty");
for (uint i = 0; i < _oracles.length; i++) {
oracles.push(_oracles[i]);
}
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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