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

Faulty offchain orders cause revert for valid orders

Summary

In SettlementBranch:: fillOfchainOrders, there is a for loop which goes through each offchain order within a batch. It calculates bid, ask, and all necessary accounting to fill the order. However, there are checks which result in a revert in the case of a faulty order. Even if there is a batch order of size 50 and one user submits an order with size delta 0, all 50 orders would be rejected

Vulnerability Details

// iterate through off-chain orders; intentionally not caching
// length as reading from calldata is faster
for (uint256 i; i < offchainOrders.length; i++) {
ctx.offchainOrder = offchainOrders[i];
// enforce size > 0
if (ctx.offchainOrder.sizeDelta == 0) {
revert Errors.ZeroInput("offchainOrder.sizeDelta");
}

Within SettlementBranch:: fillOfchainOrders, the for loop is used to sift through the off chain orders and determine validity and to fill the order. However, the checks such as lines 7 through 9 above cause a function to REVERT in the case of a faulty order. This creates a direct denial-of-service to all other orders within the batch, in turn creating an opening for manipulation via a malicious actor.

Impact

Malicious actor can cancel all off-chain orders within a batch

Text-POC

  • 25 users create valid off chain orders

  • 1 malicious actor creates an invalid off chain order with a sizeDelta of zero

  • When the for loop reaches the malicious actor's order, the if statement which checks if ctx.offchainOrder.sizeDelta == 0 will be triggered

  • This will cause a revert, reverting all valid filled offchain orders which took place and any valid offchain orders ahead of the malicious one from being filled

Tools Used

Manual Review

Recommendations

Instead of using revert, the protocol could use continue to ensure that the order is skipped over but other orders are not invalidated.

Updates

Lead Judging Commences

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

fillOffchainOrders reverts everything if a single order fails one of the multiple checks

If you send 1 cancel and 1 create it should still run the cancel, not revert everything.

Support

FAQs

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

Give us feedback!