Summary
In contact StrategyArb.sol
,StrategyOp.sol
function setRouter
has not any check for address(0)
.
In contract StrategyMainnet.sol
function addRoute
has not check for address(0)
Vulnerability Details
This issue is classified as a High Severity
finding due to complete loss of funds from the contract ad address(0)
.In the StartegyArb.sol:42
,StrategyOp.sol:48
,StrategyMainnet.sol:56
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
https://github.com/Cyfrin/2024-12-alchemix/blob/82798f4891e41959eef866bd1d4cb44fc1e26439/src/StrategyMainnet.sol#L56
This for contract StrategyArb.sol
,StrategyOp.sol
.
function setRouter(address _router) external onlyManagement {
@> router = _router;
underlying.safeApprove(router, type(uint256).max);
}
This for contract StrategyMainnet.sol
.
function addRoute(
address[11] calldata _route,
uint256[5][5] calldata _swapParams,
address[5] calldata _pools
) external onlyManagement {
@> routes[nRoutes] = _route;
swapParams[nRoutes] = _swapParams;
pools[nRoutes] = _pools;
nRoutes++;
}
Impact
Loss of funds to address(0)
Contract Logic Errors
DoS Through Critical Address Set to address(0)
but it may save from this because of onlyManagement
.
Irrecoverable and Lock of Funds
Tools Used Manual Review
Recommendations
Although is protected from onlyManagement
but by mistake it implemented to address(0)
.So it is required to include checks.
This is for contract StrategyArb.sol
,StrategyOp.sol
.
function setRouter(address _router) external onlyManagement {
+ require(_router != address(0),"Zero Address Implementation");
router = _router;
underlying.safeApprove(router, type(uint256).max);
}
This is for contract StrategyMainnet.sol
.
function addRoute(
address[11] calldata _route,
uint256[5][5] calldata _swapParams,
address[5] calldata _pools
) external onlyManagement {
+ require(_router != address(0),"Zero Address Implementation");
routes[nRoutes] = _route;
swapParams[nRoutes] = _swapParams;
pools[nRoutes] = _pools;
nRoutes++;
}