Q2 2026 Security & Compliance Report67 incidents, $764M in losses, 88% from operational failures.
Get the report →

Audit name:

[SCA] Credbull | Credbull-DeFi | Oct2024

Date:

Dec 17, 2024

Table of Content

→Introduction
→Audit Summary
→System Overview
→Potential Risks
→Findings
→Appendix 1. Definitions
→Appendix 2. Scope
→Appendix 3. Additional Valuables
→Disclaimer

Want a comprehensive audit report like this?

Introduction

We express our gratitude to the Credbull team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.

Credbull manages the first licensed on-chain private credit fund that emphasizes governance and transparency in strategy, risk management, and off-chain asset allocation. This is done through Vaults that will provide ERC1155 tokens (shares) to users in exchange for their ERC20 USDC (assets) deposits. Users will later be able to redeem their shares for to recover their deposits and some extra yield, generated from an off-chain strategy.

Document

NameSmart Contract Code Review and Security Analysis Report for Credbull
Audited ByDavid Camps Novi, Paul Clemson
Approved ByAtaberk Yavuzer
Websitehttps://credbull.io/→
Changelog23/10/2024 - Preliminary Report
17/12/2024 - Final Report
PlatformPlume Network→
LanguageSolidity
TagsVault, Proxy, ERC1155
Methodologyhttps://hackenio.cc/sc_methodology→

Review Scope

Repositoryhttps://github.com/credbull/credbull-defi→
CommitInitial commit - a3316f3; final commit - e38e285.

Audit Summary

9Total Findings
8Resolved
1Accepted
0Mitigated

The system users should acknowledge all the risks summed up in the risks section of the report

Documentation quality

  • Functional requirements are provided.

  • Technical description are provided.

Code quality

  • NatSpec is included.

  • The development environment is configured.

Test coverage

Code coverage of the project is 95% (branch coverage).

  • Deployment and basic user interactions are covered with tests.

System Overview

Credbull manages the first licensed on-chain private credit fund that emphasizes governance and transparency in strategy, risk management, and off-chain asset allocation. This is done through Vaults that will provide ERC-1155 tokens (shares) to users in exchange for their ERC20 USDC (assets) deposits. Users will later be able to redeem their shares for to recover their deposits and some extra yield, generated from an off-chain strategy.

The project consists of the following contracts:

  • AbstractYieldStrategy.sol - calculates the number of periods based on the input time bonds.

  • CalcDiscounted.sol - helper library to calculate principals and yields.

  • CalcInterestMetadata.sol - defines context variables.

  • CalcSimpleInterest.sol - helper library to calculate yield.

  • RedeemOptimizerFIFO.sol - provides the optimal withdrawal requests based on the desired shares or assets to be obtained.

  • Timer.sol - helper library to calculate periods and timestamps.

  • TripleRateContext.sol - defines context variables.

  • LiquidContinuousMultiTokenVault.sol - main entry-point of the protocol for the users to deposit and withdraw assets in exchange for some shares/yield.

  • MultiTokenVault.sol - baseline vault contract inherited by the LiquidContinuousMultiTokenVault.

  • TimelockAsyncUnlock.sol - manages the requests to unlock assets from the vault.

  • SimpleInterestYieldStrategy.sol - defines a yield strategy based on the number of periods.

  • TripleRateYieldStrategy.sol - defines a yield strategy based on a combination of full maturity periods and the other periods.

Privileged roles

  • Operator can

    • Change the addresses of _redeemOptimizer, _yieldStrategy.

    • Set a new interest rate and the vault start timestamp.

    • Pause and unpause the contract.

    • Lock the tokens of a user (requires ERC20 allowance).

  • Upgrader can

    • Upgrade the vault contracts.

  • Asset Manager can

    • Withdraw assets from the vault.

Potential Risks

The project utilizes Solidity version 0.8.20 or higher, which includes the introduction of the PUSH0 (0x5f) opcode. This opcode is currently supported on the Ethereum mainnet but may not be universally supported across other blockchain networks. Consequently, deploying the contract on chains other than the Ethereum mainnet, such as certain Layer 2 (L2) chains or alternative networks, might lead to compatibility issues or execution errors due to the lack of support for the PUSH0 opcode. In scenarios where deployment on various chains is anticipated, selecting an appropriate Ethereum Virtual Machine (EVM) version that is widely supported across these networks is crucial to avoid potential operational disruptions or deployment failures.

The funds held by the contract depend on their correct management by the system admins: they must ensure the contract will always have the required funds to fulfil each redeem request with the corresponding interest.

The project iterates over large dynamic arrays, which leads to excessive gas costs, risking denial of service due to out-of-gas errors, directly impacting contract usability and reliability.

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.

The yield strategy used in the protocol is defined by the system role OPERATOR_ROLE, relying on their correct setup to have a proper functioning of the yield calculations.

In the TripleRateYieldStrategy contract, if a deposit was made prior to the latest interest valid timestamp, the system will take into account the previous period's interest in order to compute the yield obtained by the user. However, this check assumes there is only a single previous interest period (i.e. current interest plus a previous period only); if there was an even earlier interest period (i.e. current interest plus two previous periods), or more, the earliest periods would not be taken into account. Although it is technically possible to have more than two interest periods, the development team communicated that each vault will never have more than two.

