Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Lack of Market ID Existence Check in `LiveMarkets::addMarket` Function

Summary

The addMarket function is responsible for adding a market to the liveMarketIds set. However, it does not include a check to verify if the marketId is already present in the set before attempting to add it. This missing check can lead to unintended behavior, such as duplicates being added to the set, which may cause issues with data integrity or logic flow in the system.

Vulnerability Details

The function does not verify whether the marketId is already present in liveMarketIds before adding it. In this case, calling the function multiple times with the same marketId could result in duplicate entries in the set, potentially violating business rules or causing inefficient operations. A set is typically expected to contain unique values, and failing to enforce this uniqueness could lead to problems in other parts of the contract where the uniqueness of the market ID is critical.

function addMarket(Data storage self, uint128 marketId) internal returns (bool) {
return self.liveMarketIds.add(uint256(marketId));
}

Impact

The presence of duplicate marketId entries can corrupt the data, leading to inaccurate records of active markets.
If the contract logic assumes each market ID is unique, the absence of checks could cause errors, especially if other functions rely on the assumption of unique marketIds.
The contract might perform redundant operations or updates, which could be costly.

Recommendations

Add Check for Market ID Existence.
Consider Reverting Duplicate Entries

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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