Closed c4-bot-6 closed 11 months ago
raymondfam marked the issue as insufficient quality report
raymondfam marked the issue as duplicate of #404
MarioPoneder marked the issue as unsatisfactory: Invalid
MarioPoneder changed the severity to QA (Quality Assurance)
MarioPoneder marked the issue as grade-c
Hi @MarioPoneder,
This issue is marked as a duplicate of 404 which indicates frontrunning effect on the governance token price, while this issue is not a duplicate; it doesn't share the root cause of the primary issue!
The price of the governance token should never reach zero, this is an invariant that shouldn't be broken at any case or circumstances, but the issue clarifies that this invariant will be broken in some cases.
This issue is more of a duplicate of issue #371
I kindly ask you to take a second look and re-evaluate this issue,
Thanks!
Thank you for your comment!
I partially agree. However, the price running down to 0 in case of no buy pressure over a long period of time itself is intended behavior and not breaking any invariant.
The core issue is that a 0 price will DoS the ERC20TokenEmitter
contract which was not stated in this report.
Hi @MarioPoneder ,,
testGetTokenPrice
that is wriiten by the protocol team to check that the price would never reach zero:function testGetTokenPrice() public {
vm.startPrank(address(0));
vm.deal(address(0), 100000 ether);
vm.stopPrank();
int256 priceAfterManyPurchases = erc20TokenEmitter.buyTokenQuote(1e18);
emit log_int(priceAfterManyPurchases);
// Simulate the passage of time
uint256 daysElapsed = 221;
vm.warp(block.timestamp + daysElapsed * 1 days);
int256 priceAfterManyDays = erc20TokenEmitter.buyTokenQuote(1e18);
emit log_int(priceAfterManyDays);
// Assert that the price is greater than zero
assertGt(priceAfterManyDays, 0, "Price should never hit zero");
}
and this issue shows a case in which the price would reach zero.
Also the root cause of this issue and issue 371 is that the vrgdac.xToY
that's called when buyTokenQuote
is invoked is malfunctioned and would result in:
ERC20TokenEmitter
contract (as stated in issue 371).buyTokenQuote
, and issue 371 pointed to the other effect on the protocol (both issues sharing the same root cause).Would appreciate it if you could have a second look and re-evaluate it!
Thanks again for your time and consideration,,
Thank you for your comment!
I acknowlege that 0 price should not be reached after your proof. However, the subsequential DoS scenario was not stated in the original report which would make it eligible for duplication to #371. Therefore, QA still seems most appropriate.
Thank you for your understanding!
Lines of code
https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/ERC20TokenEmitter.sol#L232-L247
Vulnerability details
Impact
The price of governance tokens is controlled by the demand (sold tokens) whether it being ahead of scheduled rate or behind it; where the scheduled rate is the number of tokens to be sold per day, and if the amount of sold tokens per day is greater than this rate; then the price will be increased, and if the amount of sold tokens per day is less than the rate limit; then the price will be decreased to encourage users to buy the token while the price will never reach zero .
But it was noticed that after some time passing without any token put=rchase; the price will be dropped to reach zero, this will lead to user buying these governance tokes while paying the protocol fees only.
Proof of Concept
Code Instances:
ERC20TokenEmitter.buyTokenQuote function
Foundry PoC:
testTokenPriceReachesZero
fuzzing test inside theERC20TokenEmitterTest
test contract that resides in theERC20TokenEmitter.t.sol
test file which is located in the following directorypackages/revolution/test/token-emitter/ERC20TokenEmitter.t.sol
:Explained scenario:
Test result:
So as can be noticed from the test result above; the price will hit zero after 319 days with a total sold tokens of 1 ether and no purchases were made after that, note that the number of days where the token reaches zero depends on the total number of sold tokens (
emittedTokenWad
).Tools Used
Manual Review & Foundry.
Recommended Mitigation Steps
Update
vrgdac
related functions to prevent returning zero price, or implement a minimum price if it hits zero.Assessed type
Context