The QuantammMathMovingAverage::_calculateQuantAMMMovingAverage
function does not impose any restrictions on the size of the _lambda
and _newData
arrays passed as parameters. This omission makes it possible for a malicious user to craft a transaction with excessively large arrays. Although these transactions might stay below the Ethereum Virtual Machine (EVM) block gas limit, they could result in high gas costs, rendering subsequent legitimate transactions economically infeasible. This vulnerability represents a Denial-of-Service (DoS) risk and could lead to inefficiencies in the system.
Both _newData
and _lambda
are dynamic arrays passed to the function.
The function iterates through these arrays using a for
loop, performing calculations for each element.
There is no limit on the size of these arrays, allowing an attacker to input extremely large arrays just below the EVM’s block gas limit. This could:
Cause the transaction to consume excessive gas.
Lead to an economic DoS for subsequent legitimate users, as the gas usage increases significantly.
Economic Denial-of-Service (DoS): Maliciously large array inputs can make contract interactions prohibitively expensive.
System Inefficiency: Lack of input validation opens the door to misuse and inefficiencies during execution.
Attacker passes arrays of size 10,000
to _newData
and _lambda
.
Gas usage for processing this large input significantly increases but remains below the block gas limit.
Legitimate users find subsequent transactions prohibitively expensive due to high base gas requirements caused by the attacker’s input.
Manuel Review
Limit Array Size Implement an upper limit on the size of _lambda
and _newData
. For example:
Estimate Gas Costs Before proceeding with execution, ensure the estimated gas costs do not exceed a safe threshold:
Validate Array Consistency Ensure the sizes of _newData
, _lambda
, and _prevMovingAverag
e match _numberOfAssets
:
This vulnerability allows malicious actors to exploit the absence of input size validation, potentially leading to high gas costs and a Denial-of-Service (DoS) condition. By enforcing limits on the input size and validating array consistency, this issue can be mitigated effectively. This is a critical recommendation to enhance the robustness and security of the contract. Personally, I feel the third recommendation is best suited for the project.
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.