The StrategyMainnet
, StrategyArb
, and StrategyOp
contracts contain a vulnerability related to unlimited token approvals. Specifically, the strategies grant unlimited approval to their respective router
contracts, allowing them to transfer any amount of tokens from the strategies. If a router is malicious or compromised, it can drain all funds deposited in the strategies.
The exploit is successfully demonstrated using a malicious router that extracts all strategy funds by leveraging the unlimited approval. This issue arises from the lack of restriction in token approval and inadequate handling of trust assumptions in the claimAndSwap
and _deployFunds
functions.
The root cause lies in the contracts granting unlimited approval of tokens to their respective routers during the initialization or interaction processes (_initStrategy
, _deployFunds
, and claimAndSwap
). This practice assumes the router is always trustworthy, but if compromised, it can perform unauthorized transfers.
Unlimited Approval: The strategy pre-approves an unlimited amount of tokens to the router. This occurs in the _initStrategy
function:
This approval remains active indefinitely, even if the router is replaced or compromised.
Malicious Router: The router is replaced by a malicious contract that abuses the approval to transfer tokens:
The malicious router can extract more tokens than intended by the strategy.
Execution: When claimAndSwap
is called, the malicious router uses the unlimited approval to drain all strategy funds instead of performing a legitimate swap.
Result: The strategy’s balance becomes zero, and all tokens are transferred to the malicious router.
Loss of Funds: An attacker controlling the router can drain all tokens approved to it, resulting in the complete loss of strategy funds.
Reputation Damage: Exploiting this vulnerability can undermine trust in the protocol and its security practices.
Systemic Risk: If multiple strategies share similar logic, the vulnerability may propagate across the system, amplifying the impact.
The following test demonstrates the exploit by replacing the router with a malicious one. The malicious router drains all funds from the strategy:
This confirms that the malicious router successfully drains all funds from the strategy.
Foundry: Used to develop and run tests to validate the vulnerability.
Manual Code Review: Confirmed the issue exists across all three contracts.
To mitigate this vulnerability, implement on-demand token approvals:
Approve Only When Needed:
Replace unlimited approvals with exact approvals just before the operation:
Reset Approvals Post-Operation:
Reset approvals to zero immediately after completing the operation:
The following mitigated code implements these recommendations:
The following test verifies that the mitigation is effective. It ensures the router fails to exploit the strategy:
This confirms the exploit is no longer viable after applying the mitigation.
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.