The system includes a pausable feature, which allows the OPERATOR_ROLE to halt any transfer of shares at will: deposits, withdraws and token transfers cannot execute.

Protocol users should note that yield will be calculated for deposits up to the period in which they perform a request for redeeming their funds. If, per example, the notice period to withdraw funds is 5 days, none of these 5 days will be accounted for yield calculations.

Findings

F-2024-6592Incorrect validation of spender approval in _withdraw allows theft of user funds
Status
fixed
Severity

Critical
F-2024-6665Public method allows malicious users to cause DoS on other users withdrawals
Status
fixed
Severity

High
F-2024-6713Users can earn yield while depositing funds for only a few seconds
Status
fixed
Severity

High
F-2024-6708Optimize function receives incorrect owner in requestRedeem leading to incorrect request data being stored
Status
fixed
Severity

Low
F-2024-6700Redeem Requests Cannot be Cancelled or Modified Until Redeem Period
Status
fixed
Severity

Low
F-2024-6693The optimize function fails for deposit/redeem amounts less than $1
Status
fixed
Severity

Low
F-2024-6721Missing Storage Gaps
Status
fixed
Severity

Observation
F-2024-6699Incorrect Order of Parameters Result in Wrong Calculations
Status
fixed
Severity

Observation
F-2024-6678Floating Pragma
Status
accepted
Severity

Observation
Code
―
Title
Status
Severity
F-2024-6592Incorrect validation of spender approval in _withdraw allows theft of user funds
fixed

Critical
F-2024-6665Public method allows malicious users to cause DoS on other users withdrawals
fixed

High
F-2024-6713Users can earn yield while depositing funds for only a few seconds
fixed

High
F-2024-6708Optimize function receives incorrect owner in requestRedeem leading to incorrect request data being stored
fixed

Low
F-2024-6700Redeem Requests Cannot be Cancelled or Modified Until Redeem Period
fixed

Low
F-2024-6693The optimize function fails for deposit/redeem amounts less than $1
fixed

Low
F-2024-6721Missing Storage Gaps
fixed

Observation
F-2024-6699Incorrect Order of Parameters Result in Wrong Calculations
fixed

Observation
F-2024-6678Floating Pragma
accepted

Observation
1-9 of 9 findings

Identify vulnerabilities in your smart contracts.

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:

Assets in Scope

timelock
ITimelock.sol - timelock › ITimelock.sol
ITimelockAsyncUnlock.sol - timelock › ITimelockAsyncUnlock.sol
ITimelockOpenEnded.sol - timelock › ITimelockOpenEnded.sol
TimelockAsyncUnlock.sol - timelock › TimelockAsyncUnlock.sol
Timer.sol - timelock › Timer.sol
token
component
IComponentToken.sol - token › component › IComponentToken.sol
ERC1155
IMultiTokenVault.sol - token › ERC1155 › IMultiTokenVault.sol
IRedeemOptimizer.sol - token › ERC1155 › IRedeemOptimizer.sol
MultiTokenVault.sol - token › ERC1155 › MultiTokenVault.sol
RedeemOptimizerFIFO.sol - token › ERC1155 › RedeemOptimizerFIFO.sol
yield
CalcDiscounted.sol - yield › CalcDiscounted.sol
CalcInterestMetadata.sol - yield › CalcInterestMetadata.sol
CalcSimpleInterest.sol - yield › CalcSimpleInterest.sol
context
ITripleRateContext.sol - yield › context › ITripleRateContext.sol
TripleRateContext.sol - yield › context › TripleRateContext.sol
ICalcInterestMetadata.sol - yield › ICalcInterestMetadata.sol

Appendix 3. Additional Valuables

Verification of System Invariants

During the audit of Credbull, Hacken followed its methodology by performing fuzz-testing on the project's main functions. Forge foundry fuzz tests were used to test how the protocol handles a wide variety of 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 Foundry fuzzing suite was prepared for this task, and throughout the assessment, 4 invariants were tested over 40,000 runs. This thorough testing ensured that the system works correctly even with unexpected or unusual inputs.

Invariant

Test Result

Run Count

Earned yield should match expected earned yield (SimpleInterestYieldStrategy)Passed*10,000
Earned yield should match expected earned yield (TripleRateYieldStrategy)Passed*10,000
Withdrawing any amount less than deposit amount should cause no issuesPassed*10,000
Users should be able to withdraw full amount after a partial withdrawPassed*10,000
  • Invariant

    Earned yield should match expected earned yield (SimpleInterestYieldStrategy)

    Test Result

    Passed*

    Run Count

    10,000

    Invariant

    Earned yield should match expected earned yield (TripleRateYieldStrategy)

    Test Result

    Passed*

    Run Count

    10,000

    Invariant

    Withdrawing any amount less than deposit amount should cause no issues

    Test Result

    Passed*

    Run Count

    10,000

    Invariant

    Users should be able to withdraw full amount after a partial withdraw

    Test Result

    Passed*

    Run Count

    10,000

*Tests passed after ensuring the minimum amount deposited/withdrawn was greater than 1e6 (this issue was raised as part of the audit's findings)

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.

Disclaimer