Submitted by kirk-baird, also found by csanuragjain, hansfriese, Lambda, and minhquanym
When a user is attempting to accept a counter offer they call the function acceptCounterOffer() with both the originalOrder to be cancelled and the new order to fill. It is possible for an attacker (or any other user who happens to call fillOrder() at the same time) to fill the originalOrder before acceptCounterOffer() cancels it.
The impact is that both originalOrder and order are filled. The msg.sender of acceptCounterOffer() is twice as leveraged as they intended to be if the required token transfers succeed.
acceptCounterOffer() calls cancel() on the original order, however it will not revert if the order has already been filled.
cancel() does not revert if an order has already been filled it only prevents future fillOrder() transactions from succeeding.
Therefore any user may front-run the acceptCounterOffer() transaction with a fillOrder() transaction that fills the original order. As a result the user ends up filling both order and originalOrder. Then acceptCounterOffer() cancels the originalOrder which is essentially a no-op since its been filled and continues to fill the new order resulting in both orders being filled.
Consider having cancel() revert if an order has already been filled. This can be done by adding the following line require(_ownerOf[uint256(orderHash)] == 0).
outdoteth (Putty Finance) confirmed and commented:
outdoteth (Putty Finance) resolved:
hyh (warden) reviewed mitigation:
