Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _router as parameter in _setApprovals #109

Open
gpersoon opened this issue Oct 14, 2021 · 2 comments
Open

Use _router as parameter in _setApprovals #109

gpersoon opened this issue Oct 14, 2021 · 2 comments

Comments

@gpersoon
Copy link

Vulnerability details

The function _setApprovals() of ConvexStrategy.sol includes _router as a parameter, whereas MIMConvexStrategy.sol doesn't.

MIMConvexStrategy relies on router address being set by the constructor of BaseStrategy.sol.
This only works if router is not immutable.
Luckily it isn't immutable now but this might change in forks of the code.
Although this problem is fixed in Solidity 0.8.9 it is still safer to a add _router as parameter in _setApprovals

function _setApprovals(
address _want,
address _crv,
address _cvx,
address _dai,
address _usdc,
address _usdt,
address _convexVault,
address _router,
address _stableSwap3Pool
) internal {

function _setApprovals(
address _want,
address _crv,
address _cvx,
address _mim,
address _crv3,
address _convexVault,
address _stableSwap2Pool
) internal {

Recommended mitigation steps

Change _setApprovals() of MIMConvexStrategy.sol to:

function _setApprovals(
...
address _router,
..
) internal {
..
IERC20(_crv).safeApprove(address(_router), type(uint256).max); // make sure to use _router
IERC20(_cvx).safeApprove(address(_router), type(uint256).max); // make sure to use _router
}

@uN2RVw5q
Copy link

Although this problem is fixed in Solidity 0.8.9

@gpersoon What got fixed in 0.8.9?

@gpersoon
Copy link
Author

The thing that got fixed in solidity 0.8.9 is that you can access immutable variables in the constructor.
In previous versions of solidity you cannot assign a value to an immutable variables and the access this variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants