Introduction
We express our gratitude to the MFEV team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
MFEV Network is a decentralized blockchain-powered platform and technology stack whose goal is to enable genuine mass adoption of crypto payments and decentralized finance (DeFi).
Document | |
|---|---|
| Name | Smart Contract Code Review and Security Analysis Report for MFEV |
| Audited By | David Camps Novi, Nataliia Balashova |
| Approved By | Ataberk Yavuzer |
| Website | https://mfevscan.com/→ |
| Changelog | 16/12/2024 - Preliminary Report; 08/01/2025 - Final Report |
| Platform | MFEV Network |
| Language | Solidity |
| Tags | Staking, Voting |
| Methodology | https://hackenio.cc/sc_methodology→ |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for MFEV
- Audited By
- David Camps Novi, Nataliia Balashova
- Approved By
- Ataberk Yavuzer
- Website
- https://mfevscan.com/→
- Changelog
- 16/12/2024 - Preliminary Report; 08/01/2025 - Final Report
- Platform
- MFEV Network
- Language
- Solidity
- Tags
- Staking, Voting
- Methodology
- https://hackenio.cc/sc_methodology→
Review Scope | |
|---|---|
| Repository | https://github.com/MFEVOfficial/MFEV-NETWORK→ |
| Commit | 02d7a94 |
Review Scope
- Commit
- 02d7a94
Audit Summary
The system users should acknowledge all the risks summed up in the risks section of the report.
Documentation quality
Functional requirements are limited
A general description of the protocol is provided, but no deeper description of the contracts and their functionality.
Smart contracts architecture is not provided.
Technical description is not provided
No run instructions
No technical specification.
Code quality
The development environment is not configured since it is required to manually configure bootnode in order to work with the system.
Outdated Solidity version.
Poor NatSpec quality.
Test coverage
Code coverage of the project is 0% (branch coverage).
Tests are not configured for a quick start (i.e. installation with a single command and run tests with a single command).
Critical issues (see findings section) do not allow for the necessary conditions to run the tests successfully.
System Overview
MFEV Network is a decentralized blockchain-powered platform and technology stack whose goal is to enable genuine mass adoption of crypto payments and decentralized finance (DeFi).
It consists of the following contracts, which are based on and inspired by Fuse Network's →:
RewardsDistributor: allows the owner (contract deployer) to add rewards for different addresses, which will be processed and sent during block reward execution. A reward that has been processed cannot be added again.
Voting: allows validators to create ballots and vote on them.
BlockReward: executes the whole reward mechanism, which is called by the system role to send out mining rewards to the miner as well as their delegators and the rewards receivers defined in the rewards distributor.
Consensus: entry point for users to stake or unstake tokens into the system in order to become future validators of the protocol.
ProxyStorage, EternalStorage, EternalStorageProxy: handle the storage of the system and the upgradability of contract addresses.
Privileged roles
Owner:
Initializes most contracts and manages some key parameters for the system to work correctly.
Adds users rewards that will be sent out during the execution of
reward().
System Role:
Triggers the
reward()function at every block,.Calls
finalizeChange()in order to update the validators of the system.
Validator:
Emits the events
RewardedOnCycleandInitiateChange.Updates the fee charged to their delegators.
Can drop/join the next cycle via
maintenanceandunJail().May crate new ballots to be voted on.
Potential Risks
Any external address can vote on ballots created by validators via Voting::vote(). However, such votes will not be taken into account since only the validators' stake counts as voting power.
Every cycle of the system will reset the validators of the protocol. When doing so, the current validators will be overridden by the pending validators. Thus, the system managers should carefully make sure that those addresses to be kept in the system as validators will be included in the pending validators array.
The contracts fail to use the SafeMath library to avoid overflowing in the following cases: BlockReward: getUsersAndRewards(); ConsensusUtils: _incBlockCounter(), _incStrikeReset, _setCurrentCycle(), _setCurrentValidators(), _setJailRelease(); RewardsDistributor: calculateUserRewards(). Although the likelihood of reaching overflow is low, the development team should consider using SafeMath for such cases.
Findings
Code ― | Title | Status | Severity | |
|---|---|---|---|---|
| F-2024-7682 | Lack of Critical Variables Setup Result in Denial of Service | mitigated | Critical | |
| F-2024-7654 | Incorrect Calculation Results in Wrong Supply and Rewards | fixed | Critical | |
| F-2024-7684 | Validators can Effectively Take Over All Rewards from their Delegators | fixed | Medium | |
| F-2024-7701 | Use of Built-in Transfer Instead of Cal To Send Native Assets | accepted | Low | |
| F-2024-7678 | Insufficient Handling of Duplicate Entries in Arrays | accepted | Low | |
| F-2024-7704 | Cache Variable Array Length In For Loop | fixed | Observation | |
| F-2024-7702 | Multiplication After Division may Result in Precision Loss | accepted | Observation | |
| F-2024-7688 | Missing Zero Address Check may Result in Loss of Funds | fixed | Observation | |
| F-2024-7685 | Lack of Error Messages decrease Code Quality and Troubleshooting | accepted | Observation | |
| F-2024-7683 | BlockReward is Setup at Epoch Years instead of System Years | accepted | 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://github.com/MFEVOfficial/MFEV-NETWORK→ |
| Commit | 02d7a94 |
| Whitepaper | https://mfev.io/whitepaper.pdf→ |
| Requirements | https://mfev.gitbook.io/mfev-docs→ |
| Technical Requirements | Not provided |
Scope Details
- Commit
- 02d7a94
- Whitepaper
- https://mfev.io/whitepaper.pdf→
- Requirements
- https://mfev.gitbook.io/mfev-docs→
- Technical Requirements
- Not provided
Assets in Scope
Appendix 3. Additional Valuables
Verification of System Invariants
During the audit of MFEV, 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, 10 invariants were tested over 2610 runs. This thorough testing ensured that the system works correctly even with unexpected or unusual inputs.
Invariant | Test Result | Run Count |
|---|---|---|
| Total Supply After Reward | Passed | 261 |
| Delegated Amount of Tokens | Passed | 261 |
| Withdrawn Amount of Tokens | Passed | 261 |
| Voting Addresses | Passed | 261 |
| Number of Voting Ballots | Passed | 261 |
| Voting Ballots Cycles | Passed | 261 |
| Voting Ballots Duration | Passed | 261 |
| Addresses in Users Rewards | Passed | 261 |
| Rewards in Users Rewards | Passed | 261 |
| Users Rewards cannot be Duplicated | Passed | 261 |
Invariant
- Total Supply After Reward
Test Result
- Passed
Run Count
- 261
Invariant
- Delegated Amount of Tokens
Test Result
- Passed
Run Count
- 261
Invariant
- Withdrawn Amount of Tokens
Test Result
- Passed
Run Count
- 261
Invariant
- Voting Addresses
Test Result
- Passed
Run Count
- 261
Invariant
- Number of Voting Ballots
Test Result
- Passed
Run Count
- 261
Invariant
- Voting Ballots Cycles
Test Result
- Passed
Run Count
- 261
Invariant
- Voting Ballots Duration
Test Result
- Passed
Run Count
- 261
Invariant
- Addresses in Users Rewards
Test Result
- Passed
Run Count
- 261
Invariant
- Rewards in Users Rewards
Test Result
- Passed
Run Count
- 261
Invariant
- Users Rewards cannot be Duplicated
Test Result
- Passed
Run Count
- 261
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.