Open code423n4 opened 1 year ago
chechu marked the issue as disagree with severity
Smart contracts integrating borrowRatePerBlock() can call accrueInterest() first to get updated borrow rate
I think QA is appropriate here, documentation could be improved to make the integration pattern more clear OR a view function with the logic needed for this to work could be created to avoid additional gas costs... but hard to declare this as M severity as is.
0xean changed the severity to QA (Quality Assurance)
Lines of code
https://github.com/code-423n4/2023-05-venus/blob/8be784ed9752b80e6f1b8b781e2e6251748d0d7e/contracts/VToken.sol#L587-L590
Vulnerability details
borrowRatePerBlock()
returns the borrowing rate, but the interests accrued are not included.Impact
Any smart contract relying on the value of
borrowRatePerBlock()
to perform some logic - such as decide whether toborrow
fromVToken
based on the returned value - will be impacted.For instance, imagine a protocol
ABC
having a function in their contract that callsborrowRatePerBlock()
and have a conditional call toVToken.borrow()
if the borrowing rate is less thanN
. The call toborrowRatePerBlock()
may return a valueM < N
, but the actual borrowing rate processed inborrow()
can beP > N
due to interest accrual.Tools Used
Manual Analysis
Recommended Mitigation Steps
Include some interest accrual logic in
borrowRatePerBlock()
- note that it cannot be a simple call toaccrueInterest
asborrowRatePerBlock()
is a view function.Assessed type
Timing