Brahma - JCK's results

Brahma Console is a custody and DeFi execution environment.

General Information

Platform: Code4rena

Start Date: 13/10/2023

Pot Size: $31,250 USDC

Total HM: 4

Participants: 51

Period: 7 days

Judge: 0xsomeone

Id: 295

League: ETH

Brahma

Findings Distribution

Researcher Performance

Rank: 42/51

Findings: 1

Award: $14.47

Analysis:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

14.466 USDC - $14.47

Labels

analysis-advanced
grade-b
sufficient quality report
A-09

External Links

Phase 1: Documentation and Video Review

A: Start with a comprehensive review of all documentation related to the Brahma platform, including the whitepaper, API documentation, developer guides, user guides, and any other available resources.

B: Watch any available walkthrough videos to gain a holistic understanding of the system. Pay close attention to any details about the platform’s architecture, operation, and possible edge cases.

C: Note down any potential areas of concern or unclear aspects for further investigation.

Phase 2: The key contracts of the protocol for this Audit area:

  1. AddressProvider: The AddressProvider contract serves as a single source of truth for resolving addresses of core components and external contracts

  2. AddressProviderService: The AddressProviderService contract provides a base contract for other services to resolve addresses through the AddressProvider.

  3. TransactionValidator : The TransactionValidator contract provides hooks for validation of the various kinds of transactions on Console and SubAccount. These hooks include validating policy/state compliance before and after transactions for both Console and SubAccount via. the guards (SafeModerator & SafeModeratorOverridable), and also for module execution on SubAccount via. ExecutorPlugin.

  4. SafeEnabler The SafeEnabler contract provides bytecode for enabling modules and guards on Safe, during its initialization via DELEGATECALL by the safe itself. The selfAuthorized check on Safe's ModuleManager and GuardManager makes it unfeasible to DELEGATECALL into, to manage module/guard state, and thus, this contract provides bytecode for the same but while bypassing the selfAuthorized check.

  5. ConsoleFallbackHandler The ConsoleFallbackHandler contract acts as a fallback handler for safe. It performs all the same functions as the Safe's CompatibilityFallbackHandler, to provide compatibility between pre 1.3.0 and 1.3.0+ Safe contracts, and additionally also ensures policy validation guarantees required for ConsoleAccounts/SubAccounts that have policy validation enabled. Most of the bytecode in methods are kept as close as possible to CompatibilityFallbackHandler, with the only change being in signature validation, where additional checks are performed to ensure that they are policy compliant.

Phase 3: Architecture recommendations:

  1. Consider providing more comprehensive documentation within the codebase, including detailed explanations of the contract functionalities, usage instructions, and examples. Add comments to clarify the purpose and functionality of each function, especially in complex or critical sections of the code. Consider adding more error messages to provide specific information about the reason for revert conditions. Codebase quality analysis:

  2. Error handling is implemented using custom error messages, which provides better visibility into the reason for reverts. This can assist in debugging and understanding the cause of failures. The contracts are emit events for important operations, allowing better monitoring and debugging. Event emissions can be helpful for tracking contract interactions and capturing important state changes. The contract structures are logical and readable, making it easier to understand the code. Well-organized code structures contribute to maintainability and readability

Phase 4: Codebase quality analysis:

The code appears to be well-structured and follows Solidity best practices. It uses proper error handling with custom error messages and emits events for module enablement and guard changes.

Phase 5: Centralization risks:

  1. addressProvider: The AddressProvider contract relies on a single governance address for managing authorized addresses and registries. Consider implementing a multi-signature or decentralized governance model to reduce centralization risks. The contract does not include mechanisms for on-chain governance decision-making or voting. Consider incorporating a formalized governance process that involves token holders or other stakeholders.

  2. SafeEnabler: The contract introduces the ability to enable modules and set guards bypassing the self-authorization check during initialization. This can be a potential centralization risk as it allows the contract deployer to set up modules and guards without going through the usual authorization process.

  3. SafeModerator: The contract inherits from the AddressProviderService contract, which suggests that it relies on an external address provider for retrieving authorized addresses. Depending on the implementation of the address provider, there could be potential centralization risks if the address provider is controlled by a single entity.

  4. ExecutorRegistry: The contract relies on the WalletRegistry contract for checking ownership of sub-accounts. Depending on the implementation of the WalletRegistry, there could be potential centralization risks if the WalletRegistry is controlled by a single entity.

Phase 6: Systemic Risks:

  1. Centralization of Address Provider: Both contracts inherit from the AddressProviderService contract, which suggests they rely on an external address provider. If the address provider is controlled by a single entity or a small group, it introduces a central point of failure and potential censorship or manipulation of contract behavior.

  2. Dependency on External Contracts: The contracts rely on the WalletRegistry contract from the Brahma.fi protocol. If the implementation of the WalletRegistry has vulnerabilities or is compromised, it could impact the functionality and security of the SafeModerator and ExecutorRegistry contracts.

  3. Insecure or Unaudited Contracts: The contracts do not provide explicit information about the security audits or code reviews conducted on them. Depending on the specific implementation and any potential vulnerabilities, there is a risk of security issues, including potential exploits, bugs, or vulnerabilities that could be exploited by attackers.

  4. Lack of Upgrade Mechanism: The code snippets do not show any upgrade mechanism for the contracts. Introducing upgrades or changes to the contracts without a proper upgrade mechanism can lead to disruptions, incompatibilities, or potential security risks.

  5. External Dependency Risks: The contracts may rely on external systems, such as oracles or external data sources, for their functionality. If these external dependencies are unreliable, manipulated, or compromised, it can impact the integrity and security of the overall protocol.

Phase 8: Recommendations:

  1. Decentralize the Address Provider: Consider implementing a decentralized address provider mechanism that involves multiple parties or a decentralized governance model. This helps mitigate the risk of a single point of failure or potential manipulation by a centralized entity.

  2. Conduct Security Audits: Perform comprehensive security audits of all contracts within the Brahma.fi protocol, including the SafeModerator and ExecutorRegistry contracts, as well as any dependencies like the WalletRegistry contract. Engage reputable security firms or auditors with expertise in smart contract security to identify and address any vulnerabilities or weaknesses.

  3. Implement Upgrade Mechanism:
    Introduce a proper upgrade mechanism for the contracts to ensure that any future upgrades or changes can be executed in a controlled and secure manner. Consider using mechanisms like proxy contracts or upgradeable contract patterns to enable seamless updates without disrupting the protocol's functionality.

  4. Independent Code Reviews: Encourage independent code reviews and peer reviews of the protocol's contracts. External experts can provide valuable insights, identify potential risks, and suggest improvements in the codebase.

  5. Monitor External Dependencies: Continuously monitor and evaluate the reliability and security of external dependencies, such as oracles or data sources. Establish robust mechanisms to verify the integrity and accuracy of the external data used by the protocol to minimize the risk of manipulation or compromise.

  6. Continuous Security Practices: Foster a culture of security within the development and maintenance team. Stay updated on the latest best practices, security standards, and developments in the field of blockchain security. Regularly review and update security measures, conduct penetration testing, and maintain an ongoing process for identifying and addressing security vulnerabilities.

  7. Transparent Communication: Maintain open and transparent communication with the community and users of the protocol. Provide clear information about the security measures, audits, and upgrades to foster trust and confidence in the protocol.

Phase 9: Time Spent

20 hours

Time spent:

20 hours

#0 - c4-pre-sort

2023-10-22T21:12:55Z

raymondfam marked the issue as sufficient quality report

#1 - alex-ppg

2023-10-27T13:38:21Z

The report is decent, however, it does highlight some incorrect concerns such as the SafeEnabler which is pivotal in the system managing to deploy itself with its custom guard properly.

#2 - c4-judge

2023-10-27T13:38:25Z

alex-ppg marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter