sherlock-audit / 2022-10-illuminate-judging

3 stars 0 forks source link

ctf_sec - Redeem function for Sense finance does not check the maturity. #146

Closed sherlock-admin closed 2 years ago

sherlock-admin commented 2 years ago

ctf_sec

medium

Redeem function for Sense finance does not check the maturity.

Summary

Redeem function for Sense finance does not check the maturity.

Vulnerability Detail

In the redeem function implementation, the code uses a lengthy implementation but accurate implementation to check if the position's maturity

If the position is not matured, the transaction revert before going to redeem:

// Verify that the token has matured
if (maturity > block.timestamp) {
    revert Exception(7, maturity, 0, address(0), address(0));
}

However, the checking for maturity is missing in Sense redeeming function!

Impact

Redeeming before maturity should not be allowed.

Code Snippet

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Redeemer.sol#L335-L365

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Redeemer.sol#L254-L259

Tool used

Manual Review

Recommendation

After some research, I believe we can check the Sense finance maturity first using the function below

https://github.com/sense-finance/sense-v1/blob/7b37dec129dbf207a2d2ac2469ced7c75b157691/pkg/core/src/adapters/abstract/BaseAdapter.sol#L172

    function getMaturityBounds() external view virtual returns (uint256, uint256) {
        return (adapterParams.minm, adapterParams.maxm);
    }

We can get the maturity first and validate the maturity before calling redeem.

sourabhmarathe commented 2 years ago

Sense's redeem method reverts if maturity has not occurred for the market in question. In addition, Sense's PT does not provide a mechanism to check the maturity. As a result, another approach will have to be taken to address Sense's maturity.