The deposit_stable function of the market contract only checks if a non-zero amount of stable_denom is provided but does not ensure users didn't provide other native tokens. If users send native tokens other than stable_denom when calling this function, their funds are lost in the contract and unrecoverable. The same issue exists in the repay_stable function as well.
On the other hand, the submit_bid function in the liquidation contract includes an explicit check to ensure only stable_denom is provided.
Consider adding checks to prevent users from sending other native tokens to the contract. Please refer to the following implementation:
liquidation_queue/src/bid.rs#L33-L53
Lines of code
https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/money-market-contracts/contracts/market/src/deposit.rs#L22-L32 https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/money-market-contracts/contracts/market/src/borrow.rs#L123-L133
Vulnerability details
Impact
The
deposit_stable
function of the market contract only checks if a non-zero amount ofstable_denom
is provided but does not ensure users didn't provide other native tokens. If users send native tokens other thanstable_denom
when calling this function, their funds are lost in the contract and unrecoverable. The same issue exists in therepay_stable
function as well.On the other hand, the
submit_bid
function in the liquidation contract includes an explicit check to ensure onlystable_denom
is provided.Proof of Concept
Referenced code: market/src/deposit.rs#L22-L32 market/src/borrow.rs#L123-L133
Recommended Mitigation Steps
Consider adding checks to prevent users from sending other native tokens to the contract. Please refer to the following implementation: liquidation_queue/src/bid.rs#L33-L53