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

Audit name:

[SCA] Credbull | DeFi | Jul2024

Date:

Aug 15, 2024

Table of Content

→Introduction
→Audit Summary
→System Overview
→Risks
→Findings
→Appendix 1. Severity Definitions
→Appendix 2. Scope
→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 is an ERC-4626 vault system.

Document

NameSmart Contract Code Review and Security Analysis Report for Credbull
Audited ByOlesia Bilenka, Andy Cho
Approved ByAtaberk Yavuzer
Websitehttps://credbull.io/→
Changelog26/07/2024 - Preliminary Report
15/08/2024 - Final Report
PlatformArbitrum
LanguageSolidity
TagsVault; Yield Farming
Methodologyhttps://hackenio.cc/sc_methodology→
  • Document

    Name
    Smart Contract Code Review and Security Analysis Report for Credbull
    Audited By
    Olesia Bilenka, Andy Cho
    Approved By
    Ataberk Yavuzer
    Changelog
    26/07/2024 - Preliminary Report
    15/08/2024 - Final Report
    Platform
    Arbitrum
    Language
    Solidity
    Tags
    Vault; Yield Farming

Review Scope

Repositoryhttps://github.com/credbull/credbull-defi/→
Commitf927c85
Remediation commitce1c17e

Audit Summary

10Total Findings
7Resolved
2Accepted
1Mitigated

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 is provided.

  • NatSpec comments are provided.

Code quality

  • The code mostly follows best practices and styleguides.

  • The development environment is configured.

Test coverage

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

  • Deployment and basic user interactions are covered with tests.

System Overview

Credbull is an ERC-4626 vault system with the following contracts:

Vault \- is an abstract smart contract based on OpenZeppelin's ERC4626, designed to manage ERC20 token deposits with enhanced security. Deposited assets are transferred to a designated CUSTODIAN address, with the contract maintaining records of total assets deposited. The contract includes functions for depositing, minting, withdrawing, and redeeming assets, with built-in error handling for invalid operations. Additionally, it features access control mechanisms and the ability to pause operations for security purposes.

MaturityVault \- is an abstract contract extends the Vault by adding a maturity feature, preventing further deposits once matured. It tracks whether the vault is matured and includes functions to mature the vault and check maturity status. This ensures that only existing assets and any accrued yield are managed after maturity.

FixedYieldVault \- is a contract that extends the MaturityVault and integrates additional features from WhiteListPlugin, WindowPlugin, and MaxCapPlugin. It allows deposits and redemptions based on set windows and caps, and it offers a fixed yield to users. The contract includes mechanisms for maturity checking and whitelisting, ensuring that only approved addresses can interact with it. The FixedYieldVault also has functionality to pause operations and to withdraw any ERC20 tokens held by the contract.

UpsideVault \- is a contract that extends the functionality of the FixedYieldVault by integrating collateral management using the Credbull token (CBL). Users must deposit collateral in CBL tokens alongside their main assets, with the required collateral amount determined by a specified percentage of the asset value and the current TWAP (Time-Weighted Average Price). The contract allows for both deposits and withdrawals while ensuring the proper handling and accounting of the collateral. Additionally, the contract has a mechanism to update the TWAP value, which is crucial for calculating the collateral requirements.

VaultFactory \- is a factory designed to manage the creation and oversight of vault contracts. It maintains sets of allowed custodians and created vaults, allowing only authorized custodians to interact with the factory. The contract allows administrators to add or remove custodians and provides functions to query the list of created vaults and validate custodians.

WhiteListProvider - is a contract that manages a whitelist of addresses that can be used by other contracts to determine if addresses are authorized. It allows the owner to update the whitelist status of multiple addresses at once. The contract tracks whitelist status through a mapping and provides a function to check if an address is whitelisted.

MaxCapPlugin - is a contract that provides functionality to enforce a maximum cap on asset deposits in a vault. It tracks the maximum allowed cap through the maxCap variable and uses a boolean flag, checkMaxCap, to enable or disable the cap enforcement. The contract provides internal functions to check if the deposited amount exceeds the cap, update the cap value, and toggle the cap check status.

WhiteListPlugin - is a contract that manages white-listing functionality within a vault system. It enforces that certain addresses must be white-listed to perform operations, such as deposits, if their transaction amount meets or exceeds a specified threshold (depositThresholdForWhiteListing). The white-list status is determined through an external IWhiteListProvider contract. The plugin includes internal functions for checking white-list status and toggling the white-list check.

WindowPlugin - is a contract that contract manages deposit and redemption time windows for a vault. It defines time periods during which deposits and redemptions are permitted, using timestamps for opening and closing these windows. The plugin includes functions to check whether operations fall within these time windows, update window timestamps, and toggle the window check functionality.

CredbullFixedYieldVault - is a straightforward implementation of the FixedYieldVault contract. It serves as a specific instance of FixedYieldVault with no additional functionality or modifications.

CredbullFixedYieldVaultFactory - is a contract that extends the VaultFactory and is designed to facilitate the creation of CredbullFixedYieldVault instances. It provides functionality for deploying new vaults and managing the list of allowed custodians and vault addresses.

CredbullFixedYieldVaultWithUpside - is a contract that extends the UpsideVault and is tailored to integrate additional upside functionality into the fixed yield vault. It leverages the existing features of UpsideVault, which itself extends FixedYieldVault, to provide enhanced capabilities for handling collateral and deposit-redemption windows.

CredbullUpsideVaultFactory - is a contract that extends VaultFactory to create instances of CredbullFixedYieldVaultWithUpside. This factory contract provides functionality for deploying new vaults that integrate both fixed yield and upside features.

CredbullWhiteListProvider - is an implementation that extends the WhiteListProvider contract. It inherits the functionality for managing a whitelist of addresses from WhiteListProvider, including updating whitelist statuses and querying the whitelist status of an address.

Privileged roles

  • The DEFAULT_ADMIN_ROLE in the Vault contract has the authority to pause and unpause contract operations, impacting the ability of users to deposit or withdraw assets. They can also set the custodian address and modify parameters related to asset management, such as asset decimals and share token settings.

  • The DEFAULT_ADMIN_ROLE in the MaturityVault contract has the authority to toggle the maturity check, initiate the vault's maturation process, and manage other critical parameters, affecting the vault's operational status and asset management.

  • The DEFAULT_ADMIN_ROLE in the FixedYieldVault contract has significant control, including the ability to toggle checks for maturity, whitelisting, window periods, and max cap, as well as to update the max cap value and window timestamps. The OPERATOR_ROLE can initiate the vault's maturation process and setting the TWAP value (UpsideVault contract). These roles hold significant power over the contract's functionality and the management of user assets.

  • The DEFAULT_ADMIN_ROLE in the VaultFactory contract has broad control, including adding or removing custodian addresses and managing factory-wide settings. The OPERATOR_ROLE does not have direct access to this contract's functions but is important in related contexts where vaults are created and managed.

  • The owner is of the WhiteListProvider contract is authorized to update the whitelist status of addresses and make changes to the whitelist.

  • OPERATOR_ROLE role can create new CredbullFixedYieldVault instances. It must be a valid custodian to create a vault

Risks

Owner's Unrestricted State Modification: The absence of restrictions on state variable modifications by the owner leads to arbitrary changes, affecting contract integrity and user trust, especially during critical operations like minting phases.

Absence of Time-lock Mechanisms for Critical Operations: Without time-locks on critical operations, there is no buffer to review or revert potentially harmful actions, increasing the risk of rapid exploitation and irreversible changes.

Single Points of Failure and Control: The project is fully or partially centralized, introducing single points of failure and control. This centralization can lead to vulnerabilities in decision-making and operational processes, making the system more susceptible to targeted attacks or manipulation.

Findings

