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

Unrevoked Token Approval for Old Router

Summary

The setRouter function in the StrategyOp contract allows the contract’s management to update the address of the router used for token swaps. However, the current implementation only approves the new router, without explicitly revoking approval for the old router. This can lead to a security vulnerability where the previous router address could still be able to spend tokens.

Vulnerability Details

https://github.com/Cyfrin/2024-12-alchemix/blob/82798f4891e41959eef866bd1d4cb44fc1e26439/src/StrategyArb.sol#L42

https://github.com/Cyfrin/2024-12-alchemix/blob/82798f4891e41959eef866bd1d4cb44fc1e26439/src/StrategyOp.sol#L48

The setRouter function updates the router address and approves the new router to spend the underlying token using safeApprove. However, it does not revoke the approval for the old router. In the current implementation, there is no mechanism to revoke the old router’s approval when a new one is set. This leaves the previous router address with the ability to spend unlimited tokens, potentially resulting in unauthorized token transfers or security exploits.

Impact

The old router can still call safeApprove or other methods to withdraw or spend tokens, resulting in potential loss or misappropriation of funds.

Attackers or unauthorized entities could take advantage of the lingering approval for the old router, potentially draining funds.

Tools Used

Recommendations

function setRouter(address _router) external onlyManagement {
address oldRouter = router; // Save the old router address
router = _router; // Set the new router
underlying.safeApprove(oldRouter, 0);
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.