DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: medium
Invalid

Unlimited token approval for routers

Summary

The StrategyMainnet , StrategyOp and StrategyArb contracts grant unlimited token approval (type(uint256).max) to their respective router contracts (ICurveRouterNG,IVeloRouter and IRamsesRouter). This creates a significant risk if the routers are compromised, as an attacker could drain all underlying tokens from the strategies.

Vulnerability Details

The underlying token is approved with the type(uint256).max allowance for the router in the _initStrategy() and setRouter() functions.

These routers are external contracts. If either router is compromised or contains a vulnerability, an attacker can exploit the unlimited approval to transfer all tokens from the strategy.

This risk exists even if no function in the strategy is explicitly called, as the routers hold perpetual approval.

Impact

An attacker exploiting the router can damage the strategy of all underlying tokens.

Tools Used

manual

Recommendations

Grant approval only for the exact amount required for each transaction. This eliminates the risk of over-approval.

function _initStrategy() internal {
router = 0xa062aE8A9c5e11aaA026fc2670B0D65cCc8B2858;
- underlying.safeApprove(address(router), type(uint256).max);
}
function setRouter(address _router) external onlyManagement {
router = _router;
- underlying.safeApprove(router, type(uint256).max);
}
function _swapUnderlyingToAsset(uint256 _amount, uint256 minOut, IVeloRouter.route[] calldata _path) internal {
require(minOut > _amount, "minOut too low");
uint256 underlyingBalance = underlying.balanceOf(address(this));
require(underlyingBalance >= _amount, "not enough underlying balance");
+ underlying.forceApprove(router, _amount);
IVeloRouter(router).swapExactTokensForTokens(_amount, minOut, _path, address(this), block.timestamp);
}
Updates

Appeal created

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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