The checkUpkeep
function contains a critical vulnerability due to improper initialization of the marketIds
and assets
arrays. These arrays are initialized with a fixed size of liveMarketIds.length * 10
, which does not account for the actual number of assets requiring fee distribution. This approach leads to buffer overflow/underflow risks and data truncation.
The arrays are initialized to the size of liveMarketIds.length * 10
, assuming each market has at most liveMarketIds.length * 10
assets. This is an arbitrary assumption and not enforced by the protocol.
Suppose a market has more than liveMarketIds.length * 10
assets, the loop will attempt to write beyond the array’s bounds, causing a runtime error.
Suppose a market has fewer than liveMarketIds.length * 10
assets, the arrays will contain unused slots, wasting gas.
The inner loop iterates over marketAssets
, which can have an arbitrary number of assets per market. There is no limit on how many assets a market can have, making the fixed-size arrays unsafe.
Denial-of-Service (DoS): The function will revert if any market has more assets than the fixed array allows, preventing all fee distributions.
Incomplete Distributions: Valid fee distribution requests will be not be processed if the total exceeds the fixed array size, violating protocol guarantees.
Gas Waste: Unused array slots increase gas costs unnecessarily.
Manual Review
Replace fixed-size arrays with dynamic arrays to accommodate an arbitrary number of entries:
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.