Open code423n4 opened 2 years ago
Loss of yield, conditional on reaching limit, consider reducing severity
Can be mitigated with a large spend limit, which likely exists to prevent catastrophic cases. The issue is correct though, that this is a bug. Downgrading to med severity though, given the practicality.
Lines of code
https://github.com/code-423n4/2022-02-anchor/blob/7af353e3234837979a19ddc8093dc9ad3c63ab6b/contracts/money-market-contracts/contracts/market/src/borrow.rs#L216-L234
Vulnerability details
While
claim_rewards
from themoney-market
, it calls thedistributor_contract#spend()
to send the rewards.https://github.com/code-423n4/2022-02-anchor/blob/7af353e3234837979a19ddc8093dc9ad3c63ab6b/contracts/money-market-contracts/contracts/market/src/borrow.rs#L216-L234
However, the
distributor_contract#spend()
function have aspend_limit
config and it will revert if the amount is larger than thespend_limit
.https://github.com/code-423n4/2022-02-anchor/blob/7af353e3234837979a19ddc8093dc9ad3c63ab6b/contracts/anchor-token-contracts/contracts/distributor/src/contract.rs#L153-L155
As a result, users won't be able to claim their rewards anymore once the amount of the rewards excess the spend_limit config on
distributor_contract
.Recommendation
Consider removing the
spend_limit
or allowing users to specify an amount whenclaim_rewards
.