Putty contest - hubble'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: 14/133

Findings: 3

Award: $1,317.61

🌟 Selected for report: 1

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: berndartmueller

Also found by: Lambda, Metatron, hubble, swit

Labels

bug
duplicate
2 (Med Risk)
old-submission-method

Awards

227.0813 USDC - $227.08

External Links

Lines of code

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

Vulnerability details

Fees is calculated and sent only in the condition if put is expired or call is exercised No fees sent in either withdraw() or exercise() in condition if put is exercised or call is expired.

Impact

Loss of fees

Calculate similar fees and send

#0 - outdoteth

2022-07-06T18:25:01Z

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

#1 - HickupHH3

2022-07-11T03:11:20Z

dup of #285

Findings Information

🌟 Selected for report: hubble

Labels

bug
2 (Med Risk)
resolved
sponsor confirmed
old-submission-method

Awards

1038.3233 USDC - $1,038.32

External Links

Lines of code

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

Vulnerability details

The solidity version 0.8.13 has below two issues applicable to PuttyV2

  1. Vulnerability related to ABI-encoding. ref : https://blog.soliditylang.org/2022/05/18/solidity-0.8.14-release-announcement/ This vulnerability can be misused since the function hashOrder() and hashOppositeOrder() has applicable conditions. "...pass a nested array directly to another external function call or use abi.encode on it."

  2. Vulnerability related to 'Optimizer Bug Regarding Memory Side Effects of Inline Assembly' ref : https://blog.soliditylang.org/2022/06/15/solidity-0.8.15-release-announcement/ PuttyV2 inherits solidity contracts from openzeppelin and solmate, and both these uses inline assembly, and optimization is enabled while compiling.

Use recent Solidity version 0.8.15 which has the fix for these issues

#0 - outdoteth

2022-07-06T19:34:21Z

great catch.

#1 - outdoteth

2022-07-08T13:34:07Z

Report: Use of solidity 0.8.13 with known issues in ABI encoding and memory side effects

#2 - outdoteth

2022-07-15T10:34:29Z

Summary of Findings for Low / Non-Critical issues

  • L-01 : pause and unpause functionality missing
  • L-02 : In exercise(), the positionExpirations[] check should be inclusive of block.timestamp
  • L-03 : In fillOrder(), the order.expiration check should be inclusive of block.timestamp
  • L-04 : Possibility of losing control of PuttyV2 contract via renounceOwnership()
  • L-05 : Possibility of losing control of PuttyV2 contract via transferOwnership()
  • L-06 : Return value during transfer of premium to order.maker not checked when weth used

Details L-01

Title : pause and unpause functionality missing

The PuttyV2 contract will hold good amount of TVL (Weth, ERC20's and ERC721's balances).

Impact

In case of any eventuality, there may be a requirement to freeze some of the operations of the protocol. Hence a pause and unpause mechanism will help during that period.

Incorporate or import the relevant library to pause/unpause few external functions.

Details L-02

Title : In exercise(), the positionExpirations[] check should be inclusive of block.timestamp

In the function exercise(),

line#401 require(block.timestamp < positionExpirations[uint256(orderHash)], "Position has expired"); The check for positionExpirations should ideally include the block.timestamp as an edge case.

The reason is that in withdraw() function, the block.timestamp is exclusive

line#481 require(block.timestamp > positionExpirations[longPositionId] || isExercised, "Must be exercised or expired");

line#401 require(block.timestamp <= positionExpirations[uint256(orderHash)], "Position has expired");

Details L-03

Title : In fillOrder(), the order.expiration check should be inclusive of block.timestamp

In the function fillOrder(),

line#290 require(block.timestamp < order.expiration, "Order has expired"); The check for order.expiration should ideally include the block.timestamp as an edge case.

line#290 require(block.timestamp <= order.expiration, "Order has expired");

Details L-04

Title : Possibility of losing control of PuttyV2 contract via renounceOwnership()

In PuttyV2.sol the PuttyV2 contract inherits Ownable, which has the function renounceOwnership() If by mistake or maliciously the renounceOwnership() is called, there is a possibility of losing control on the PuttyV2 contract.

Override this renounceOwnership() function in PuttyV2.sol by making it a no-op.

Details L-05

Title : Possibility of losing control of PuttyV2 contract via transferOwnership()

In PuttyV2.sol the PuttyV2 contract inherits Ownable, which has the function transferOwnership() which only checks for null address. If by mistake a wrong address is used in transferOwnership(), then there is a possibility of losing control on the PuttyV2 contract.

Best practice is to use two step process to transfer ownership 1st Step : setNewOwner << setting/proposing the address of the new Owner 2nd Step : acceptOwnership << the new Owner will execute this function to complete the ownership transfer

Details L-06

Title : Return value during transfer of premium to order.maker not checked when weth used

In fillOrder() , the return value during transfer of premium to order.maker is not checked when weth is used.

line#336 IWETH(weth).transfer(order.maker, msg.value);

In case of any failure in this line, the fillOrder will still succeed.

Store the return value and check if success.

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