Introduction
We express our gratitude to the Zharta team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Zharta revolutionizes the NFT landscape by offering instant NFT loans and staking backed by NFTs, ensuring seamless liquidity without the hassle of traditional lending processes, while providing unparalleled security and benefits such as fixed APR.
title | content |
---|---|
Platform | EVM |
Language | Vyper |
Tags | NFT Lending |
Timeline | 27/02/2024 - 04/03/2024 |
Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
---|---|
Repository | https://github.com/Zharta/lotm-renting-protocol-v1→ |
Commit | c746cea |
Review Scope
- Commit
- c746cea
Audit Summary
10/10
99%
10/10
10/10
The system users should acknowledge all the risks summed up in the risks section of the report
Document Information
This report may contain confidential information about IT systems and the intellectual property of the Customer, as well as information about potential vulnerabilities and methods of their exploitation.
The report can be disclosed publicly after prior consent by another Party. Any subsequent publication of this report shall be without mandatory consent.
Document | |
---|---|
Name | Smart Contract Code Review and Security Analysis Report for Zharta |
Audited By | Turgay Arda Usman, Seher Saylik |
Approved By | Grzegorz Trawinski |
Website | https://www.zharta.io→ |
Changelog | 06/04/2024 - Preliminary Report |
18/04/2024 - Final Report |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Zharta
- Audited By
- Turgay Arda Usman, Seher Saylik
- Approved By
- Grzegorz Trawinski
- Website
- https://www.zharta.io→
- Changelog
- 06/04/2024 - Preliminary Report
- 18/04/2024 - Final Report
System Overview
Zharta is an NFT renting and staking platform with the following contracts:
RentingERC721V3 — a simple non-fungible token contract that enables the conversion of deposited NFTs into new ERC721 tokens. It facilitates the minting and burning of tokens corresponding to deposited NFTs by the renting contract. Mint and burn functions can only be called by the renting contract address.
RentingV3 — a contract that facilitates the delegation and management of NFT rentals, offering functions to delegate NFTs to wallets, start, extend, and close rentals, and claim rewards. Users can deposit NFTs into vaults, revoke listings, and stake for their NFTs, while also being able to withdraw NFTs only if it is not in an active rental and claim rewards accrued from rentals.
Once rental context data, such as price and maximum duration, is signed by both the owner and protocol admin, users can rent the NFT. They can do so by providing the required signatures and specifying the rental duration.
Renters are also permitted to cancel the rental at any time, albeit with the requirement to pay for at least the minimum duration of the rented NFT. This ensures that there is a fair compensation for the time the NFT was intended to be rented, even if the rental is terminated prematurely.
The rental price, or APR (Annual Percentage Rate), for an NFT is established at the beginning of the rental period and remains fixed throughout the rental duration. This means that renters are aware of the price they will pay upfront and can plan accordingly, without the risk of unexpected price fluctuations during the rental period.
VaultV3 — In the system, for each deposited NFT, a VaultV3 contract is created where the NFT is stored, and staking management for the specific NFT is handled within the Vault contract. This setup ensures that each NFT has its own dedicated storage and staking functionalities, maintaining a clear separation of concerns and facilitating efficient management of assets and associated staking activities.
Privileged roles
The authorities of the RentingV3 contract"s protocol admin:
Claiming the accrued protocol fees
Setting the protocol fee
Changing the protocol wallet address
Pausing/unpausing the contract
Changing the admin role
Executive Summary
Documentation quality
The total Documentation Quality score is 10 out of 10.
Functional requirements are provided
Technical description is provided.
Code quality
The total Code Quality score is 10 out of 10.
The development environment is configured.
The code follows best practices.
Test coverage
Code coverage of the project is 99% (branch coverage).
Deployment and basic user interactions are covered with tests.
Tests are well written and the interactions by several users are tested thoroughly.
Security score
Upon auditing, the code was found to contain 0 critical, 0 high, 0 medium, and 1 low severity issues, leading to a security score of 10 out of 10. Following remediation, all identified issues have been resolved.
All identified issues are detailed in the “Findings” section of this report.
Summary
The comprehensive audit of the customer's smart contract yields an overall score of 10. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
If a renter desires to cancel the rental agreement before the minimum expiration date, they are obligated to pay the rental fee until the minimum expiration date specified in the contract, rather than until the current blockchain block timestamp.
The RentingV3.vy
enables the owner to set platform fee via the set_protocol_fee()
function. This means that the owner can submit a transaction to alter this value concurrently. By allocating a higher gas limit to their transaction, the owner can ensure it is processed faster, resulting in the user receiving a different amount of tokens than anticipated. This situation allows the owner to engage in front-running, exploiting their ability to preempt user transactions and alter exchange outcomes to their advantage
This audit report focuses exclusively on the security assessment of the contracts within the specified review scope. Interactions with out-of-scope contracts are presumed to be correct and are not examined in this audit. We want to highlight that Interactions with contracts outside the specified scope, such as:
3rd-party/ApeCoinStaking.sol
3rd-party/HotWallet.sol
3rd-party/HotWallet2.sol have not been verified or assessed as part of this report.
While we have diligently identified and mitigated potential security risks within the defined scope, it is important to note that our assessment is confined to the isolated contracts within this scope. The overall security of the entire system, including external contracts and integrations beyond our audit scope, cannot be guaranteed. Users and stakeholders are urged to exercise caution when assessing the security of the broader ecosystem and interactions with external contracts. For a comprehensive evaluation of the entire system, additional audits and assessments outside the scope of this report are necessary.
This report serves as a snapshot of the security status of the audited contracts within the specified scope at the time of the audit. We strongly recommend ongoing security evaluations and continuous monitoring to maintain and enhance the overall system's security.
Findings
Code ― | Title | Status | Severity | |
---|---|---|---|---|
F-2024-1273 | Fee Change Can be Frontrunned | mitigated | Low | |
F-2024-1312 | Checks-Effects-Interactions Pattern Violation | fixed | Observation | |
F-2024-1311 | Missing Zero Address Validation | fixed | Observation | |
F-2024-1199 | ecrecover May Return Empty Address | mitigated | Observation | |
F-2024-1196 | Missing Event Logging | fixed | Observation | |
F-2024-1195 | Unused Event In RentingV3 | fixed | Observation |
Identify vulnerabilities in your smart contracts.
Appendix 1. Severity Definitions
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
---|---|
Repository | https://github.com/Zharta/lotm-renting-proto→ |
Commit | e15a6be05d88b651fed6d49793405c5e3a45d0a7 |
Whitepaper | https://zharta.gitbook.io/zharta-welcome-kit/overview/introducing-zharta→ |
Requirements | https://github.com/Zharta/lotm-renting-protocol-v1/pull/69→ |
Technical Requirements | https://zharta.gitbook.io/zharta-welcome-kit/overview/introducing-zharta→ |
Scope Details
- Commit
- e15a6be05d88b651fed6d49793405c5e3a45d0a7
- Technical Requirements
- https://zharta.gitbook.io/zharta-welcome-kit/overview/introducing-zharta→
Contracts in Scope
contracts/RentingERC721V3.vy
contracts/RentingV3.vy
contracts/VaultV3.vy