Open code423n4 opened 2 years ago
Please ignore the // @audit
annotations in the first code snippet (I forgot to remove them). Thanks!
Duplicate: Fees are only applied on puts if they are expired: https://github.com/code-423n4/2022-06-putty-findings/issues/269
Making this the primary issue for the med severity issue, as per my comment in #269
PR with fix: https://github.com/outdoteth/putty-v2/pull/4
Lines of code
https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L450-L451
Vulnerability details
Impact
Fees are expected to be paid whenever an option is exercised (as per the function comment on L235).
Put options
If a put option is exercised, the exerciser receives the strike price (initially deposited by the short position holder) denominated in
order.baseAsset
.Call options
If a call option is exercised, the exerciser sends the strike price to Putty and the short position holder is able to withdraw the strike amount.
However, the current protocol implementation is missing to deduct fees for exercised put options. Put options are free of any fees.
Proof of Concept
The protocol fee is correctly charged for exercised calls:
PuttyV2.withdraw
Contrary, put options are free of any fees:
PuttyV2.sol#L450-L451
Tools Used
Manual review
Recommended mitigation steps
Charge fees also for exercised put options.