borrowRateMaxMantissa should be specific to the chain protocol is being deployed to
The maximum borrow rate constant is fixed for all chains, so on chains with shorter block times the effective annual maximum borrow rate becomes extremely high. An attacker could exploit this to borrow at an absurd rate if utilisation spikes, potentially causing protocol failure.
Submitted by kankodu, also found by cryptonue
https://github.com/code-423n4/2023-07-moonwell/blob/main/src/core/MTokenInterfaces.sol#L23
- The purpose of borrowRateMaxMantissa is to put the protocol in failure mode when absurd utilisation makes borrowRate absurd. It is defined as a constant for all the chains. It should really be changed according to average blocktime of the chain the protocol is being deployed to.
- borrowRateMaxMantissa = 0.0005e16 translates to maximum borrow rate of .0005% / block.
- For Ethereum chain that has 12 seconds of average block time, this translates to maximum borrow rate of
0.0005% * (365 * 24 * 3600)/12 = 1314. For BNB with 3 seconds of average block time it is0.0005% * (365 * 24 * 3600)/3 = 5256%. For fantom with 1 second of average block time it is0.0005% * (365 * 24 * 3600)/1 = 15768%.
Proof of Concept
https://github.com/code-423n4/2023-07-moonwell/blob/main/src/core/MTokenInterfaces.sol#L23
Recommended Mitigation Steps
- Decide on a maximum borrow rate protocol is ok with (my suggestion is ~1000%) and change
borrowRateMaxMantissaaccording to what chain it is being deployed to.
ElliotFriedman (Moonwell) acknowledged and commented:
Agreed this could be configured on a per chain basis, however this is legacy code that we don’t want to change. This instance is only being deployed on base, so maybe instead of making it configurable, this value could be adjusted downwards.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the maximum borrow rate constant was not adjusted for the average block time of the deployment chain, so the per-block cap translates to an excessive annual rate on faster chains.
Impact
On chains with short block times, the maximum annual borrow rate could reach thousands of percent, potentially putting the protocol in failure mode if utilisation becomes absurd.
What the attacker needed
Protocol deployed on a fast-block chain; utilisation becomes absurd
The fix
The value should be adjusted downwards or made configurable per chain to target a reasonable maximum annual borrow rate.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract sets a cap on how fast interest can grow per block. Because different blockchains produce blocks at different speeds, the same per-block cap means a much higher yearly interest rate on faster chains. This could let someone borrow at a rate so high it breaks the protocol's economics.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.