Governance - Onyx DAO


Prepared by:

Halborn Logo

HALBORN

Last Updated 03/10/2025

Date of Engagement: February 12th, 2025 - February 21st, 2025

Summary

92% of all REPORTED Findings have been addressed

All findings

12

Critical

0

High

0

Medium

0

Low

4

Informational

8


1. Introduction

Onyx engaged Halborn to conduct a security assessment on their smart contracts beginning on February 12th, 2025 and ending on February 21th, 2025. The security assessment was scoped to the smart contracts provided to Halborn. Commit hashes and further details can be found in the Scope section of this report.

The Onyx codebase in scope consist of 4 different solidity files:

    • MasterChef contract: Its purpose is to distribute rewards to stakers based on their stake.

    • CHNGovernance contract: It allows users to create proposals and vote on them.

    • CHNTimelock contract: It is responsible for queuing and executing proposals from the CHNGovernance contract.

    • CHNStaking contract: It enables users to stake tokens, rewards them based on their stakes, and tracks their voting power.

2. Assessment Summary

Halborn was provided 8 days for the engagement and assigned 1 full-time security engineer to review the security of the smart contracts in scope. The engineer is a blockchain and smart contract security expert with advanced smart contract hacking skills, and deep knowledge of multiple blockchain protocols.

The purpose of the assessment is to:

    • Identify potential security issues within the smart contracts.

    • Ensure that smart contract functionality operates as intended.

In summary, Halborn identified some improvements to reduce the likelihood and impact of risks, which should be addressed by the Onyx team. The main ones were the following:

    • Consider enforcing the maxXcnPerSecond parameter in the constructor, or remove it entirely.

    • Consider using multisig wallet address for the guardian address. Additionally consider adding functionality to change the guardian address in the CHNGovernance contract.

    • Consider adding the proposal id into the calculation of the operation id in the _queueOrRevert() function.

    • Consider caching the length of the proposal.targets array before you loop over them.

3. Test Approach and Methodology

Halborn performed a combination of manual review of the code and automated security testing to balance efficiency, timeliness, and accuracy in regard to the scope of this assessment. While manual testing is recommended to uncover flaws in logic, process, and implementation; automated testing techniques help enhance coverage of smart contracts and can quickly identify items that do not follow security best practices.

The following phases and associated tools were used throughout the term of the assessment:

    • Research into architecture, purpose and use of the platform.

    • Smart contract manual code review and walkthrough to identify any logic issue.

    • Thorough assessment of safety and usage of critical Solidity variables and functions in scope that could lead to arithmetic related vulnerabilities.

    • Local testing with custom scripts (Foundry).

    • Fork testing against main networks (Foundry).

    • Static analysis of security for scoped contract, and imported functions(Slither).


4. RISK METHODOLOGY

Every vulnerability and issue observed by Halborn is ranked based on two sets of Metrics and a Severity Coefficient. This system is inspired by the industry standard Common Vulnerability Scoring System.
The two Metric sets are: Exploitability and Impact. Exploitability captures the ease and technical means by which vulnerabilities can be exploited and Impact describes the consequences of a successful exploit.
The Severity Coefficients is designed to further refine the accuracy of the ranking with two factors: Reversibility and Scope. These capture the impact of the vulnerability on the environment as well as the number of users and smart contracts affected.
The final score is a value between 0-10 rounded up to 1 decimal place and 10 corresponding to the highest security risk. This provides an objective and accurate rating of the severity of security vulnerabilities in smart contracts.
The system is designed to assist in identifying and prioritizing vulnerabilities based on their level of risk to address the most critical issues in a timely manner.

4.1 EXPLOITABILITY

Attack Origin (AO):
Captures whether the attack requires compromising a specific account.
Attack Cost (AC):
Captures the cost of exploiting the vulnerability incurred by the attacker relative to sending a single transaction on the relevant blockchain. Includes but is not limited to financial and computational cost.
Attack Complexity (AX):
Describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability. Includes but is not limited to macro situation, available third-party liquidity and regulatory challenges.
Metrics:
EXPLOITABILITY METRIC (mem_e)METRIC VALUENUMERICAL VALUE
Attack Origin (AO)Arbitrary (AO:A)
Specific (AO:S)
1
0.2
Attack Cost (AC)Low (AC:L)
Medium (AC:M)
High (AC:H)
1
0.67
0.33
Attack Complexity (AX)Low (AX:L)
Medium (AX:M)
High (AX:H)
1
0.67
0.33
Exploitability EE is calculated using the following formula:

E=meE = \prod m_e

4.2 IMPACT

Confidentiality (C):
Measures the impact to the confidentiality of the information resources managed by the contract due to a successfully exploited vulnerability. Confidentiality refers to limiting access to authorized users only.
Integrity (I):
Measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of data stored and/or processed on-chain. Integrity impact directly affecting Deposit or Yield records is excluded.
Availability (A):
Measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability. This metric refers to smart contract features and functionality, not state. Availability impact directly affecting Deposit or Yield is excluded.
Deposit (D):
Measures the impact to the deposits made to the contract by either users or owners.
Yield (Y):
Measures the impact to the yield generated by the contract for either users or owners.
Metrics:
IMPACT METRIC (mIm_I)METRIC VALUENUMERICAL VALUE
Confidentiality (C)None (I:N)
Low (I:L)
Medium (I:M)
High (I:H)
Critical (I:C)
0
0.25
0.5
0.75
1
Integrity (I)None (I:N)
Low (I:L)
Medium (I:M)
High (I:H)
Critical (I:C)
0
0.25
0.5
0.75
1
Availability (A)None (A:N)
Low (A:L)
Medium (A:M)
High (A:H)
Critical (A:C)
0
0.25
0.5
0.75
1
Deposit (D)None (D:N)
Low (D:L)
Medium (D:M)
High (D:H)
Critical (D:C)
0
0.25
0.5
0.75
1
Yield (Y)None (Y:N)
Low (Y:L)
Medium (Y:M)
High (Y:H)
Critical (Y:C)
0
0.25
0.5
0.75
1
Impact II is calculated using the following formula:

I=max(mI)+mImax(mI)4I = max(m_I) + \frac{\sum{m_I} - max(m_I)}{4}

4.3 SEVERITY COEFFICIENT

Reversibility (R):
Describes the share of the exploited vulnerability effects that can be reversed. For upgradeable contracts, assume the contract private key is available.
Scope (S):
Captures whether a vulnerability in one vulnerable contract impacts resources in other contracts.
Metrics:
SEVERITY COEFFICIENT (CC)COEFFICIENT VALUENUMERICAL VALUE
Reversibility (rr)None (R:N)
Partial (R:P)
Full (R:F)
1
0.5
0.25
Scope (ss)Changed (S:C)
Unchanged (S:U)
1.25
1
Severity Coefficient CC is obtained by the following product:

C=rsC = rs

The Vulnerability Severity Score SS is obtained by:

S=min(10,EIC10)S = min(10, EIC * 10)

The score is rounded up to 1 decimal places.
SeverityScore Value Range
Critical9 - 10
High7 - 8.9
Medium4.5 - 6.9
Low2 - 4.4
Informational0 - 1.9

6. Assessment Summary & Findings Overview

Critical

0

High

0

Medium

0

Low

4

Informational

8

Security analysisRisk levelRemediation Date
Rewards are not guaranteed to be depositedLowRisk Accepted - 03/03/2025
Possible DOS of proposalsLowRisk Accepted - 03/03/2025
Restrictions are not enforced in the constructorLowRisk Accepted - 03/03/2025
Centralization riskLowRisk Accepted - 03/03/2025
Use of unsafe Functions for ERC20 InteractionsInformationalAcknowledged - 03/03/2025
Custom errors should be usedInformationalAcknowledged - 03/03/2025
The length of an array is not cached before loopsInformationalAcknowledged - 03/03/2025
Use of memory instead of calldata for an unmodified function argumentInformationalAcknowledged - 03/03/2025
Insufficient test coverageInformationalAcknowledged - 03/03/2025
Consider using named mappingsInformationalAcknowledged - 03/03/2025
Floating pragmaInformationalAcknowledged - 03/03/2025
Reentrancy allows manipulation of voting powerInformational-

7. Findings & Tech Details

7.1 Rewards are not guaranteed to be deposited

//

Low

Description

The MasterChef contract allows users to stake rewards, and based on their stake, the time they have been staking and the XCN rewards per second they are supposed to receive some amount of rewards. However there is no mechanism that guarantees that the full amount of XCN rewards will be deposited into the MasterChef contract, and stakers will be able to withdraw them.

BVSS
Recommendation

Consider implementing a mechanism that guarantees the XCN rewards are deposited into the MasterChef contract before they are accrued to stakers.

Remediation Comment

RISK ACCEPTED: The Onyx team has accepted the risk.

References

7.2 Possible DOS of proposals

//

Low

Description

One proposal can contain multiple operations in different contracts that have to be executed. Some governance proposals may require a sequence of operations to be executed in a specific order in order for the proposal to have an effect. Before the operations from the proposal can be executed they have to be queued first via the queue() function:

    function queue(uint proposalId) public {
        require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded");
        Proposal storage proposal = proposals[proposalId];
        uint eta = add256(block.timestamp, timelock.delay());
        for (uint i = 0; i < proposal.targets.length; i++) {
            _queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
        }
        proposal.eta = eta;
        emit ProposalQueued(proposalId, eta);
    }
  function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
        require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta");
        timelock.queueTransaction(target, value, signature, data, eta);
  }

As can be seen from the _queueOrRevert() function the operation id is calculated with the provided target, value, signature, data, and eta parameters. In a scenario where one proposal has multiple operations that have to be executed, a malicious user with enough voting power can create a proposal with just one of the operations, and use the same target, value, signature and data parameters, right after the first proposal is created. The protocol is deployed on Ethereum so frontrunning and backrunning of transactions is possible. This way if both of the proposals succeed, they will have the same eta parameters. Now the malicious user has to queue his proposal first, and when someone tries to queue the non malicious proposal it will revert as one of the operations in the non malicious proposal will already be queued. This way a malicious user or a group of people with enough voting power can dos proposals that they are strictly against but they don't have enough voting power to outvote the other users in the non malicious proposal.

BVSS
Recommendation

Consider adding the proposal id into the calculation of the operation id in the _queueOrRevert() function, also modify the queueTransaction() function in the CHNTimelock contract:

_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta, proposal.id);

Remediation Comment

RISK ACCEPTED: The Onyx team has accepted the risk.

References

7.3 Restrictions are not enforced in the constructor

//

Low

Description

The MasterChef contract has a maxXcnPerSecond parameter that defines the maximum amount of XCN tokens that should be distributed per second. However this restriction is not enforced in the constructor, and the actual xcnPerSecond parameter is set to 2.5e18, as can be seen on chain: https://etherscan.io/address/0x3fa642c0bbad64569eb8424af35f518347249216#readContract#F12


This results in the protocol distributing more rewards per second than the max amount of rewards per second that are defined as a constant.

BVSS
Recommendation

Consider enforcing the maxXcnPerSecond parameter in the constructor, or remove it entirely.

Remediation Comment

RISK ACCEPTED: The Onyx team has accepted the risk.

References

7.4 Centralization risk

//

Low

Description

If the guardian address in the CHNGovernance contract is compromised, all the critical functionalities of the CHNTimelock contract will be compromised. The guardian address can directly change the admin address in the CHNTimelock contract via the __queueSetTimelockPendingAdmin() and __executeSetTimelockPendingAdmin() functions. And the queueTransaction() and the executeTransaction() functions in the CHNTimelock contract can be called by the admin(which is originally set to the CHNGovernance contract). Additionally the guardian address can cancel all proposals that are not yet executed, no matter whether they have succeeded or not.

BVSS
Recommendation

Consider using multisig wallet address for the guardian address. Additionally consider adding functionality to change the guardian address in the CHNGovernance contract.

Remediation Comment

RISK ACCEPTED: The Onyx team has accepted the risk.

References

7.5 Use of unsafe Functions for ERC20 Interactions

//

Informational

Description

In the MasterChef contract the inCaseETHGetStuck() function uses transfer() instead of safeTransfer(), and in a case where a weird ERC20 token have to be rescued, the function may revert.

BVSS
Recommendation

In the inCaseETHGetStuck() function use safeTransfer() instead of transfer()

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

References

7.6 Custom errors should be used

//

Informational

Description

In Solidity smart contract development, replacing hard-coded revert message strings with the Error() syntax is an optimization strategy that can significantly reduce gas costs. Hard-coded strings, stored on the blockchain, increase the size and cost of deploying and executing contracts.


The Error() syntax allows for the definition of reusable, parameterized custom errors, leading to a more efficient use of storage and reduced gas consumption. This approach not only optimizes gas usage during deployment and interaction with the contract but also enhances code maintainability and readability by providing clearer, context-specific error information.

BVSS
Recommendation

It is recommended to replace hard-coded revert strings in require statements for custom errors, which can be done following the logic below:


1. Standard require statement (to be replaced):

require(condition, "Condition not met");

2. Declare the error definition to state:

error ConditionNotMet();

3. As currently is not possible to use custom errors in combination with require statements, the standard syntax is:

if (!condition) revert ConditionNotMet();

More information about this topic in [Official Solidity Documentation](https://docs.soliditylang.org/en/v0.8.24/control-structures.html#panic-via-assert-and-error-via-require).

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

References

7.7 The length of an array is not cached before loops

//

Informational

Description

In the CHNGovernance contract the queue() function iterates over all of the contract targets of the proposal and then calls the _queueOrRevert() function in order to queue all of the functions that have to be executed later. However the length of the proposal.targets is not cached before all of the targets are looped trough. This increases the gas consumed by the queue() function. There is a similar scenario in the execute() function.

BVSS
Recommendation

Consider caching the length of the proposal.targets array before you loop over them.

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

References

7.8 Use of memory instead of calldata for an unmodified function argument

//

Informational

Description

In the CHNGovernance contract in the propose(), and _queueOrRevert() functions, the memory keyword is used for parameters which are not modified instead of the calldata keyword. There is a similar scenario in the queueTransaction() function in the CHNTimelock contract.

BVSS
Recommendation

Consider using the calldata keyword instead of the memory for function arguments which are not modified.

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

References

7.9 Insufficient test coverage

//

Informational

Description

The project lacks unit and E2E tests. It is always a good practice to implement unit tests and E2E tests, as it helps discovering vulnerabilities in the early stages of development, and later on it helps with maintaining and updating the code base.

BVSS
Recommendation

Consider adding unit and E2E tests to the project.

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

7.10 Consider using named mappings

//

Informational

Description

The Solidity version of the different contracts in scope is not fixed, some contracts use a Solidity version from 6.12.0 up to 7.0.0, others use a Solidity version greater than 0.8.1. Consider using a Solidity version grater than 0.8.18, which supports named mapping, and utilize the named mappings. Using named mappings can improve the readability and maintainability of the code by making the purpose of each mapping clearer. This practice helps developers and auditors understand the mappings' intent more easily.

BVSS
Recommendation

Consider refactoring the mappings to use named arguments, which will enhance code readability and make the purpose of each mapping more explicit.


For example, in the CHNTimelock contract, instead of declaring:

mapping (bytes32 => bool) public queuedTransactions;

It could be declared as:

mapping (bytes32 transactionId => bool queued) public queuedTransactions;

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

References

7.11 Floating pragma

//

Informational

Description

The Solidity version of the different contracts in scope is not fixed, some contracts use a Solidity version from 6.12.0 up to 7.0.0, others use a Solidity version greater than 0.8.1. It is recommended that contracts should be deployed with the same compiler version and flags used during development and testing. Locking the pragma helps to ensure that contracts do not accidentally get deployed using another pragma. For example, an outdated pragma version might introduce bugs that affect the contract system negatively.

In this aspect, it is crucial to select the appropriate EVM version when it's intended to deploy the contracts on networks other than the Ethereum mainnet, which may not support these opcodes. Failure to do so could lead to unsuccessful contract deployments or transaction execution issues.

BVSS
Recommendation

Lock the pragma version to the same version used during development and testing.

Additionally, make sure to specify the target EVM version when using Solidity versions from 0.8.20 and above if deploying to chains that may not support newly introduced opcodes. Additionally, it is crucial to stay informed about the opcode support of different chains to ensure smooth deployment and compatibility.

Remediation Comment

ACKNOWLEDGED: The Onyx team has acknowledged the risk.

References

7.12 Reentrancy allows manipulation of voting power

//

Informational

Description

The owner of the CHNStaking contract is the CHNTimelock contract, that means if a proposal passes all kind of tokens can be added via the add() function.

Score
(0.0)
References

8. Automated Testing

Static Analysis Report

Description

Halborn used automated testing techniques to enhance the coverage of certain areas of the smart contracts in scope. Among the tools used was Slither, a Solidity static analysis framework. After Halborn verified the smart contracts in the repository and was able to compile them correctly into their abis and binary format, Slither was run against the contract. This tool can statically verify mathematical relationships between Solidity variables to detect invalid or inconsistent usage of the contracts' APIs across the entire code-base.

The security team assessed all findings identified by the Slither software, however, most of the findings are not included in the below results for the sake of report readability.


Output

The findings obtained as a result of the Slither scan were reviewed, and the majority were not included in the report because they were determined as false positives:



Halborn strongly recommends conducting a follow-up assessment of the project either within six months or immediately following any material changes to the codebase, whichever comes first. This approach is crucial for maintaining the project’s integrity and addressing potential vulnerabilities introduced by code modifications.

© Halborn 2025. All rights reserved.