Having no clear path to define totalLpPoolWeight
and initially set totalLpPoolWeight
to zero maybe problematic for the protocol
#67
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 disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/LpGauge.sol#L111
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/InflationManager.sol#L581
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/InflationManager.sol#L588
Vulnerability details
For
totalLpPoolWeight
to have some values, someone need to callInflationManager.executeLpPoolWeight
. During the execution process,totalLpPoolWeight
will need to go throughtotalLpPoolWeight = totalLpPoolWeight - currentUInts256[key] + pendingUInts256[key];
which can be problematic because the initial value oftotalLpPoolWeight
is zero that requires subtraction fromcurrentUInts256[key]
which I also have no information about the value but I assume that the value should not be absurdly high.Since uint256 does not support negative value, the subtraction between these two variables would result in an underflow which will prompt error in solidity 0.8.0. However, the contract imports
UnceckMath
library, enable underflow possible. Therefore, the subtraction oftotalLpPoolWeight - currentUInts256[key]
can be restated astype(uint256).max - currentUInts256[key]
. This produces an absurdly hightotalLpPoolWeight
which may affectcurrentRate
of the pool causing it to likely be zero.Still I am not sure if this is intended by the dev because I am not sure about the value of
currentUInts256[key]
andpendingUInts256[key]
. If these two are high enough to matchtotalLpPoolWeight
, it could bringcurrentRate
to be in a reasonable level.Proof Of Concepts
*
totalLpPoolWeight
should initially be zero.The text was updated successfully, but these errors were encountered: