Closed sherlock-admin closed 7 months ago
3 comment(s) were left on this issue during the judging contest.
tsvetanovv commented:
Ivalid. This is a user mistake and is invalid according to Sherlock rules
PNS commented:
User input validation: User input validation to prevent user mistakes is not considered a valid issue.
0xAadi commented:
Invalid: The user should accept the effect of using fillThreshold as zero, the protocol allow fillThreshold as zero
trauki
medium
Medium -
fillThreshold
can be 0Summary
When swappers submit their order, they can specify a
fillThreshold
value which is the minimum amount of input tokens they will accept for the order to be filled. This value is never checked meaning swappers can submit orders with 0 asfillThreshold
.Vulnerability Detail
Fillers can fill these types of orders with a trival amount of input tokens.
Impact
Swappers who input
fillThreshold
as 0 can have their orders filled with a minuscule amount of tokens, forcing the swapper to submit a new order to swap anything, which can result in loss of the benefit from making a trade at a certain price/time.In this modified test, a swapper has an order to swap 100e18 tokens of
tokenIn
for 200e18 tokens oftokenOut
. Since thefillThreshold
was never correctly given a value, our filler partially fills the order with a single WEI oftokenIn
. This swap successfully executes and the swapper trades 1 WEI oftokenIn
for 2 WEI oftokenOut
.Obviously, this amount is frivolous and the order might as well have been canceled, but since it was successfully executed, the swapper could be under the impression that their order was filled correctly and they could believe they hold a position in the
tokenOut
(until they check their actual balance).Example of swapper being negatively affected like this:
tokenIn
balance is less than her original balance).tokenOut
balance has increased.tokenOut
only to realize her position in this asset is insignificant.This could mean that Alice lost money by her original position losing value, or lost out on a profitable trade if the token she wanted to swap for increased in value.
Even if Alice realized her mistake and sent in a new order with a reasonable
fillThreshold
or canceled her order, the original order could still be executed.Code Snippet
Tool used
Manual Review
Recommendation
Add a conditional check to ensure the
fillThreshold
is non-zero:or that it is greater than a certain minimum amount such as 1% of the original order amount: