Drips Protocol contest - SleepingBugs's results

An Ethereum protocol for streaming and splitting funds.

General Information

Platform: Code4rena

Start Date: 25/01/2023

Pot Size: $90,500 USDC

Total HM: 3

Participants: 26

Period: 9 days

Judge: GalloDaSballo

Id: 209

League: ETH

Drips Protocol

Findings Distribution

Researcher Performance

Rank: 26/26

Findings: 1

Award: $122.82

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

bug
grade-b
QA (Quality Assurance)
Q-01

Awards

122.8177 USDC - $122.82

External Links

Low

Missing checks for address(0x0) when assigning values to address state or immutable variables

NOTE: None of these findings where found by 4naly3er output - NC

Summary

Zero address should be checked for state variables, immutable variables. A zero address can lead into problems.

Code Snippet

Some constructor uses some OZ constructors, at them there is no check as can be seen at:

Recommendation

Check zero address before assigning or using it

block.timestamp used as time proxy

Summary

Risk of using block.timestamp for time should be considered.

Details

block.timestamp is not an ideal proxy for time because of issues with synchronization, miner manipulation and changing block times.

This kind of issue may affect the code allowing or reverting the code before the expected deadline, modifying the normal functioning or reverting sometimes.

References

SWC ID: 116

Code Snippet

Recommendation

  • Consider the risk of using block.timestamp as time proxy and evaluate if block numbers can be used as an approximation for the application logic. Both have risks that need to be factored in.
  • Consider using an oracle for precision

Destination recipient for assets may be address(0)

Description

The recipient of a transfer may be address(0), leading to lost assets.

Upgradeable contract is missing a __gap[50] storage variable to allow for new storage variables in later versions

Impact

For upgradeable contracts, there must be storage gap to "allow developers to freely add new state variables in the future without compromising the storage compatibility with existing deployments" (quote OpenZeppelin). Otherwise it may be very difficult to write new implementation code. Without storage gap, the variable in child contract might be overwritten by the upgraded base contract if new variables are added to the base contract. This could have unintended and very serious consequences to the child contracts, potentially causing loss of user fund or cause the contract to malfunction completely. See.

For a description of this storage variable. While some contracts may not currently be sub-classed, adding the variable now protects against forgetting to add it in the future.

Vulnerability Details

In the following context of the upgradeable contracts they are expected to use gaps for avoiding collision:

  • UUPS

However, none of these contracts contain storage gap. The storage gap is essential for upgradeable contract because "It allows us to freely add new state variables in the future without compromising the storage compatibility with existing deployments". Refer to the bottom part of this article.

If a contract inheriting from a base contract contains additional variable, then the base contract cannot be upgraded to include any additional variable, because it would overwrite the variable declared in its child contract. This greatly limits contract upgradeability.

Code Snippet

Tools Used

Manual analysis

Recommendation

Recommend adding appropriate storage gap at the end of upgradeable contracts such as the below.

uint256[50] private __gap;

Reference OpenZeppelin upgradeable contract templates.

_safeMint() should be used rather than _mint() wherever possible

Impact

In NFTDriver.sol, eventually it is called ERC721 _mint(). Calling _mint() this way does not ensure that the receiver of the NFT is able to accept them, making possible to lose them.

_safeMint() should be used with as it checks to see if a user can properly accept an NFT and reverts otherwise.

There is no check of the address provided by the mint NFT that it implements ERC721Receiver.

Details

_mint() is discouraged in favor of _safeMint() which ensures that the recipient is either an EOA or implements IERC721Receiver.

Both open OpenZeppelin and solmate have versions of this function so that NFTs aren’t lost if they’re minted to contracts that cannot transfer them back out.

References

Code Snippet

Recommendation

Use _safeMint() as suggested by OpenZeppelin or include the check before minting.

Informational

Use of deprecated draft file

There is a released file that is no longer a draft, it should be used rather than draft files

  • Caller.sol#L5 import {ECDSA, EIP712} from "openzeppelin-contracts/utils/cryptography/draft-EIP712.sol";

Constants should be defined rather than using magic numbers

NOTE: None of these findings where found by 4naly3er output - NC

Max value can be used rather than 2 ** n

Rather than using 2 ** 256 or other numbers (128, 64, 32, 16, 8...), it can be used type(uint256).max (depending on the exponentiation number).

Omissions in events

The events can include the new value and old value and even be refactored in just one event

_managedStorage().isPaused

Missing initializer modifier on constructor

OpenZeppelin recommends that the initializer modifier be applied to constructors in order to avoid potential griefs, social engineering, or exploits.

No need to return void in a constructor

#0 - GalloDaSballo

2023-02-14T20:05:42Z

1 Missing checks for address(0x0) when assigning values to address state or immutable variables L

2 block.timestamp used as time proxy Disputed - 3

3 Destination recipient for assets may be address(0) L

4 Upgradeable contract is missing a __gap[50] storage variable to allow for new storage variables in later versions L

5 _safeMint() should be used rather than _mint() wherever possible L

1 Use of deprecated draft file R

2 Constants should be defined rather than using magic numbers R

3 Max value can be used rather than 2 ** n R

4 Omissions in events NC

5 Missing initializer modifier on constructor R

6 No need to return void in a constructor NC

4L 4R 2NC -3

#1 - c4-judge

2023-02-24T10:55:36Z

GalloDaSballo marked the issue as grade-b

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