Open c4-bot-9 opened 10 months ago
raymondfam marked the issue as sufficient quality report
raymondfam marked the issue as duplicate of #26
raymondfam marked the issue as not a duplicate
raymondfam marked the issue as primary issue
this is intended and a consequence of how the VRGDA functions, when people buy tokens the price goes up if it is ahead of schedule
not ideal UX, but not going to fix for now
rocketman-21 (sponsor) acknowledged
Even though the increasing price is intended, it's state of the art to introduce a slippage parameter to protect users from receiving less than expected. Therefore, maintaining Medium
severity seems appropriate.
MarioPoneder marked the issue as satisfactory
MarioPoneder marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/ERC20TokenEmitter.sol#L152-L230
Vulnerability details
Impact
Users can buy NontransferableERC20Token by calling
buyToken
function directly. At that time, the expected amount of tokens they will receive is determined based on current supply and their paying ether amount. But, due to some transactions(such as settleAuction or another user's buyToken) which is running in front of caller's transaction, they can get less token than they expected.Proof of Concept
The VRGDAC always exponentially increase the price of tokens if the supply is ahead of schedule. Therefore, if another transaction of buying token is frontrun against a user's buying token transaction, the token price can arise than expected.
For instance, let's assume that ERC20TokenEmitter is initialized with following params:
To avoid complexity, we will assume that the supply of token so far is consistent with the schedule. When alice tries to buy token with
5 ether
, expected amount is calculated bygetTokenQuoteForEther(5 ether)
and the value is about4.87 ether
. However, if Bob's transaction to buy tokens with10 ether
is executed before Alice, the real amount which Alice will receive is about4.43 ether
.You can check result through following test:
Therefore, Alice will get about
0.44 ether
less tokens than expected since there is no any checking of slippage inbuyToken
function.Tools Used
VS Code
Recommended Mitigation Steps
Add slippage checking to
buyToken
function. This slippage checking should be executed only when the user callsbuyToken
function directly. In other words, it should not be executed when settleAuction callsbuyToken
function.Assessed type
Other