Putty contest - 0x52's results

An order-book based american options market for NFTs and ERC20s.

General Information

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

Putty

Findings Distribution

Researcher Performance

Rank: 25/133

Findings: 2

Award: $631.05

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Findings Information

🌟 Selected for report: zishansami

Also found by: 0x52, 0xsanson, auditor0517, berndartmueller, csanuragjain, zzzitron

Labels

bug
duplicate
3 (High Risk)

Awards

583.9233 USDC - $583.92

External Links

Lines of code

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L284

Vulnerability details

Impact

Unfair and inconsistent fees

Proof of Concept

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L451.

When exercising a put option, the full order.strike is transferred to the exerciser in L451. No fee is taken at any point during fillOrder and no fee is taken here meaning that not fee is taken at all on exercised put options.

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L495-L506

Additionally when an expired unexercised put is withdrawn (i.e. !order.isCall && !isExercised) a fee is taken in L503. This is exact opposite of when the fee is intended to be taken.

Tools Used

L498 should be changed to:

if (fee > 0 && !isExercised)

L451 should be replaced with:

uint256 feeAmount = 0; if (fee > 0) { feeAmount = (order.strike * fee) / 1000; ERC20(order.baseAsset).safeTransfer(owner(), feeAmount); }

ERC20(order.baseAsset).safeTransfer(msg.sender, order.strike - feeAmount);

#0 - outdoteth

2022-07-06T18:23:48Z

Duplicate: Fees are only applied on puts if they are expired: https://github.com/code-423n4/2022-06-putty-findings/issues/269

Lines of code

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L284

Vulnerability details

Impact

Transaction reverts due to out of gas error because whitelist is too long

Proof of Concept

L670 simply loops through the entire list of whitelisted addresses until it matches msg.sender. If list is long and msg.sender is further down on the list, out of gas errors could easily happen. Additionally this could be use maliciously on counter offers to cause other user high gas fees.

Tools Used

Require the length of the whitelist to be less than some max length (i.e. 64) when calling fillOrder()

require(order.whitelist.length < 64)

#0 - outdoteth

2022-07-07T14:08:00Z

Any out of gas error here will show up in the user's wallet as an error. This will prevent them from wasting gas and submitting the tx to get a revert on chain. Technically this is a valid finding, but think it should be marked as low severity.

#1 - HickupHH3

2022-07-13T07:12:52Z

there's control over the whitelist off-chain. it can therefore be enforced to be of reasonable length or trimmed if necessary. non-crit IMO.

warden has no QA report, this issue will be the primary

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter