Introduction
We express our gratitude to the Zharta team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Zharta is a platform that provides instant loans & renting services using NFTs as collateral, enabling NFT holders to get liquidity & yield without having to sell their NFTs
| title | content |
|---|---|
| Platform | EVM |
| Language | Vyper |
| Tags | NFT Renting; Escrow; ERC721; Delegation |
| Timeline | 30/11/2023 - 11/12/2023 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/Zharta/lotm-renting-protocol→ |
| Commit | d455048 |
Review Scope
- Commit
- d455048
Audit Summary
10/10
100%
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 | David Camps Novi, Viktor Lavrenenko |
| Approved By | Przemyslaw Swiatowiec |
| Website | https://www.zharta.io/→ |
| Changelog | 06/12/2023 - Initial Review |
| 11/12/2023 - Second Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Zharta
- Audited By
- David Camps Novi, Viktor Lavrenenko
- Approved By
- Przemyslaw Swiatowiec
- Website
- https://www.zharta.io/→
- Changelog
- 06/12/2023 - Initial Review
- 11/12/2023 - Second Review
System Overview
The LOTM Renting Protocol is a trustless way for LOTM players to rent game assets from users.
The NFT renting process in this protocol is as follows:
A lender deposits NFT in a vault, setting the lending terms (price + rental duration).
A borrower gets the NFT they wish, by paying the rental price upfront.
The vault containing the NFT delegates it to the borrower’s specific wallet for a specific duration.
Once the loan duration is reached, the rental finishes.
The borrower can end the rental before the end date, recovering the funds corresponding to the period unused.
Fees are defined in Renting.vy as protocol_fee and protocol_wallet, which are used when a new rental is created through Vault.start_rental.
Protocol contracts:
Vault - holds the core functionality of the NFT lending.
Renting - entry point for users and other protocols.
Contains the admin protocol methods to update the protocol fee and the protocol admin.
Privileged roles
Renting.vy:
Admin - sets the protocol fees and the protocol wallet that receives those fees.
Admin can be changed via
propose_adminandclaim_ownershipfunctions.
Vault.vy:
Owner - the owner of each NFT in the vault. Only this address can interact with the vault through the Renting.vy contract.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Functional requirements are provided:
Project overview is provided.
Use cases are described and detailed.
All the project’s features are mentioned.
Roles and authorization are described.
Technical description is sufficient:
Technical specifications are present.
Deployment instructions are provided.
Code quality
The total Code quality score is 10 out of 10.
The code maintains a high standard.
Best practices are followed.
Test coverage
Code coverage of the project is 100% (branch coverage).
Deployment and basic user interactions are covered with tests.
Negative case coverage is present.
Interactions by several users are tested.
Security score
Upon auditing, the code was found to contain 0 critical, 0 high, 0 medium, and 2 low severity issues. Out of these, 2 issues have been addressed and resolved, leading to a Security score of 10 out of 10.
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
The Vault contract calls ERC20’s methods transfer and transferFrom, checking the return value. However, if a token were used that does not revert or return at all, functions including the aforementioned calls would fail.
Renting time can be set to unlimited, resulting in the loss of control over the rented NFT.
When a renter sets an allowance higher than the original listing.price, there is a risk that the nft_owner can frontrun the renter by changing the listing.price via set_listings() function.
Interactions with delegation_registry_addr (warm.xyz) are out of scope of this audit and cannot be validated (see the following risk statement).
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2023-0743 | Missing Zero Address Checks | fixed | Low | |
| F-2023-0742 | Missing Maximum Protocol Fee Check | fixed | Low | |
| I-2023-0188 | Unused Parameter | fixed | Observation |
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-protocol→ |
| Commit | d455048 |
| Whitepaper | Provided→ |
| Requirements | Provided→ |
| Technical Requirements | Provided→ |