Open code423n4 opened 2 years ago
Why would the caller send ETH when they don't have to?
User error is one possibility.
Report: Native ETH can be lost if it’s not utilised in exercise and fillOrder
PR with fix: https://github.com/outdoteth/putty-v2/pull/5
Lines of code
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L324 https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L338 https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L436
Vulnerability details
Impact
fillOrder()
andexercise()
have code paths that require Ether to be sent to them (e.g. using WETH as the base asset, or the provision of the exercise price), and therefore those two functions have thepayable
modifier. However, there are code paths within those functions that do not require Ether. Ether passed to the functions, when the non-Ether code paths are taken, is locked in the contract forever, and the sender gets nothing extra in return for it.Proof of Concept
Ether can't be pulled from the
order.maker
during the filling of a long order, somsg.value
shouldn't be provided here:https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L323-L325
If the
baseAsset
isn't WETH during order fulfillment,msg.value
is unused:https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L337-L339
Same for the exercise of call options:
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L435-L437
Tools Used
Code inspection
Recommended Mitigation Steps
Add a
require(0 == msg.value)
for the above three conditions