Submitted by cmichel
The UToken.borrow function first checks the borrowed balance and the old credit limit before accruing the actual interest on the market:
Thus the borrowed balance of the user does not include the latest interest as it uses the old global borrowIndex but the new borrowIndex is only set in accrueInterest.
In low-activity markets, it could be that the borrowIndex accruals (accrueInterest calls) happen infrequently and a long time is between them.
A borrower could borrow tokens, and borrow more tokens later at a different time without first having their latest debt accrued.
This will lead to borrowers being able to borrow more than maxBorrow and more than their credit limit as these checks are performed before updating accruing interest.
The require(accrueInterest(), "UToken: accrue interest failed"); call should happen at the beginning of the function.
GeraldHost (Union Finance) confirmed
GalloDaSballo (judge) commented:
