Platform: Code4rena
Start Date: 29/06/2022
Pot Size: $50,000 USDC
Total HM: 20
Participants: 133
Period: 5 days
Judge: hickuphh3
Total Solo HM: 1
Id: 142
League: ETH
Rank: 99/133
Findings: 1
Award: $41.89
π Selected for report: 0
π Solo Findings: 0
π Selected for report: kirk-baird
Also found by: 0xA5DF, Kenshin, cccz, chatch, csanuragjain, hansfriese, hyh, itsmeSTYJ, pedroais, sashik_eth, unforgiven, xiaoming90
41.8933 USDC - $41.89
https://github.com/code-423n4/2022-06-putty/blob/1ddbec4a5242e0160da832cb46b2b3cdbb49a8af/contracts/src/PuttyV2.sol#L324 https://github.com/code-423n4/2022-06-putty/blob/1ddbec4a5242e0160da832cb46b2b3cdbb49a8af/contracts/src/PuttyV2.sol#L344
Avoid premium payment on long call or long put. Avoid strike payment on short put.
NOTE: this would not be possible if the order was created using the official DApp which has a drop down selector that restricts the base asset ("base token" in the dapp) to the official DAI or WETH tokens.
However for users interacting with the protocol by some other means - a different dapp or an API this would be possible if the maker could convince the taker they are using DAI for example, but actually provide some other fake DAI token as Order.baseAsset.
Premium is transferred from maker to taker for longs here: https://github.com/code-423n4/2022-06-putty/blob/1ddbec4a5242e0160da832cb46b2b3cdbb49a8af/contracts/src/PuttyV2.sol#L324 Strike is transferred from maker to contract for short puts here: https://github.com/code-423n4/2022-06-putty/blob/1ddbec4a5242e0160da832cb46b2b3cdbb49a8af/contracts/src/PuttyV2.sol#L344
However no validation is done on the baseAsset except to check that it is an address with bytecode: require(order.baseAsset.code.length > 0, "baseAsset is not contract");
.
Manual analysis.
Maintain a Whitelist of allowed baseAssets in the PuttyV2 contract.
Replace the check order.baseAsset.code.length > 0
with something like baseAssetWhitelist[order.baseAsset] == true
.
This would mitigate this issue by ensuring the baseAsset is a known and verified token.
The initial whitelist would contain the addresses for the tokens listed in the DApp UI - DAI and WETH.
#0 - GalloDaSballo
2022-07-05T01:28:22Z
Orders can be created with any token, why would the counterparty agree to be paid in a fake token?
#1 - outdoteth
2022-07-07T13:35:15Z
Duplicate: Setting malicious or invalid erc721Assets, erc20Assets or floorTokens prevents the option from being exercised: https://github.com/code-423n4/2022-06-putty-findings/issues/50