Submitted by unforgiven, also found by GreyArt
Functions matchOneToOneOrders(), matchOneToManyOrders(), matchOrders(), takeMultipleOneOrders(), takeOrders() are for order matching and order execution and they validate different things about orders but there is no check for that seller != buyer, which can cause wrong order matching resulting in fund lose or fund theft or griefing. (it can be combined with other vulns to perform more damaging attacks)
We only give proof of concept for matchOneToManyOrders() and other order execution/matching functions has similar bugs which root cause is not checking seller != buyer.
This is matchOneToManyOrders() code:
in its executions it calls InfinityOrderBookComplication.canExecMatchOneToMany(), verifyMatchOneToManyOrders(), isOrderValid() to see that if orders are valid and one order matched to all other orders but there is no check for seller != buyer in any of those functions. and also ERC721 and ERC20 allows funds and assets to be transferred from address to itself.
So its possible for matchOneToManyOrders() to match one user sell orders to its buy orders which can cause fund theft or griefing. This is the scenario for fund lose in matchOneToManyOrders():
Of course for this attack to work for matchOneToManyOrders() off-chain matching engine need to send wrong data but checks on the contract are not enough.
There are other scenarios for other functions that can cause griefing, for example for function matchOrders():
a user can have multiple order to buy some tokens in list of ids. its possible to match these old orders:
There may be other scenarios for this vulnerability to be harmful for users.
VIM
Add some checks to ensure that seller != buyer
nneverlander (Infinity) confirmed and resolved:
HardlyDifficult (judge) decreased severity to Medium and commented:
