Part 2

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

Denial-of-Service risk in initiateSwap leading to forced refunds and financial loss

Summary

Malicious actors can flood the system with many small initiateSwap requests, overwhelming the fulfillSwap function. If the system keeper cannot process all pending swaps in time, valid swap requests may expire due to the deadline check in fulfillSwap, legitimate users are forced to call refundSwap to reclaim their locked funds, losing money due to swap fees.

Vulnerability Details

The issue arises from how initiateSwap allows unlimited pending swap requests while fulfillSwap has a deadline check. The malicious actors can spam initiateSwap with many small requests, delaying swap processing.

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/branches/StabilityBranch.sol#L347-L349

if (ctx.deadline < block.timestamp) {
revert Errors.SwapRequestExpired(user, requestId, ctx.deadline);
}

After the swap request expired, users are forced to call refundSwap to reclaim their locked funds, losing money due to swap fees if the baseFeeUsd is not zero.

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/branches/StabilityBranch.sol#L474

// cache the amount of usd tokens to be refunded
uint256 refundAmountUsd = depositedUsdToken - baseFeeUsd;

Impact

Denial of Service (DoS): The swap system becomes unusable due to spammed and expired requests.
Financial Loss: Users lose money to refund fees without completing swaps.

Tools Used

Manual code review

Recommended Mitigation

Implement a priority queue or enforce a minimum USD token amount per swap

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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