Introduction
We express our gratitude to the PreSend team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
PreSend contracts stand for storing affiliates and fees collecting.
| title | content |
|---|---|
| Platform | Ethereum, Polygon |
| Language | Solidity |
| Timeline | 12/11/2022 - 30/01/2023 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Type: Transaction verifier, Affiliate program
Review Scope | |
|---|---|
| Repository | https://github.com/Presend-DeFi/presend-protocol-payment-affiliate→ |
| Commit | d2c814f6dd1e574b1d0452c243eca4669be6dd94 |
Review Scope
- Commit
- d2c814f6dd1e574b1d0452c243eca4669be6dd94
Audit Summary
10/10
98.65%
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 PreSend |
| Audited By | Hacken |
| Changelog | 17/11/2022 – Initial Review |
| 21/12/2022 - Second Review | |
| 30/01/2023 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for PreSend
- Audited By
- Hacken
- Changelog
- 17/11/2022 – Initial Review
- 21/12/2022 - Second Review
- 30/01/2023 - Third Review
System Overview
PreSend contracts stand for storing affiliates and fees collecting. They are represented by these contracts:
PreSendPayment — Payment contract gives it permission to increase and decrease the amount of funds affiliates can withdraw. Inherited from OpenZeppelin’s Initializable, AccessControl, Chainlink’s AutomationCompatible contracts.
It has the following attributes:
affiliate smart contract reference.
address of the treasury where affiliate payments will go.
aggregator to get the price of the native coin in USD.
the Default Admin user.
PreSendAffilate - Role to manage affiliates. This role can add/remove affiliates, update the affiliate tier that determines the percentage of fees they get, and add new tiers for affiliates. This role can also update the reference to the payment contract. Inherited from OpenZeppelin’s Initializable, AccessControl contracts.
It has the following attributes:
affiliate features and properties.
the address of the PreSend payments smart contract.
the Default Admin user.
Privileged roles
Default Admin: Admin who can set and change an Affiliate, Treasury, aggregator, Fee divisor, Payment, Fee roles.
Affiliate_Admin: In PreSendAffiliate.sol can add or update tier and affiliate.
Payment_Admin: In PreSendPayments.sol this role can increase or decrease currency allowance.
Fee_Admin: Fee Admin who manually sends PreSend transaction fees from the contract to the treasury address.
Payment_Contract: In PreSendAffiliate.sol it represents
PreSendPaymentsaddress.User: The person who uses a Payment contract.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Technical descriptions are provided.
Functional requirements are provided.
Code quality
The total Code quality score is 10 out of 10.
Technical descriptions are provided.
Functional requirements are provided.
Test coverage
Code coverage of the project is 98.65%.
Some error handlers were not tested.
Security score
Upon auditing, the code was found to contain 2 critical, 4 high, 10 medium, and 7 low severity issues. Out of these, 23 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 9.95. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2023-132 | Insufficient Funds | fixed | Critical | |
| F-2023-1320 | Upgradeability Errors | fixed | Critical | |
| F-2023-1325 | Undocumented Behavior | fixed | High | |
| F-2023-132 | Access Control Violation | fixed | High | |
| F-2023-1323 | Requirements Violation | fixed | High | |
| F-2023-132 | Requirements Violation | fixed | High | |
| F-2023-1335 | Contradiction | fixed | Medium | |
| F-2023-133 | Contradiction | fixed | Medium | |
| F-2023-133 | Missing Validation | fixed | Medium | |
| F-2023-1332 | Requirements Violation | fixed | Medium |
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/Presend-DeFi/presend-protocol-payment-affiliate→ |
| Commit | d2c814f6dd1e574b1d0452c243eca4669be6dd94 |
| Whitepaper | Not provided |
| Requirements | Not provided |
| Technical Requirements | Provided |
Scope Details
- Commit
- d2c814f6dd1e574b1d0452c243eca4669be6dd94
- Whitepaper
- Not provided
- Requirements
- Not provided
- Technical Requirements
- Provided