DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: low
Valid

Missing Revocation of Previous Router Approval in `setRouter()`

Summary

The setRouter function allows management to set a new router and grants the new router an infinite approval to spend the underlying token. However, the function does not revoke the approval of the previous router.

function setRouter(address _router) external onlyManagement {
router = _router;
// underlying is WETH
underlying.safeApprove(router, type(uint256).max);
}

Vulnerability Details

The setRouter() function in the StrategyOp, StrategyArb, and StrategyMainnet contracts allows management to set a new router and grants the new router an infinite approval to spend the underlying token. However, the function does not revoke the approval of the previous router, leaving the previous router with lingering approval to spend the contract's tokens.

Impact

If the previously approved router remains authorized to spend tokens, it poses a security risk:

  1. Unauthorized Usage: If the previous router is compromised or malicious, it could continue to spend the underlying token without restriction.

  2. Loss of Funds: If the previous router’s contract is exploited, it could drain all approved tokens from the protocol.

Tools Used

manual review

Recommendations

Revoke the approval of the previous router before setting a new one. This can be done by calling safeApprove() with a value of 0 for the previous router.

function setRouter(address _router) external onlyManagement {
// Revoke approval of the previous router
@>>> underlying.safeApprove(router, 0);
// Update the router and approve the new one
router = _router;
underlying.safeApprove(router, type(uint256).max);
}
Updates

Appeal created

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Old router approval is not revoked after an update

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Old router approval is not revoked after an update

Support

FAQs

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