Open c4-bot-10 opened 11 months ago
0xleastwood marked the issue as primary issue
I think this would be an unavoidable behavior. Swapping using the liquidity from the same pool indeed should pay the swap fee. Regarding "maliciously" providing swapping liquidity and lending liquidity and be the liquidator at the same time, then users might not want to interact with such pools since it's too centralized. As long as there are other liquidity providers in the play, doing manipulation will pay the price for benefitting other LPs. As long as there's enough LPs, manipulation won't have enough incentive.
wukong-particle (sponsor) acknowledged
0xleastwood marked the issue as selected for report
Not sure this is an issue, whether to include or not the same pool in the path taken by the dex aggregator doesn't cause any real issue, those are fees after all and should be factored in the logic, and in any case these should be low amounts since it's a fee from a single trade.
I guess it is unclear how to fix this as there are already safety checks to ensure a liquidation returns sufficient capital to repay LPs. This seems to be more of an issue of skimming funds by forcing the borrower to pay more fees which is another issue altogether. But the warden has not highlighted this and is more focused on the swaps itself. I think this makes sense to be QA for these reasons.
0xleastwood marked the issue as not selected for report
0xleastwood changed the severity to QA (Quality Assurance)
0xleastwood marked the issue as grade-a
Lines of code
https://github.com/code-423n4/2023-12-particle/blob/main/contracts/protocol/ParticlePositionManager.sol#L208-L215 https://github.com/code-423n4/2023-12-particle/blob/main/contracts/protocol/ParticlePositionManager.sol#L399-L406
Vulnerability details
Impact
When traders open or close a position using LPs' Uniswap V3 position within the active range, they can utilize the same Uniswap V3 pool where LPs provide liquidity. This means while the swap operation already charge traders fee, the fee growth caused by the open or close position swap also increase fee growth that will be charged again to the trader.
The more severe scenario occurs when the LP inside Particle acts as a liquidator, intentionally providing the same Uniswap V3 pool for the swap operation. This results in higher fee growth and tokens owed to them.
Proof of Concept
It can be observed that inside
openPosition
and_closePosition
, users can provide the pool they want to use for swapping.https://github.com/code-423n4/2023-12-particle/blob/main/contracts/protocol/ParticlePositionManager.sol#L208-L215
https://github.com/code-423n4/2023-12-particle/blob/main/contracts/protocol/ParticlePositionManager.sol#L399-L406
As previously mentioned, If the LP Uni V3 position is withing active range, the LP provider can intentionally use the same pool to increase the fee growth and token owed for them when liquidating a position. And traders will pay fee more than it should.
Tools Used
Manual review
Recommended Mitigation Steps
Seems there is no obvious way to solve the issue inside
openPosition
. But for_closePosition
, move query forcache.feeGrowthInside0LastX128
andcache.feeGrowthInside1LastX128
before the swap is performed.Assessed type
Context