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

Hardcoded Router Address May Cause Token Lockup in Non-Standard Networks

Summary

This audit report provides an assessment of the contract containing the hardcoded router address for token swaps. The The hardcoded router address can cause issues when deployed on networks where this address does not correspond to the appropriate router. In such cases, tokens may become locked in the protocol indefinitely, preventing withdrawals and potentially leading to financial losses.

Vulnerability Details

https://github.com/Cyfrin/2024-12-alchemix/blob/main/src/StrategyOp.sol#L36

function _initStrategy() internal
{ router = 0xa062aE8A9c5e11aaA026fc2670B0D65cCc8B2858;
underlying.safeApprove(address(router), type(uint256).max);
}
https://github.com/Cyfrin/2024-12-alchemix/blob/main/src/StrategyMainnet.sol#L43
function _initStrategy() internal {
router = ICurveRouterNG(0xF0d4c12A5768D806021F80a262B4d39d26C58b8D);
underlying.safeApprove(address(router), type(uint256).max);
}
https://github.com/Cyfrin/2024-12-alchemix/blob/main/src/StrategyArb.sol#L34
function _initStrategy() internal {
router = 0xAAA87963EFeB6f7E0a2711F397663105Acb1805e;
underlying.safeApprove(address(router), type(uint256).max);
}

Impact

The presence of the hardcoded router address can lead to token lockup issues when the contract is deployed on networks with a non-standard router. Tokens sent to the contract for swapping purposes may not be routed correctly, potentially resulting in funds being locked in the protocol forever. This can result in users losing access to their tokens and can have severe financial consequences for affected users and the protocol.

Tools Used

Recommendations

address public swapRouter;

function setSwapRouter(address _newRouter) public onlyOwner {
require(_newRouter != address(0), "Invalid router address");
swapRouter = ISwapRouter(_newRouter);
}

Updates

Appeal created

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

Cannot Set A New Router In `StrategyMainnet.sol`

Support

FAQs

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