Closed code423n4 closed 2 years ago
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L78-L81 https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L157-L160
Inability to set or change curve pool after initialization will hurt the project liquidity and block the ability to instant unstake from curve.
CURVE_POOL
initialize
setCurvePool
instantUnstakeCurve
ethers.constants.AddressZero,
await staking.setCurvePool(constants.CURVE_POOL);
"Can instant unstake full amount with curve"
"Can instant unstake partial amount with curve"
Yarn Hardhat
Add approve to setCurvePool so it will look like this:
function setCurvePool(address _curvePool) external onlyOwner { CURVE_POOL = _curvePool; IERC20(TOKE_POOL).approve(CURVE_POOL, type(uint256).max); setToAndFromCurve(); }
sponsor confirmed
The judging sheet mentions this as duplicate of https://github.com/code-423n4/2022-06-yieldy-findings/issues/222 instead of https://github.com/code-423n4/2022-06-yieldy-findings/issues/165.
Lines of code
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L78-L81 https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L157-L160
Vulnerability details
https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L78-L81 https://github.com/code-423n4/2022-06-yieldy/blob/524f3b83522125fb7d4677fa7a7e5ba5a2c0fe67/src/contracts/Staking.sol#L157-L160
Impact
Inability to set or change curve pool after initialization will hurt the project liquidity and block the ability to instant unstake from curve.
CURVE_POOL
address is done only oninitialize
and only if non zero address supplied.setCurvePool
the address changes but not approved, thereforeinstantUnstakeCurve
will fail with any parameters.Proof of Concept
ethers.constants.AddressZero,
await staking.setCurvePool(constants.CURVE_POOL);
"Can instant unstake full amount with curve"
and"Can instant unstake partial amount with curve"
will failTools Used
Yarn Hardhat
Recommended Mitigation Steps
Add approve to
setCurvePool
so it will look like this: