Minter.sol#startInflation() can be bypassed.
Submitted by WatchPug, also found by 0x52
function startInflation() external override onlyGovernance {
require(lastEvent == 0, "Inflation has already started.");
lastEvent = block.timestamp;
lastInflationDecay = block.timestamp;
}
As lastEvent and lastInflationDecay are not initialized in the constructor(), they will remain to the default value of 0.
However, the permissionless executeInflationRateUpdate() method does not check the value of lastEvent and lastInflationDecay and used them directly.
As a result, if executeInflationRateUpdate() is called before startInflation():
- L190, the check of if
_INFLATION_DECAY_PERIODhas passed sincelastInflationDecaywill betrue, andinitialPeriodEndedwill be set totrueright away; - L188, since the
lastEventintotalAvailableToNow += (currentTotalInflation * (block.timestamp - lastEvent));is0, thetotalAvailableToNowwill be set tototalAvailableToNow ≈ currentTotalInflation * 52 years, which renders the constrains oftotalAvailableToNowincorrect and useless.
function executeInflationRateUpdate() external override returns (bool) {
return _executeInflationRateUpdate();
}
function _executeInflationRateUpdate() internal returns (bool) {
totalAvailableToNow += (currentTotalInflation * (block.timestamp - lastEvent));
lastEvent = block.timestamp;
if (block.timestamp >= lastInflationDecay + _INFLATION_DECAY_PERIOD) {
currentInflationAmountLp = currentInflationAmountLp.scaledMul(annualInflationDecayLp);
if (initialPeriodEnded) {
currentInflationAmountKeeper = currentInflationAmountKeeper.scaledMul(
annualInflationDecayKeeper
);
currentInflationAmountAmm = currentInflationAmountAmm.scaledMul(
annualInflationDecayAmm
);
} else {
currentInflationAmountKeeper =
initialAnnualInflationRateKeeper /
_INFLATION_DECAY_PERIOD;
currentInflationAmountAmm = initialAnnualInflationRateAmm / _INFLATION_DECAY_PERIOD;
initialPeriodEnded = true;
}
currentTotalInflation =
currentInflationAmountLp +
currentInflationAmountKeeper +
currentInflationAmountAmm;
controller.inflationManager().checkpointAllGauges();
lastInflationDecay = block.timestamp;
}
return true;
}
// Used for final safety check to ensure inflation is not exceeded
uint256 public totalAvailableToNow;
function _mint(address beneficiary, uint256 amount) internal returns (bool) {
totalAvailableToNow += ((block.timestamp - lastEvent) * currentTotalInflation);
uint256 newTotalMintedToNow = totalMintedToNow + amount;
require(newTotalMintedToNow <= totalAvailableToNow, "Mintable amount exceeded");
totalMintedToNow = newTotalMintedToNow;
lastEvent = block.timestamp;
token.mint(beneficiary, amount);
_executeInflationRateUpdate();
emit TokensMinted(beneficiary, amount);
return true;
}
Recommendation
Consider initializing lastEvent, lastInflationDecay in constructor().
or
Consider adding require(lastEvent != 0 && lastInflationDecay != 0, "...") to executeInflationRateUpdate().
Alex the Entreprenerd (judge) commented:
The warden has shown how
startInflationcan be bypassed, breaking the Access Control as well as the Sponsor Goal for Emissions.Because of this I believe High Severity to be appropriate.
The sponsor has mitigated in a subsequent PR
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A high-severity business logic bug in Backd Tokenomics contest. Code4rena made it public on 19 July 2022. Found in the 2022-05-backd audit contest (finding H-01).
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.