Potential overflow at updateBaseRate()
function
#142
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/Plex-Engineer/lending-market-v2/blob/443a8c0fed3c5018e95f3881a31b81a555c42b2d/contracts/NoteInterest.sol#L145-L147
Vulnerability details
Impact
When casting to
int
fromuint
, the overflow might happen.Proof of Concept
https://github.com/Plex-Engineer/lending-market-v2/blob/443a8c0fed3c5018e95f3881a31b81a555c42b2d/contracts/NoteInterest.sol#L145-L147
int(twapMantissa)
can overflow depending on the value ofuint twapMantissa
. Even if this is not expected, handling this case should be good.Tools Used
Static analysis
Recommended Mitigation Steps
Consider using the logic of
toInt256
provided by OpenZeppelin.https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol#L1130-L1134
The text was updated successfully, but these errors were encountered: