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

previous approvals not revoked

Summary

The contract approves type(uint256).max for router.
If the router address is changed, the previous approval will remain active, potentially leading to security risks.

Vulnerability Details

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);
}

In the provided implementation, the contract sets the maximum approval for the router without a mechanism to revoke or reduce the approval when the router is no longer in use. This results in perpetual approvals for previously assigned routers, which could pose security risks.

Impact

Unlimited token approvals can be exploited if the router address is compromised. An attacker could misuse the unrevoked approval to transfer tokens without restrictions.

Tools Used

Manual Review

Recommendations

Add a mechanism to revoke existing approvals before assigning a new router address. This ensures that unused approvals are properly invalidated.

Consider implementing a function to explicitly manage token approvals, such as setting them to zero before re-approving with a new limit.

For example:

function setRouter(address _router) external onlyManagement {
// Revoke previous approval
if (router != address(0)) {
underlying.safeApprove(router, 0);
}
// Set new router and grant maximum approval
router = _router;
underlying.safeApprove(router, type(uint256).max);
}
Updates

Appeal created

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

Old router approval is not revoked after an update

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