Issue with totalSupplyAvg value calculation #134
Labels
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
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/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L260-L269
Vulnerability details
Impact
BaseV1-core.sol#L260
totalSupplyAvg
may not provide the average value whengranularity
is lesser than or greater(too away from median value) than the total number of_totalSupplyAvg
Proof of Concept
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L260-L269
In above code the average is computed based on
granularity
but thiegranularity
can be a value which is too far away from the median value.say, it could be too away from
_totalSupplyAvg.length
Tools Used
VS code and Manual code review
Recommended Mitigation Steps
It is suggested to calculate the average value based on
_totalSupplyAvg.length
totalSupplyCumulativeAvg / _totalSupplyAvg.length
The text was updated successfully, but these errors were encountered: