code-423n4 / 2022-06-yieldy-findings

0 stars 0 forks source link

[M-01] Cannot set or change curve pool after initialization #285

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

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.

Proof of Concept

Tools Used

Yarn Hardhat

Recommended Mitigation Steps

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();
    }
toshiSat commented 2 years ago

sponsor confirmed

KenzoAgada commented 2 years ago

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.