Platform: Code4rena
Start Date: 08/03/2023
Pot Size: $60,500 USDC
Total HM: 2
Participants: 123
Period: 7 days
Judge: hansfriese
Id: 220
League: ETH
Rank: 29/123
Findings: 2
Award: $184.41
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: rokso
Also found by: 0x52, 0xnev, ABA, BPZ, DadeKuma, Haipls, J4de, Jeiwan, Josiah, Krace, LegendFenGuin, Lirios, MadWookie, RaymondFam, Ruhum, Toshii, UdarTeam, aashar, ak1, anodaram, auditor0517, carlitox477, cccz, jekapi, juancito, kaden, kenzo, minhquanym, nobody2018, rbserver, rokso, ulqiorra
154.74 USDC - $154.74
An attacker may artificially inflate their points as much as they like by exploiting a loss of precision.
In _withdrawLP()
, there exists logic to check how many points to decrement the users LP pool position by, according to the amount they took out and the multiplier they had applied.
// _withdrawLP() - NeoTokyoStaker.sol:L1623-1627 uint256 points = amount * 100 / 1e18 * lpPosition.multiplier / _DIVISOR; ... lpPosition.points -= points;
The problem however with this logic is that there is a loss of precision in calculating the points such that if the amount is less than 1e16, points
will be 0.
This allows the following attack to take place:
Based on the maximum size of withdrawals for this attack to function, <0.01 LP tokens, it may seem unlikely to be possible. However, a very small number of LP tokens may correspond to a very valuable position. Take for example this transaction displaying a deposit of ~$7k in liquidity to the Uniswap v2 USDT/WETH pool, obtaining only ~0.000037 LP tokens. It's also important to consider other ways in which this attack may be possible, e.g. if the LP token has less than 18 decimals.
Therefore, it is easily possible for an attacker to significantly manipulate their points
in the LP token pool such that they earn a significant portion, or even the entirety, of the rewards assigned to the pool.
It may be necessary to reconfigure points
to be normalized to 18 decimal places throughout the protocol such that precision isn't lost.
#0 - c4-judge
2023-03-16T05:20:16Z
hansfriese marked the issue as satisfactory
#1 - c4-judge
2023-03-16T05:20:45Z
hansfriese marked the issue as duplicate of #348
#2 - c4-judge
2023-03-21T09:19:31Z
hansfriese marked the issue as duplicate of #261