Closed code423n4 closed 2 years ago
Should be tagged as low severity imo. Spam orders are prevented at the db level already. The proposed onchain check does not solve the issue either because a user can still create orders with a premium of 1 wei or a strike of 1 wei which is almost the same as a 0 wei order.
Also note that options with a strike of 0 are valid orders with a use case.
Report: Possible to create spam orders with 0 strike and premium
As #418 mentioned, 0 strike options are a common derivative. Agree with sponsor that checking > 0
isn't sufficient as a sanity check. Maybe have a minimum premium amount depending on token, though this adds overhead.
Spam / DoS attacks also require gas to execute. Using ETH mainnet acts as a natural deterrence, but are more viable on L2s etc.
The front-end can choose to filter out such orders of dust amounts as well.
Hence, am downgrading the issue to QA.
Part of warden's QA report: #306
Lines of code
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L268
Vulnerability details
Proof-of-Concept
Based on the implementation of the
PuttyV2.fillOrder
, it was found that there is no validation to ensure that theorder.premium
andorder.strike
is notzero
. Thus, a griefer can create as many orders as they want in Putty.This will most likely pose problems on the front-end of the Putty protocol because there will be a ridiculously high number of "spam" orders displayed to actual users. This affects the usability of the protocol, and damage Putty's reputation. Malicious users could easily fill up the "Open Orders" and "Filled Orders" page of Putty Protocol. Malicious Users could easily fill up the "Open Order" and "Filled Order" pages in Putty.
Following are the only checks implemented in the
PuttyV2.fillOrder
. Note that it does not validate that theorder.premium
andorder.strike
is notzero
on-chain.https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L268
Attacker could perform the following:
order.strike
andorder.premium
set tozero
.PuttyV2.fillOrder
function.Impact
This affects the usability of the protocol, and damage Putty's reputation.
Recommended Mitigation Steps
It is recommended to add the following checks to ensure that the
order.strike
andorder.premium
is not equal to zeroAlthough client-side or off-chain might have already implemented such validations, simply relying on client-side and off-chain validations are not sufficient. It is possible for an attacker to bypass the client-side and off-chain validations and interact directly with the contract. Thus, such validation must also be implemented in the on-chain contracts.
Additionally, consider restricting the number of orders each user can create or introduce a time delay that user has to wait after creating a new order to reduce the impact of this issue.