code-423n4 / 2022-05-backd-findings

0 stars 0 forks source link

Any user can start inflation for Minter.sol #162

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L187-L215

Vulnerability details

Submitting as a high risk bug because it is equivalent to calling startInflation() which is a function reserved for only governance to call and it drastically alters token distribution

Impact

Bypass governance only call restriction and cause immediate inflation decay

Proof of Concept

The two main functions of startInflation() is to set lastEvent and lastInflationDecay to block.timestamp. startInflation() is restricted to allow governance to start inflation when it chooses. However these values can be set to block.timestamp by any user that calls executeInflationRateUpdate() because that function is not restricted to only governance. This allows any user to start inflation whenever they want. executeInflationRateUpdate() calls _executeInflationRateUpdate which sets lastEvent = block.timestamp in L189:

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L189

it also sets lastInflationDecay = block.timestamp in L212:

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L212

Additionally inflation decay will be immediately applied because L190 will return true because lastInflationDecay will still be at the default value of 0:

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L190

Tools Used

Recommended Mitigation Steps

Add same lastEvent check as other functions in the contract

function executeInflationRateUpdate() external override returns (bool) { if (lastEvent == 0) return 0; return _executeInflationRateUpdate(); }

chase-manning commented 2 years ago

duplicate of #99

GalloDaSballo commented 2 years ago

Dup of #99