Introduction
We express our gratitude to the Runwago team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Runwago is a blockchain-based platform combining fitness and cryptocurrency rewards, offering a new way for people to achieve their running goals.
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for Runwago |
| Audited By | Seher Saylik, Andy Cho |
| Approved By | Ataberk Yavuzer |
| Website | https://www.runwago.com/en→ |
| Changelog | 29/11/2024 - Preliminary Report |
| Changelog | 06/12/2024 - Final Report |
| Platform | Binance, Ethereum and Arbitrum One |
| Language | Solidity |
| Tags | Presale |
| Methodology | https://hackenio.cc/sc_methodology→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Runwago
- Audited By
- Seher Saylik, Andy Cho
- Approved By
- Ataberk Yavuzer
- Website
- https://www.runwago.com/en→
- Changelog
- 29/11/2024 - Preliminary Report
- Changelog
- 06/12/2024 - Final Report
- Platform
- Binance, Ethereum and Arbitrum One
- Language
- Solidity
- Tags
- Presale
- Methodology
- https://hackenio.cc/sc_methodology→
Review Scope | |
|---|---|
| Repository | https://gitlab.cleevio.cz/cleeviox/backend/runwago-presale-sc→ |
| Commit | e8dc9b1 |
| Retest commit | e72b971 |
Review Scope
- Commit
- e8dc9b1
- Retest commit
- e72b971
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report
Documentation quality
Functional requirements are partially missed.
Technical description is provided.
Code quality
Some gas-inefficient usages were detected.
Unused instances were found.
The development environment is configured.
Test coverage
Code coverage of the project is 83.84% (branch coverage).
Deployment and basic user interactions are covered with tests.
Interactions by several users are not tested thoroughly.
System Overview
Runwago is a presale protocol with the following contracts:
PresaleClaiming — a contract that manages a token presale, enabling users to purchase tokens using various payment methods, including native cryptocurrency and ERC20 tokens, with features like referral and volume bonuses. It also handles token claiming through a phased vesting system, using Merkle proofs to verify user eligibility, and ensures administrative control over key parameters like payment tokens, bonus tiers, and withdrawal mechanisms.
ReferralUSDTRewards — facilitates the claiming of USDT rewards using a Merkle proof system for verification, while also providing an emergency withdrawal mechanism for the contract owner
Privileged roles
The admin of the PresaleClaiming contract can
Set the claiming data: Configure claiming phases, percentages, and Merkle root.
Set the claiming active flag: Enable or disable claiming.
Set referral bonus tiers: Adjust percentages and thresholds.
Toggle referral bonuses: Enable or disable referral bonuses.
Set volume buy bonus tiers: Adjust percentages and thresholds.
Toggle volume buy bonuses: Enable or disable volume bonuses.
Update presale phase index: Change the current phase.
Set presale state: Update presale status (e.g., active, finished).
Set presale start time: Adjust start timestamp for a phase.
Add or remove payment tokens: Enable or disable ERC20 tokens.
Update stablecoin addresses: Set or update USDC/USDT addresses.
Set treasury wallet: Update treasury wallet address.
Update token data feed: Adjust data feed and heartbeat.
Update native coin feed: Set native coin data feed and heartbeat.
Emergency ERC20 withdrawal: Withdraw tokens any time
Emergency native coin withdrawal: Withdraw ETH any time
Set hot wallet: Add or remove hot wallets.
Set estimation address: Add or remove estimation addresses.
Set claimable token: Configure the claimable token address.
Set minimum purchase: Adjust minimum USD purchase amount.
Authorize upgrades: Approve contract implementation upgrades.
The admin role of the ReferralUSDTRewards contract can:
withdraw USDT tokens any time
set the Nerkle root
Potential Risks
The audited project is designed to function correctly only with presale tokens that have 18 decimals. Using tokens with a different decimal configuration can result in price calculation inaccuracies due to the code's dependency on consistent decimal handling.
Flexibility and Risk in Contract Upgrades: The project's contracts are upgradable, allowing the administrator to update the contract logic at any time. While this provides flexibility in addressing issues and evolving the project, it also introduces risks if upgrade processes are not properly managed or secured, potentially allowing for unauthorized changes that could compromise the project's integrity and security.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2024-7398 | Silent Failure on Invalid Merkle Proof Causes Irreversible Loss of Referral Bonuses | accepted | Low | |
| F-2024-7397 | Unrestricted Emergency Token Withdrawal | accepted | Low | |
| F-2024-7391 | Missing Checks For address(0) in constructor/initializers | fixed | Low | |
| F-2024-7388 | Lack of Restriction on Admin-Controlled Dates and Durations in setClaiming() | accepted | Low | |
| F-2024-7387 | Lack of Sequential Validation for Phase Percentages in setClaiming() | fixed | Low | |
| F-2024-7400 | Lack Of Cached Values While Reading From Storage Leads To Unnecessary Gas Consumption | fixed | Observation | |
| F-2024-7396 | Use != 0 Instead of > 0 for Unsigned Integer Comparison | fixed | Observation | |
| F-2024-7395 | Unused Error Definition | fixed | Observation | |
| F-2024-7394 | Unused Structs | fixed | Observation | |
| F-2024-7393 | Do Not Cache Constants To Save Gas | fixed | Observation |
Appendix 1. Definitions
Severities
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. |
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.
Potential Risks
The "Potential Risks" section identifies issues that are not direct security vulnerabilities but could still affect the project’s performance, reliability, or user trust. These risks arise from design choices, architectural decisions, or operational practices that, while not immediately exploitable, may lead to problems under certain conditions. Additionally, potential risks can impact the quality of the audit itself, as they may involve external factors or components beyond the scope of the audit, leading to incomplete assessments or oversight of key areas. This section aims to provide a broader perspective on factors that could affect the project's long-term security, functionality, and the comprehensiveness of the audit findings.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
|---|---|
| Repository | https://gitlab.cleevio.cz/cleeviox/backend/runwago-presale-sc→ |
| Commit | e8dc9b1feccb464305b75110e3a6945586161f2b |
| Whitepaper | N/A |
| Requirements | https://gitlab.cleevio.cz/cleeviox/backend/runwago-presale-sc/-/blob/main/README.md?ref_type=heads→ |
| Technical Requirements | N/A |
Scope Details
- Commit
- e8dc9b1feccb464305b75110e3a6945586161f2b
- Whitepaper
- N/A
- Technical Requirements
- N/A
Assets in Scope
Appendix 3. Additional Valuables
Verification of System Invariants
During the audit of Runwago, Hacken followed its methodology by performing fuzz-testing on the project's main functions. Foundry →, a tool used for fuzz-testing, was employed to check how the protocol behaves under various inputs. Due to the complex and dynamic interactions within the protocol, unexpected edge cases might arise. Therefore, it was important to use fuzz-testing to ensure that several system invariants hold true in all situations.
Fuzz-testing allows the input of many random data points into the system, helping to identify issues that regular testing might miss. A specific Echidna fuzzing suite was prepared for this task, and throughout the assessment, 4 invariants were tested over 50,000 runs. This thorough testing ensured that the system works correctly even with unexpected or unusual inputs.
Invariant | Test Result | Run Count |
|---|---|---|
PresaleClaiming::setClaiming Non-cumulative phase percentages list couldn't be provided | Failed | 50k |
PresaleClaiming::_update Claiming phase index must be incremented correctly when time advances | Passed | 50k |
PresaleClaiming::buyTokens Should allow buying any random amounts | Passed | 50k |
Invariant
PresaleClaiming::setClaimingNon-cumulative phase percentages list couldn't be providedTest Result
- Failed
Run Count
- 50k
Invariant
PresaleClaiming::_updateClaiming phase index must be incremented correctly when time advancesTest Result
- Passed
Run Count
- 50k
Invariant
PresaleClaiming::buyTokensShould allow buying any random amountsTest Result
- Passed
Run Count
- 50k
Additional Recommendations
The smart contracts in the scope of this audit could benefit from the introduction of automatic emergency actions for critical activities, such as unauthorized operations like ownership changes or proxy upgrades, as well as unexpected fund manipulations, including large withdrawals or minting events. Adding such mechanisms would enable the protocol to react automatically to unusual activity, ensuring that the contract remains secure and functions as intended.
To improve functionality, these emergency actions could be designed to trigger under specific conditions, such as:
Detecting changes to ownership or critical permissions.
Monitoring large or unexpected transactions and minting events.
Pausing operations when irregularities are identified.
These enhancements would provide an added layer of security, making the contract more robust and better equipped to handle unexpected situations while maintaining smooth operations.