Open c4-bot-8 opened 10 months ago
raymondfam marked the issue as insufficient quality report
raymondfam marked the issue as primary issue
startTime == 0 would be true on the upgraded contract.
MarioPoneder changed the severity to QA (Quality Assurance)
@rocketman-21 Tagging for visibility.
Anyways, QA because affecting future contract implementation.
MarioPoneder marked the issue as grade-b
this is fair - appreciate the tag, implemented fix
Lines of code
https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/ERC20TokenEmitter.sol#L105 https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/ERC20TokenEmitter.sol#L271-L281
Vulnerability details
Impact
ERC20TokenEmitter
is an upgradeable contract where it can be initialized/upgraded by theRevolutionBuilder
contract, and when the contract is upgradeded; a new value for thestartTime
variable is set to equal the currentblock.timestamp
.startTime
value is used to calculate thetimeSinceStart
that is used to evaluate the price of the governance ERC20 token viaVRGDAC
contract, and this price starts low and increases if the emitted (bought) token amounts is high (higher demand than the amount set to be emitted per time unit which is set to be one day), and decreses if the demand is low (behind amount to be emitted per time unit which is set to be one day).So upgrading the contract will change the
startTime
, while theemittedTokenWad
value (which represents the amount of sold tokens) will be preserved, and this will result in rising the price of the token with each upgrade as the demand will be conceived to be high within a short time (asemittedTokenWad
doesn't represent the actual amount of tokens sold withinblock.timestamp - startTime
period).Proof of Concept
ERC20TokenEmitter.initialize function/L105
ERC20TokenEmitter.getTokenQuoteForPayment function
Tools Used
Manual Review.
Recommended Mitigation Steps
Preserve the previous value of
startTime
when re-initializing the contract:Assessed type
Context