The claimAndSwap function allows the keeper role to specify arbitrary swap paths when swapping underlying tokens to asset tokens. Without validation, a malicious keeper can provide a swap path that diverts funds through attacker-controlled tokens or contracts, leading to significant financial losses for the strategy.
In the claimAndSwap function, the keeper specifies the swap route via the _path parameter:
Key issues:
No Validation of _path:
The contract does not check whether the swap path ends with the expected asset token.
It does not verify if the intermediate tokens in _path are safe or approved.
Potential for Malicious Swap Paths:
A malicious keeper can craft a swap path that routes through tokens or contracts they control.
This can result in funds being diverted away from the strategy.
Complete Loss of Swapped Funds:
Funds intended to be converted from underlying to asset can be siphoned off during the swap.
Security Breach:
The strategy's integrity is compromised if a keeper can manipulate funds without checks.
Loss of Trust:
Investors may lose confidence in the strategy due to vulnerabilities in fund management.
Setup:
The keeper has the onlyKeepers role, allowing them to call claimAndSwap.
Crafting Malicious Swap Path:
The keeper defines a swap path that includes a malicious token or contract (MaliciousToken).
For example, the path could be: WETH -> MaliciousToken -> WETH.
Execution:
The keeper calls claimAndSwap with the malicious path.
Malicious Contract Drains Funds:
The MaliciousToken contract has a transfer function that transfers tokens to the attacker's address whenever it is called.
Result:
During the swap, the underlying tokens are routed through MaliciousToken, which steals the tokens.
The strategy contract ends up with fewer asset tokens than expected, or none at all.
Validate Swap Paths:
Ensure that the swap path starts with underlying and ends with asset.
Verify that all intermediate tokens and pairs are approved and safe.
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.