No slippage Protecting while adding liquidity to the pool #535
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-260
grade-c
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L198-L199
Vulnerability details
Impact
The presence of the front-running vulnerability in the
claimFee()
function can have significant repercussions for users. Exploiting this vulnerability enables malicious actors to prioritize their transactions, potentially leading to unfavorable prices for other users. Consequently, users who initially submitted their transactions may end up receiving worse prices than they anticipated. This can result in financial losses.Proof of Concept
The
claimFee()
function in the TokenisableRange.sol code is responsible for claiming fee. However, it suffers from a front-running vulnerability due to the inadequate specification of minimum token amounts (amount0Min and amount1Min).When the amount0Min and amount1Min parameters are both set to 0, the code allows any amount of token0 and token1 to be accepted during the fee claiming process. This lack of minimum token amount validation creates an opportunity for attackers to manipulate the transaction and impact the price received by the victim.
Malicious users can monitor pending transactions and quickly execute their own transaction with higher fees, effectively "sandwiching" the original transaction. By manipulating the price, the attacker can cause the original transaction to receive unfavorable rates, resulting in financial harm to the user.
In the below instances, a call to Uniswap V3 is made and
amount0Min
andamount1Min
are each set to 0, which allows for 100% slippage tolerance. This means that the action could lead to the caller losing up to 100% of their tokens due to slippage.Tools Used
Manual review
Recommended Mitigation Steps
Implement it like you have done in
withdraw()
function (take if as input from user)Assessed type
Uniswap
The text was updated successfully, but these errors were encountered: