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

Old router approval not reset when setting a new router

Summary

In the setRouter function, a new router is set without resetting the approval for the old router. This can leave the old router with unlimited approval, posing a security risk.

Vulnerability Details

The setRouter function updates the router contract and sets a new approval for the updated router. However, it does not reset the approval for the old router, leaving it with unlimited access to the underlying token. If the old router becomes compromised or behaves maliciously, it could exploit this unrestricted approval.

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

In the current implementation, the old router retains approval to spend the underlying token, which is not explicitly revoked.

Impact

This vulnerability could lead to unintended token transfers by the old router if it becomes compromised or malicious. Attackers could exploit this to drain the contract's underlying token balance, causing significant financial loss.

Tools Used

Manual inspection.

Recommendations

To mitigate the risk, reset the approval for the old router before setting a new one. This ensures that no obsolete router retains token access.

function setRouter(address _router) external onlyManagement {
underlying.safeApprove(router, 0); // Reset the approval for old router
router = _router;
underlying.safeApprove(router, type(uint256).max);
}

This modification explicitly revokes the approval for the old router before updating to a new one, minimizing the risk of token mismanagement.

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.