An order maker might steal premium from the sender by setting order.strike = 0. #216
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate
This issue or pull request already exists
Lines of code
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L436
Vulnerability details
Impact
An order maker might steal premium from the sender by setting order.strike = 0.
It's known that some ERC20 tokens don't allow 0 transfer and it will revert when the order sender tries to exercise his long position.
So the order maker will receive back his tokens after the order is expired.
Proof of Concept
As we can see here, some tokens don't allow 0 transfer. Let's call the token TOK and assume 1 TOK = 1 USDC.
And I can't find a restriction on that order.strike must be positive and I think it would be possible to create an order that has a positive premium and zero strikes.
premium = 5000 TOK, strike = 0 TOK, ERC20 token = 10000 USDC
Tools Used
Solidity Visual Developer of VSCode
Recommended Mitigation Steps
We should check order.strike != 0 before transfer.
Modification for L436.
In the fillOrder() function, there are similar transfers here and here, but there will be no loss of funds because the order won't be filled anyway.
The text was updated successfully, but these errors were encountered: