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

Approval not set to 0 to Old router before New router is set

Summary

The approve function in the strategy contract allows for an unlimited allowance (type(uint256).max) to a new router when switching to it. However, the approval for the old router is not revoked, leaving the old router with maximum approval. This creates an over-allowance vulnerability where unauthorized or unintended actions can exploit the old router's residual approval.

Vulnerability Details

The function does not revoke allowances for the old router when transitioning to a new one.
The first Router address and the Second both will have type(uint256).max approve.

function _initStrategy() internal {
router = 0xAAA87963EFeB6f7E0a2711F397663105Acb1805e;
underlying.safeApprove(address(router), type(uint256).max);
}
function setRouter(address _router) external onlyManagement {
router = _router;
underlying.safeApprove(router, type(uint256).max);
}

Impact

Unnecessary approve for old router which leaves every old router with max approve.

Tools Used

Solidit:
Defi / General / SOL-Defi-General-6 Does the protocol revert on maximum approval to prevent over-allowance? Setting high allowances can make funds vulnerable to abuse; protocols sometimes set max to prevent this risk. Consider implementing a revert on approval functions when an unnecessarily high allowance is set.

Recommendations

  1. Revoke Old Router Approval: Introduce logic to explicitly reset the allowance of the old router to zero (underlying.safeApprove(oldRouter, 0)) before assigning maximum approval to the new router.

function setRouter(address _router) external onlyManagement {
+ underlying.safeApprove(router, 0);
router = _router;
underlying.safeApprove(router, type(uint256).max);
}
Updates

Appeal created

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

Old router approval is not revoked after an update

inallhonesty Lead Judge 10 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.