Platform: Code4rena
Start Date: 08/01/2024
Pot Size: $83,600 USDC
Total HM: 23
Participants: 116
Period: 10 days
Judge: 0xean
Total Solo HM: 1
Id: 317
League: ETH
Rank: 34/116
Findings: 1
Award: $269.86
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: fouzantanveer
Also found by: 0xA5DF, 0xepley, SAQ, SBSecurity, albahaca, catellatech, clara, hals, hunter_w3b, kaveyjoe, ladboy233, pavankv, peanuts, tala7985, yongskiws
269.8643 USDC - $269.86
reNFT
is a pioneering protocol and platform enabling peer-to-peer renting of non-fungible
tokens (NFTs). This report delves into a detailed analysis of reNFT, encompassing its core features, technical framework, potential use cases, and associated risks.
reNFT
eliminates the need for renters to deposit collateral
, significantly reducing barriers to entry.Ethereum and Polygon
, with integrations planned for other popular blockchains, enhancing accessibility and reach.customized
and dynamic marketplace
.Axie Infinity
scholarships, automating rental agreements and reward distribution
for scholars.Code4rena
, promoting transparency and building trust.escrow deposits
, rental agreements
, and fee distributions
through audited smart contracts.RENFT
token fuels the platform's ecosystem, rewarding
token holders for participation and governance
.Web3 projects
and marketplaces, expanding reNFT's
reach and utility.DAO
structure empowers community decision-making on protocol upgrades and future development.Rent gaming NFTs
to gain access to play-to-earn
opportunities without incurring high upfront costs.artworks
for temporary display or personal enjoyment, expanding access to exclusive pieces.metaverse platforms
.The NFT market is experiencing explosive growth, and reNFT addresses a crucial need within this space: unlocking the utility of NFTs beyond mere ownership
. By enabling rentals
, reNFT opens up new avenues for revenue generation for NFT holders
and expands access to NFT experience
s for a wider audience. This creates a win-win situation for all stakeholders involved
.
i .Purpose
PaymentEscrowBase
) to store token balances separately.iii. Storage
balanceOf mapping
).fee
) to be deducted from payments.iv. Functions
settlePayment and settlePaymentBatch
).increaseDeposit
).setFee
).skim
).upgrade
).i . Purpose
"Storage,"
is responsible for managing various storage functionalities within the protocol.active rentals
, deployed rental safes, hooks, and whitelists.
ii. ArchitectureStorageBas
e) for storing different types of data separately.
iii. Storageorders mapping
) and the number of actively rented tokens (rentedAssets mapping
).deployedSafes mapping and totalSafes counter
)._contractToHook mapping and hookStatus mapping
).whitelistedDelegates and whitelistedExtensions mappings
).
iv. FunctionsaddRentals, removeRentals, removeRentalsBatch
).
Manages deployed rental safes (addRentalSafe
).updateHookPath, updateHookStatus
).toggleWhitelistDelegate, toggleWhitelistExtension
).isRentedOut, contractToHook, hookOnTransaction, hookOnStart, hookOnStop
).i . Purpose
ii . Key Components
Insert Function (_insert
)
Convert to Static Function (_convertToStatic
)
i . Purpose
ii. Key Components Original Deployment Address
original
), and its methods include checks to ensure proper delegate calls from the rental safe.Transfer Functions (_transferERC721 and _transferERC1155
)
Reclaim Rental Order Function (reclaimRentalOrder
)
i . Purpose The contract, "Signer," manages logic related to signed payloads and signature verification when creating rentals. It is designed to ensure the integrity of the rental creation process through signature validation. ii . Key Components EIP-712 Structs and Typehashes
EIP-712
structured data and typehashes to create a standardized and secure way of signing and verifying signatures.items, hooks, rental orders, order fulfillments, order metadata, and rent payloads
.Signature Verification
ECDSA signatures
.Hash Derivation Functions
EIP-712 Domain Separator
i . Purpose
fee management, proxy management, and whitelist management
.protocol's governance structure
.ii . Key Components Dependencies on Modules
Permissions and Keycodes
whitelist settings
,upgrading modules
, and freezing modules
.External Functions
i . Purpose
The contract"Create," is to serve as an interface for creating rental orders within a decentralized application (DApp
) or smart contract system. The contract involves the rental of assets and interacts with other modules and interfaces.
ii . Key Components
Policy Inheritance
Configuration and Initialization
View Functions
domainSeparator, getRentalOrderHash, getRentPayloadHash, and getOrderMetadataHash
.Internal Functions
_emitRentalOrderStarted, _processBaseOrderOffer, _processPayOrderOffer
, etc., are used for internal processing and emitting events.Rental Order Initialization
Order Validation
rental process
.i . Purpose
safes
. Some key components and features include:ii . Key Components Kernel Policy Configuration
Storage Module Dependency: The contract depends on a Storage module, and its configureDependencies function sets the address of this module. The Storage module appears to be critical for maintaining state related to rental safes. Policies:
Stop Policy and Guard Policy: The contract references and uses a Stop policy and a Guard policy. The initializeRentalSafe function enables the stop policy as a module and sets the guard policy for a rental safe. External Contracts:
Gnosis Safe Contracts: The contract interacts with external Gnosis Safe contracts, such as SafeL2
, SafeProxyFactory
, and TokenCallbackHandler
. These contracts likely provide core functionalities for safe deployment, proxy creation, and handling callbacks.
Constructor
kernel
, stop policy,
guard policy,
fallback handler,
safe proxy factory, and
safe singleton`.Configuration Functions
External Functions
Events
i . Purpose
The contract, "Guard" serves as an interface responsible for guarding transactions originating from a rental wallet
. It imposes restrictions on certain types of transactions and allows for customization through the use of external hook contracts.
ii . Key Components
Kernel Policy Configuration
configureDependencies
function ensures that the contract has the correct address for the Storage module
.Internal Functions
_loadValueFromCalldata
: Private function to load a `bytes32 value from calldata at a specified offset._revertSelectorOnActiveRental
: Reverts if a specified selector is called on an actively rented token._revertNonWhitelistedExtension
: Reverts if an extension is not whitelisted._forwardToHook
: Forwards a Gnosis Safe call to a hook contract for additional processing._checkTransaction
: Prevents certain transactions involving ERC721/ERC1155 tokens or changing modules/guard contract.External Functions
checkTransaction
: Checks a transaction initiated by a rental safe, allowing external hooks to intervene in the control flow.checkAfterExecution
: Placeholder for post-execution checks (currently unimplemented).updateHookPath
: Connects a target contract to a hook for transaction processing.updateHookStatus
: Toggles the status of a hook contract, defining the functionality it supports.i . Purpose The contract "Stop", functions as an interface to manage the stopping of rental orders. It ensures that rental orders are stopped under appropriate conditions, facilitates the execution of hooks associated with stopping, and manages the settlement of payments.
ii . Key Components
Kernel Policy Configuration
Internal Functions
_emitRentalOrderStopped
: Helper function to emit an event signaling that a rental order has been stopped._validateRentalCanBeStopped
: Validates whether a rental order can be stopped based on its type, end timestamp, and the address of the expected lender._reclaimRentedItems
: Initiates the reclaiming of rented items, bypassing the guard, and transferring them back to the lender using the Safe module._removeHooks
: Processes hooks associated with stopping the rental order, executing only those with the appropriate status.External Functions
stopRent
: Stops a single rental order by validating conditions, processing hooks, reclaiming rented items, settling payments, and removing relevant data from storage.stopRentBatch
: Stops multiple rental orders in a batch, applying similar logic as stopRent for each order in the batch.i . Purpose
ii . Key Components
Deployed Contract Tracking
Deployment Function - deploy
Address Calculation Function - getCreate2Address
CREATE2
based on the salt and init code.Salt Generation Function - generateSaltWithSender
CREATE2
address, preventing frontrunning
on different chains.i . Purpose
The Contrat "kernel" acts as a registry managing policy and module contracts. The kernel allows the installation, upgrade, activation, and deactivation of modules and policies, while maintaining dependencies and permissions. The contracts have a modular structure, including abstract contracts for adapters, modules, and policies
.
ii . Key Components
KernelAdapter
Module
Policy
Kernel
installing/upgrading
modules, activating/deactivating policies, and migrating the kernel.Modularity
: The codebase appears to be structured in a modular way, utilizing various contracts to manage specific functionalities. This can contribute to easier maintenance and upgrades.
Interfaces
: The use of interfaces, such as Proxiable and Module, suggests a well-thought-out design, promoting code reusability and flexibility.
**Standardization
: **Leveraging EIP-712 for signature verification and adhering to common interfaces like ERC721 and ERC1155 indicates a commitment to standardization and interoperability.
Comments and Documentation
: The inclusion of comments for functions and sections provides A level
of documentation, aiding developers in understanding the code.
The ability to upgrade both the Storage and PaymentEscrow modules introduces centralization risks. The contract owner, having the "ADMIN_ADMIN" role, can potentially wield significant control over protocol upgrades
.
The security of the rental creation process heavily relies on the correctness of the signature verification mechanism
.
The use of external hook contracts introduces complexity and dependencie
s. The correctness and security of the system heavily rely on the proper implementation and security of these hooks
.
Migrating the kernel to a new contract is a critical operation and must be performed with caution. Failure to re-add modules
and policies
to the new kernel can lead to a loss of functionality.
Delegate Call Constraints are in place to limit the calling addresses to whitelisted entities (addresses explicitly whitelisted by the Admin policy
).
The initializeRentalSafe
function assumes that delegate call restrictions are in place due to the guard policy. If delegate calls were allowed without restriction, an attacker could potentially change the module/guard
contacts after deployment, leading to unauthorized transfers of rented assets.
The deployRentalSafe
function requires a valid threshold, and improper validation may result in unexpected behavior. Ensuring that the threshold is within the correct range is crucial for the security of the deployed safes.
The deployment process involves multiple steps, including delegate calls and interactions with external contracts. Any issues during this process, such as reentrancy vulnerabilities
or unexpected state changes
, could pose risks to the correct deployment and initialization of rental safes
.
Granting and revoking roles should be carefully managed to avoid unintended consequences. The grantRole and revokeRole functions require proper validation.
The uniqueness of the safe addresses is based on the nonce generation using keccak256(abi.encode(STORE.totalSafes() + 1, block.chainid))
. If there are issues with nonce generation
or if the chain ID is manipulated, it could result in non-unique safe addresses, leading to potential security issues.
The warning about delegate call assumption indicates a potential security concern. It's crucial to ensure that delegate call restrictions are effectively implemented by the `guard policy.
The codebase review of reNFT
has significantly contributed to my growth in codebase skills by providing a comprehensive understanding of various aspects of smart contract development. Here's how this review has been instrumental in enhancing my skills:
Architecture Understanding
reNFT protocol
.Smart Contract Patterns
Storage Management
Security Considerations
Memory Management Techniques
Delegate Calls and Reentrancy Protection
External Contract Interaction
Signature Verification and EIP Standards
Administrative and Governance Aspects
Factory Contract for Deployment
Secure Contract Deployment
Create2Deployer.sol
contract introduced me to the secure deployment of contracts using CREATE2
. Understanding how to prevent frontrunning
and tying deployment addresses to unique salts is crucial for deploying contracts in a secure manner
.Policy and Module Management
Kernel.sol
contract acted as a registry managing policies
and modules
. Understanding how policies and modules are activated
, upgraded
, and deactivated
provides insights into governance structures and contract lifecycle management
.reNFT presents a groundbreaking solution for unlocking the true potential of NFTs by enabling their utilization through renting. Its innovative features, multi-chain support, and flexible use cases position it as a key player in the evolving NFT landscape. However, addressing potential risks and fostering community engagement remain crucial for reNFT's long-term success. This report provides a comprehensive foundation for further analysis and evaluation of this transformative protocol.
Congratulations on the successful completion of the codebase audit for reNFT within the Code4rena platform. The depth and quality of your codebase reflect a remarkable commitment to security, transparency, and excellence in blockchain development.
As an C4 warden reviewing the reNFT codebase, I was thoroughly impressed by the meticulous design and robust architecture of your smart contracts. Each module, from PaymentEscrow to Create2Deployer, demonstrates a profound understanding of the complexities involved in handling rental payments, managing storage functionalities, and ensuring secure deployment of contracts. the reNFT codebase reflects an exceptional level of diligence and expertise in blockchain development. The team's commitment to security, modular design, and adherence to best practices is evident throughout the codebase.
I want to extend my best wishes to the entire reNFT team for the success of your project. Your dedication to excellence in smart contract development and security is truly commendable.
35 hours
#0 - c4-judge
2024-01-27T20:26:48Z
0xean marked the issue as grade-a