F-2024-4404Centralization Risk in Vault System Leading to Deposit Lock
Status
mitigated
Severity

Medium
F-2024-4396Risk of Ownership Control Loss in Owner-Dependent Contracts
Status
fixed
Severity

Low
F-2024-4419Violation of Checks-Effects-Interactions Pattern
Status
accepted
Severity

Observation
F-2024-4416Missing Validation for collateralPercentage and twap in UpsideVault Contract
Status
fixed
Severity

Observation
F-2024-4414Missing Zero Addresses Validations Leading to Misconfiguration
Status
fixed
Severity

Observation
F-2024-4403State Variables That Should Be Immutable
Status
fixed
Severity

Observation
F-2024-4400Lack of Configuration Events
Status
fixed
Severity

Observation
F-2024-4399Redundant Fallback and Receive Functionality
Status
fixed
Severity

Observation
F-2024-4398Missing Validation for Time Windows in WindowPlugin Contract
Status
fixed
Severity

Observation
F-2024-4397Floating Pragma
Status
accepted
Severity

Observation
Code
―
Title
Status
Severity
F-2024-4404Centralization Risk in Vault System Leading to Deposit Lock
mitigated

Medium
F-2024-4396Risk of Ownership Control Loss in Owner-Dependent Contracts
fixed

Low
F-2024-4419Violation of Checks-Effects-Interactions Pattern
accepted

Observation
F-2024-4416Missing Validation for collateralPercentage and twap in UpsideVault Contract
fixed

Observation
F-2024-4414Missing Zero Addresses Validations Leading to Misconfiguration
fixed

Observation
F-2024-4403State Variables That Should Be Immutable
fixed

Observation
F-2024-4400Lack of Configuration Events
fixed

Observation
F-2024-4399Redundant Fallback and Receive Functionality
fixed

Observation
F-2024-4398Missing Validation for Time Windows in WindowPlugin Contract
fixed

Observation
F-2024-4397Floating Pragma
accepted

Observation
1-10 of 10 findings

Identify vulnerabilities in your smart contracts.

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

Repositoryhttps://github.com/credbull/credbull-defi/→
Commitf927c850b628a63dd71e5c6a1e8888e89a6262e5
Remediation commitce1c17ea94494d985c516f0ac3be379cb2fef8e3
WhitepaperCredbull High Level Architecture (SHA256: 13117d79fe1da3f456fad5b0c0d24c956bb8552b1e9c40b97c2d90c6f50cf4f6)
https://docs.credbull.io/docs/litepaper→

Contracts in Scope

packages
contracts
src
factory
VaultFactory.sol - packages › contracts › src › factory › VaultFactory.sol
plugin
MaxCapPlugin.sol - packages › contracts › src › plugin › MaxCapPlugin.sol
WhiteListPlugin.sol - packages › contracts › src › plugin › WhiteListPlugin.sol
WindowPlugin.sol - packages › contracts › src › plugin › WindowPlugin.sol
provider
whiteList
IWhiteListProvider.sol - packages › contracts › src › provider › whiteList › IWhiteListProvider.sol
WhiteListProvider.sol - packages › contracts › src › provider › whiteList › WhiteListProvider.sol
vault
FixedYieldVault.sol - packages › contracts › src › vault › FixedYieldVault.sol
MaturityVault.sol - packages › contracts › src › vault › MaturityVault.sol
UpsideVault.sol - packages › contracts › src › vault › UpsideVault.sol
Vault.sol - packages › contracts › src › vault › Vault.sol
CredbullFixedYieldVault.sol - packages › contracts › src › CredbullFixedYieldVault.sol
CredbullFixedYieldVaultFactory.sol - packages › contracts › src › CredbullFixedYieldVaultFactory.sol
CredbullFixedYieldVaultWithUpside.sol - packages › contracts › src › CredbullFixedYieldVaultWithUpside.sol
CredbullUpsideVaultFactory.sol - packages › contracts › src › CredbullUpsideVaultFactory.sol

Disclaimer