The ParaSwapUtils
library's swap implementation lacks post-swap balance validation, relying solely on the success of the swap call. While the library validates the callee address and receiver, it doesn't verify the actual output amount received, which could lead to unfavorable trades being accepted.
The issue lies in:
No pre-swap balance check of the output token
No post-swap balance validation
No minimum output amount enforcement
Only validates that the call succeeded via require(success, "paraswap call reverted")
The ParaSwapUtils library's swap function lacks proper output validation, allowing trades to execute with unfavorable rates. An attacker can craft transactions that technically succeed but result in significant value loss for the protocol.
Attacker: A MEV bot operator or malicious user who monitors and manipulates the trading environment
Victim: The Perpetual Vault Protocol using ParaSwapUtils for token swaps
Protocol: ParaSwap DEX aggregator and the underlying liquidity pools
Setup (Lines 15-24):
Creates test environment with mock USDC and WETH tokens
Sets up initial balances and test conditions
Attack Preparation (Lines 25-36):
Creates manipulated price environment in mock DEX
Crafts malicious calldata that will pass validation
Execution (Lines 38-44):
Records initial balances
Executes swap through ParaSwapUtils
The swap succeeds but returns unfavorable amounts
Verification (Lines 46-60):
Compares actual output with expected output
Demonstrates significant value loss despite successful swap
Helper Functions (Lines 62-98):
craftMaliciousCalldata
: Creates valid but exploitative calldata
setupManipulatedPriceEnvironment
: Sets up attack conditions
calculateExpectedOutput
: Determines fair market value
Medium severity (monetary loss but requires specific conditions)
Protocol could receive significantly less tokens than expected from swaps
While the hardcoded Augustus Swapper address provides some safety, the lack of output validation still leaves room for manipulation
Each successful but unfavorable swap directly impacts the protocol's economics
Manual code review
Add pre and post swap balance checks:
Add explicit output token and minimum amount parameters to the function signature to make validations more robust.
Consider implementing a price deviation check using an oracle for additional safety.
Slippage and deadline are handled externally. Paraswap implementation used by the current code (behind the proxy): https://etherscan.io/address/0xdffd706ee98953d3d25a3b8440e34e3a2c9beb2c GMX code: https://github.com/gmx-io/gmx-synthetics/blob/caf3dd8b51ad9ad27b0a399f668e3016fd2c14df/contracts/order/OrderUtils.sol#L150C15-L150C33
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.