sherlock-audit / 2024-01-looksrare-judging

3 stars 0 forks source link

unforgiven - user can deposit into the future rounds and fix the wrong price for the ERC20 and ERC721 tokens #161

Closed sherlock-admin closed 9 months ago

sherlock-admin commented 9 months ago

unforgiven

high

user can deposit into the future rounds and fix the wrong price for the ERC20 and ERC721 tokens

Summary

function deposit() allows users to deposit ERC20 and ERc721 tokens into any round they want. in the first token deposit code sets the ERC20 and ERC721 token price for that round. the issue is that attacker can deposit ERC20 and ERC721 into far feature rounds and fix very wrong price for those tokens. as result when contract reach those rounds the fixed prices will be very different than real token prices and it would create arbitrage opportunities and other ERC721 or ERC20 tokens may receive unfair risk/reward ratio.

Vulnerability Detail

function deposit() allows users to deposit ERC20 and ERc721 tokens into any round they want. in the first token deposit code sets the ERC20 and ERC721 token price for that round. this behavior is okey for current and near future rounds as the price won't change dramatically in short time but an attacker can fix the price for the far future rounds and for sure those price of tokens is gonna change until the contract reaches those rounds. this will have different impact:

  1. if price of ERC20 or ERC721 increase until reaching those rounds then no one would deposit ERC20 and ERC721 token into those rounds and attacker will be able to DOS those rounds.
  2. if price of ERC20 or ERC721 decrease until reaching those rounds then everyone will deposit ERC20 and ERC721 tokens into the rounds and ETH depositors would receive unfair reward/risk ratio.

this is POC:

  1. suppose ERC20 TOKEN1 price is having a pump and TOKEN1 is whitelisted.
  2. attacker can call deposit() for far future rounds that have ETH deposits and deposit TOKEN1 into them and fix a very high price for TOKEN1 in those rounds.
  3. after some time price of the TOKEN1 will get back to its normal levels.
  4. now attacker would convert his ETH into TOKEN1 and deposit his TOKEN1 into the future rounds that have wrong fix price. attacker would receive more entry point that his tokens value as the round fixed price is wrong.
  5. as result attacker was able to deposit TOKEN1 with very high price to those rounds and receive huge amount of entry points and have more chance to win over ETH depositors.

Impact

attacker can steal ETH depositors or DOS the future rounds.

Code Snippet

https://github.com/sherlock-audit/2024-01-looksrare/blob/7d76b96a58a6aee38f23bb38b8a5daa3bdc03f7c/contracts-yolo/contracts/YoloV2.sol#L1032-L1120

Tool used

Manual Review

Recommendation

don't allow deposits for far future.

Duplicate of #44