0x52 - MorphoLeverageModule#removeModule is broken and cannot be used without trapping funds #37
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0x52
Medium
MorphoLeverageModule#removeModule is broken and cannot be used without trapping funds
Summary
Removing a module for a set token is a core functionality of the protocol but MorphoLeverageModule cannot be removed without breaking set token redemption and trapping user funds. The standard methodology is that MorphoLeverageModule#removeModule would be called after the set has deleveraged to zero debt. However it fails to withdraw the collateral from Morpho, resulting in the funds becoming inaccessible after removal.
This also violates the expected behavior of the module based on comments in the contract itself and the set token
Root Cause
MorphoLeverageModule#removeModule fails to withdraw collateral from Morpho
Internal pre-conditions
None. Funds are trapped regardless of amount.
External pre-conditions
None.
Attack Path
SetToken.sol#L376-L387
The removal process begins with the set token which calls MorphoLeverageModule#removeModule.
MorphoLeverageModule.sol#L446-L462
This unregisters the MorphoLeverageModule from the debtIssuanceModule and clears the marketParams.
DebtIssuanceModule.sol#L288-L292
This in turn clears the issuance/redemption hooks, preventing the assets from being accessed.
Impact
When module is removed, set token redemption breaks and user funds are trapped.
PoC
No response
Mitigation
MorphoLeverageModule#removeModule should withdraw all funds from Morpho and update the default position for the collateral component.
The text was updated successfully, but these errors were encountered: