Submitted by SpicyMeatball, also found by Kenshin, Brenzee, and Musaka
Malicious user can manipulate balances of the WETH/LBR pair and bypass this check:
https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/miner/EUSDMiningIncentives.sol#L203
Which allows them to steal rewards from a user who has staked enough LP and whose rewards shouldnt be claimable under normal circumstances.
EUSDMiningIncentives.sol is a staking contract which distributes rewards to users based on how much EUSD they have minted/borrowed. Rewards are accumulated over time and can be claimed only if a user has staked enough WETH/LBR uniswap pair LP tokens into another staking:
https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/miner/stakerewardV2pool.sol
This condition is checked here:
https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/miner/EUSDMiningIncentives.sol#L188
As we can see, stakedLBRLpValue of a user is calculated based on how much LP they have staked and the total cost of the tokens that are stored inside the WETH/LBR pair.
https://github.com/code-423n4/2023-06-lybra/blob/main/contracts/lybra/miner/EUSDMiningIncentives.sol#L151-L156
The total cost, however, is simply derived from the sum of the tokens balances, which we get with balanceOf(pair).
This can be exploited:
Custom test:
Forge. I forked the ETH mainnet at block 17592869. Also, the following mainnet contracts were used:
Use ethlbrLpToken.getReserves() instead of quoting balances directly with balanceOf
Uniswap
LybraFinance disputed and commented:
0xean (judge) decreased severity to Medium and commented:
LybraFinance acknowledged
