Summary
The claimAndSwap
function accepts an array of swap paths (_path
) without validating their integrity. This oversight increases the risk of malicious or improperly configured swap paths, which could lead to token theft, slippage exploitation, or interactions with malicious contracts. Implementing robust path validation and restrictions can mitigate these risks effectively.
The _path
parameter, an array of IVeloRouter.route
structures, is passed directly to the IVeloRouter.swapExactTokensForTokens
function without validation. This allows arbitrary paths to be supplied, potentially exposing the protocol to malicious or inefficient routes.
Malicious Routes: Unverified _path
inputs can redirect swaps to malicious contracts that steal tokens.
Excessive Complexity: Overly complex paths can cause gas exhaustion, failed transactions, or unfavorable swap outcomes.
Protocol Integrity: Allowing unrestricted paths undermines the trust and stability of the protocol’s swap operations.
Attack Scenarios Common to happen
Setup: A Keeper provides a _path
that routes WETH through a malicious contract.
Execution: The malicious contract intercepts WETH and transfers it to an attacker’s address.
**Impact **The strategy loses WETH, and funds are drained from the protocol.
Setup: A Keeper designs a _path
with multiple intermediary tokens that increase the complexity of the swap.
Execution: The swap fails to meet the minOut
condition due to manipulated slippage, causing transaction failures or economic loss.
**Impact **Users experience reduced yields or financial losses due to unfavorable trades.
Setup: A malicious Keeper provides a _path
with unnecessary steps, increasing gas consumption.
Execution: The transaction consumes excessive gas, leading to failed swaps or operational delays.
**Impact **The strategy becomes less efficient, harming depositors and the protocol's reputation.
Impact
Financial Risk: Loss of funds through malicious swaps or slippage manipulation.
Operational Risk: Increased gas costs and failed transactions.
Reputational Risk: Undermined trust in the protocol due to exploitability.
Mitigation Recommendations
Check Token Sequences: Verify that each token in the _path
array adheres to expected token pairs and is compatible with the protocol’s assets.
Verify Contract Addresses: Ensure each contract in the swap path is legitimate and aligns with known protocols (e.g., VeloRouter, Uniswap).
Restrict swap paths to use only contracts on an approved whitelist:
Set a maximum length for _path
to reduce gas consumption and prevent unnecessary complexity:
Log details of each swap to facilitate auditing and real-time monitoring:
Proof of Concept (PoC)
Deploy the StrategyOp
contract with mock implementations of IVeloRouter
and transmuter
.
Call claimAndSwap
with a _path
that includes a malicious contract.
Observe token transfers to the malicious contract instead of legitimate pools.
Implement path validation as recommended.
Retry the exploit with the same malicious _path
.
Observe the transaction revert with an error message indicating invalid paths.
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.