Closed code423n4 closed 2 years ago
Why would the counter-party accept a 10 seconds or 5 minutes contract unless they wanted to buy it?
Duplicate: Orders with low durations can be easily DOS’d and prevent possibility of exercise: https://github.com/code-423n4/2022-06-putty-findings/issues/265
Lines of code
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L268
Vulnerability details
Proof-of-Concept
The
PuttyV2.fillOrder
function will validate that the order duration is less than 10,000 days. However, it does not check that order duration is equal tozero
. Thus, it is possible for a malicious order maker to create an order withorder.duration
equal tozero
. This will cause the order to expired immediately after being filled by a taker.https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L268
An attacker (Alice) could perform the following:
order.duration
set tozero
.Impact
The order taker (victim) would lost their funds as they paid for an option that cannot be exercised because the option expired immediately after being bought.
Recommended Mitigation Steps
It is recommended to implement additional validation to ensure that the
order.duration
is notzero
or set to short period of time (e.g. 5 minute).An option that expires immediately or expires within a short period of time (e.g. 10 seconds or 5 minutes) does not have much value, and thus it should not be allowed within Putty. Order makers who create such orders are likely to be malicious user who exploits this flexibility to 'trick' or 'fish' the users into filling their order to obtain the premium, thus causing harm to the community.