Minter.sol#startInflation()
can be bypassed
#99
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
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-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L104-L108
Vulnerability details
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L104-L108
As
lastEvent
andlastInflationDecay
are not initialized in theconstructor()
, they will remain to the default value of0
.However, the permissionless
executeInflationRateUpdate()
method does not check the value oflastEvent
andlastInflationDecay
and used them directly.As a result, if
executeInflationRateUpdate()
is called beforestartInflation()
:_INFLATION_DECAY_PERIOD
has passed sincelastInflationDecay
will betrue
, andinitialPeriodEnded
will be set totrue
right away;lastEvent
intotalAvailableToNow += (currentTotalInflation * (block.timestamp - lastEvent));
is0
, thetotalAvailableToNow
will be set tototalAvailableToNow ≈ currentTotalInflation * 52 years
, which renders the constrains oftotalAvailableToNow
incorrect and useless.https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L115-L117
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L187-L215
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L50-L51
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L217-L227
Recommendation
Consider initializing
lastEvent
,lastInflationDecay
inconstructor()
.or
Consider adding
require(lastEvent != 0 && lastInflationDecay != 0, "...")
toexecuteInflationRateUpdate()
.The text was updated successfully, but these errors were encountered: