code-423n4 / 2021-04-maple-findings

0 stars 0 forks source link

Missing check for Pool state on several functions in Pool.sol #68

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

0xRajeev

Vulnerability details

Impact

The Pool may be in three states: Initialized, Finalized and Deactivated as indicated by the enum State variable. While a couple of functions such as fundLoan() and deposit() check against a valid Pool state i.e. Finalized using _isValidState(State.Finalized), most other functions miss this check. This could cause unexpected protocol behavior if such functions are triggered in invalid Pool states e.g. Deactivated.

Examples of such functions missing this Pool state validity check are triggerDefault(), claim(), withdraw() and withdrawFunds().

Proof of Concept

https://github.com/maple-labs/maple-core/blob/355141befa89c7623150a83b7d56a5f5820819e9/contracts/Pool.sol#L50

https://github.com/maple-labs/maple-core/blob/355141befa89c7623150a83b7d56a5f5820819e9/contracts/Pool.sol#L168 https://github.com/maple-labs/maple-core/blob/355141befa89c7623150a83b7d56a5f5820819e9/contracts/Pool.sol#L185 https://github.com/maple-labs/maple-core/blob/355141befa89c7623150a83b7d56a5f5820819e9/contracts/Pool.sol#L392 https://github.com/maple-labs/maple-core/blob/355141befa89c7623150a83b7d56a5f5820819e9/contracts/Pool.sol#L424

Tools Used

Manual Analysis

Recommended Mitigation Steps

Add _isValidState(State.Finalized) check to all such functions specified above.

lucas-manuel commented 3 years ago

Informational, will address, not really a bug.

Arachnid commented 3 years ago

Submitter has not demonstrated how this can be exploited, but these seem like important checks to be omitting and may well result in invariants being violated. In the absence of a specific exploit vector, I'm awarding this as Low.

satyamakgec commented 3 years ago

So we did an analysis again and here are some data points -

We could add the statechecks eventually but it doesn't give us any extra benefit although it does increase the size of the PoolFactory contract bytecode that we don't want as we are already on the verge of 24 KB