Introduction
We express our gratitude to the USSD team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
USSD is an autonomous stablecoin with crypto collateralization.
| title | content |
|---|---|
| Platform | EVM (Ethereum, Arbitrum, BNB Smart Chain, Optimism) |
| Language | Solidity |
| Tags | Oracle, Staking, Stablecoin |
| Timeline | 15/01/2024 - 07/03/2024 |
| Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
|---|---|
| Repository | https://github.com/DavidLeeChaum/USSDv2/→ |
| Commit | bf57fe60453768e41fdfb27b683abbffe9a700d6 |
Review Scope
- Commit
- bf57fe60453768e41fdfb27b683abbffe9a700d6
Audit Summary
9/10
N/A
10/10
10/10
The system users should acknowledge all the risks summed up in the risks section of the report. Mitigated issues are excluded from the Total Findings count.
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 USSD |
| Audited By | Maksym Fedorenko, Roman Tiutiun |
| Approved By | Przemyslaw Swiatowiec |
| Website | https://www.ussd.ai/→ |
| Changelog | 22/01/2024 - Preliminary Report |
| 22/02/2024 - Second Review | |
| 07/03/2024 - Third Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for USSD
- Audited By
- Maksym Fedorenko, Roman Tiutiun
- Approved By
- Przemyslaw Swiatowiec
- Website
- https://www.ussd.ai/→
- Changelog
- 22/01/2024 - Preliminary Report
- 22/02/2024 - Second Review
- 07/03/2024 - Third Review
System Overview
USSD is an autonomous stablecoin with crypto collateralization with the following contracts:
USSD — an autonomous on-chain stablecoin system. The contract uses the ERC20 standard for token implementation and includes additional functionality for minting, redeeming, and managing the stablecoin. It also interacts with external contracts and oracles to determine asset prices and manage collateral.
USSDRewards — is an extension of the ERC20 token standard. This contract is designed to distribute rewards through USSDToken tokens to users who hold the USSDRewards token. The rewards are calculated based on the average percentage yield (APY) over time and the total supply of staked tokens.
stUSSD — is a staking token, where users can deposit a token (presumably called USSD) and receive stUSSD tokens in return, which may earn rewards over time. The contract includes functionality for depositing, withdrawing, and redeeming tokens, as well as accounting logic to manage the relationship between assets and shares.
ICT — is a contract that deals with insurance and rewards, using two types of tokens: WETH (Wrapped Ether) and WBGL (presumably another token). The contract allows users to mint new tokens in exchange for WETH or WBGL and to claim insurance under certain conditions.
Privileged roles
The USSD contract owner has the flexibility to add a staking contract, insurance contract, and configure oracles. Additionally, they can enable WETH and DAI tokens as collateral, but it is important to note that these actions above in this paragraph can be performed only once ever by the admin.
The admin role may be transferred from one user to another multiple times.
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.
Test coverage
Code coverage of the project is N/A
Code coverage cannot be calculated due to the lack of Truffle framework support by the code coverage tools.
While the project includes tests, they do not cover all possible branches. Test coverage is assumed to be 100% due to the inability to measure coverage.
Security score
Upon auditing, the code was found to contain 1 critical, 2 high, 4 medium, and 1 low severity issues. The 1 critical, 2 high, and 1 medium severity issues were promptly addressed, fixed, mitigated or accepted as part of the remediation efforts. After the remediation check of the audit process, 1 medium severity issues were accepted by the client, leading to a security score of 9 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.3. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
The repository includes dependencies beyond the audit scope, introducing potential security risks associated with third-party code such as the solmate library and third-party protocols like Oracles and DEXs. Due to the composability of contracts, these external dependencies pose inherent security risks that are not covered in the audit.
The stable coin collaterization ratio might fall lower 100% any time due to the collateral tokens price fluctuations.
If the collateral ratio is below 95%, then the conversion of USSD within the protocol is only possible with a 5% discount. For example with the 0.94 collateral ratio the protocol has only 0.94 cents of collateral to cover one USSD token, but with the discount it would be possible to convert one USSD to only 0.893 USD of collateral (Collateral ratio * (1 - discount) = 0.94 * 0.95 = 0.893)
Before using the system it is recommended to make sure that the proper Oracles addresses are specified within the next variables: STABLE_ORACLE, STABLEDAI_ORACLE, WBGL_ORACLE, WBTC_ORACLE, and WETH_ORACLE. The reliability of these Price Oracles themselves poses a risk independent of the USSD admin's behavior.
Excessive minting of USSD may occur, the risk arises not from the minting process itself, but from staking reward minting. This risk could materialize if collateral value updates are delayed. Collateral value updates occur during USSD token minting against collateral or can be triggered by anyone at any time. The admin must ensure timely updates, or trigger them if necessary.
Insurance contract may not have enough funds to increase the collaterization ratio sufficiently.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2024-0518 | The Staking Rewards Are Not Minted | fixed | Critical | |
| F-2024-0521 | Flashloan Attack to Increase The Staking Rewards | fixed | High | |
| F-2024-0519 | Staking Rewards are Not Separated From Users Balances | fixed | High | |
| F-2024-0970 | The System Might Mint Redundant Rewards | mitigated | Medium | |
| F-2024-0540 | Arbitrage Opportunities Can Affect The Price Stability | accepted | Medium | |
| F-2024-0520 | Insurance Tokens are Transferable Independent From Collateralization Level | fixed | Medium | |
| F-2024-0515 | Funds Lock On the Insurance Contract | fixed | Medium | |
| F-2024-0497 | Missing Checks for Zero Address | fixed | Low | |
| F-2024-0539 | Redundant Code Blocks | fixed | Observation | |
| F-2024-0522 | Redundancy with Solmate and OpenZeppelin in Safe Transfers and ERC-20 Interactions | 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/DavidLeeChaum/USSDv2→ |
| Commit | bf57fe60453768e41fdfb27b683abbffe9a700d6 |
| Whitepaper | - |
| Requirements | - |
| Technical Requirements | Readme.md |
Scope Details
- Repository
- https://github.com/DavidLeeChaum/USSDv2→
- Commit
- bf57fe60453768e41fdfb27b683abbffe9a700d6
- Whitepaper
- -
- Requirements
- -
- Technical Requirements
- Readme.md