_updateTwav()
and _getTwav()
will revert when cumulativePrice overflows
#246
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Lines of code
https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Twav/Twav.sol#L28
https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Twav/Twav.sol#L40
Vulnerability details
Impact
Contract will break when
cumulativeValuation
overflows.PoC
Cumulative prices are designed to work with overflows/underflows because in the end the difference is important.
In
_updateTwav()
when _prevCumulativeValuation + (_valuation *_timeElapsed)
overflows the contract will not work anymore.Same problem in
_getTwav()
Similar issues
code-423n4/2022-04-phuture-findings#62
Recommended
Add unchecked keyword in every line you add / subtract cumulative prices.
The text was updated successfully, but these errors were encountered: