DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Valid

Users can bypass maxPositionsPerAccount due to improper checks

Summary

The config globalConfiguration.maxPositionsPerAccountis used to ensure that number of positions of tradingAccountdoesn't exceed certain threshold. However, due to insufficient checks, traders can have more positions than maxPositionsPerAccountin their trading account.

Vulnerability Details

The createMarketOrderchecks that whether the newly created order exceeds number of positions of account than the mentioned threshold. However, there is no such checks present while settlement of orders. Also, due to off-chain component, users can bypass this check easily.

Consider the following example:
maxPositionsPerAccountis 5.

currentActivePositionsOfTraderis 3.

Trader place offchain orders in two different perp market.

Trader creates new market order.

Market order is settled and currentActivePositionsOfTraderis 4.

Off-chain orders is settled and currentActivePositionsOfTraderis 6.

Impact

Traders can have more positions than maxPositionsPerAccountin their trading account. Due to this, running out of gas in functions that loop over the active positions of accounts such as liquidation etc.

Tools Used

Manual review

Recommendations

Ensure that the settlement of trade doesn't exceed trader's active position than required threshold.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

`maxPositionsPerAccount` may be exceeded by combining onchain and offchain orders

Support

FAQs

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

Give us feedback!