Shell Protocol - clara's results

Shell Protocol is DeFi made simple. Enjoy powerful one-click transactions, unbeatably capital-efficient AMMs, and a modular developer experience.

General Information

Platform: Code4rena

Start Date: 27/11/2023

Pot Size: $36,500 USDC

Total HM: 0

Participants: 22

Period: 8 days

Judge: 0xA5DF

Id: 308

League: ETH

Shell Protocol

Findings Distribution

Researcher Performance

Rank: 15/22

Findings: 1

Award: $44.92

Analysis:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

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

Awards

44.915 USDC - $44.92

External Links

Any comments for the judge to contextualize your findings:

The provided Solidity code encompasses smart contracts related to decentralized finance (DeFi), specifically adapters for interacting with Curve Finance pools and an abstract helper contract within an Ocean ecosystem. The analysis focuses on understanding the functionality, security considerations, and potential improvements for each contract.

Approach taken in evaluating the codebase:

The assessment involved a thorough examination of each contract's functionality, security measures, and code quality. Emphasis was placed on understanding the purpose of immutables and state variables, scrutinizing dependencies on external systems, and evaluating error handling. Special attention was given to potential vulnerabilities, reentrancy risks, and centralization concerns. The analysis considered the contracts' reliance on external primitives, addressing governance and token wrapping/unwrapping mechanisms. The goal was to provide a concise yet comprehensive overview, highlighting strengths and proposing specific recommendations for enhancing security, decentralization, and overall code quality.

Architecture recommendations:

  1. Curve2PoolAdapter.sol:

    • Functionality: Facilitates interactions with a Curve Finance 2pool through the Ocean platform.

    • Security Concerns:

      • Unlimited Approvals: The use of type(uint256).max for token approvals poses a risk. Suggest considering more granular approval amounts.
      • Index Validation: Lack of validation for Curve pool indices could lead to incorrect interactions.
      • Reentrancy Guard: Implement reentrancy guards to secure against potential vulnerabilities in external calls.
    • Recommendations:

      • Limited Approvals: Consider approving only the necessary amount for each operation.
      • Index Validation: Validate Curve pool indices to ensure correctness.
      • Reentrancy Guard: Introduce reentrancy guards for external calls.
  2. CurveTricryptoAdapter.sol:

    • Functionality: Facilitates interactions with the Curve Tricrypto pool within the Ocean protocol.

    • Security Concerns:

      • Primitive Address: The contract assumes the provided primitive address is legitimate; validate this to prevent potential exploits.
      • Reentrancy Guard: Implement reentrancy guards for external calls.
      • Approval Risk: Consider limiting token approvals to minimize potential risks.
    • Recommendations:

      • Validation: Validate the legitimacy and security of the primitive address.
      • Reentrancy Guard: Implement reentrancy guards for external calls.
      • Limited Approvals: Consider approving only the necessary amount for each operation.
  3. OceanAdapter.sol:

    • Functionality: Abstract helper contract for interactions between an Ocean system and an external primitive.

    • Security Concerns:

      • Unwrap Fee Calculation: Potential rounding errors in unwrap fee calculation; ensure secure handling.
      • ERC1155 Handling: The onERC1155Received function may pose a risk; review its implementation for security.
      • Abstract Functions: Security depends on correct implementation in derived contracts; thorough audits are crucial.
    • Recommendations:

      • Rounding Errors: Safeguard against rounding errors in unwrap fee calculation.
      • ERC1155 Handling: Ensure proper handling of incoming ERC1155 tokens.
      • Audit Derived Contracts: Conduct thorough audits of contracts extending this abstract contract.
  4. Ocean.sol:

    • Functionality: Integral part of a DeFi framework interacting with various token standards and custom primitives.

    • Security Concerns:

      • Reentrancy Risk: Despite status flags, validate all external calls for reentrancy.
      • Decimal Handling: Ensure all ERC-20 tokens implement the decimals() function to prevent potential issues.
      • Fee Governance: Implement governance or timelocks for changes to the unwrap fee divisor.
    • Recommendations:

      • Reentrancy Validation: Thoroughly validate external calls for reentrancy risks.
      • Decimal Handling: Implement checks to ensure ERC-20 tokens comply with expected standards.
      • Governance Mechanism: Introduce governance or timelocks for changes to fee-related parameters.

Codebase quality analysis:

The overall quality of the codebase is commendable, showcasing a structured design and alignment with modern Solidity practices. The contracts are logically organized, making them easy to understand. However, certain security considerations should be addressed to enhance the codebase's robustness.

  • Structured Design: The contracts follow a modular and well-organized structure, aiding readability and maintainability.

  • Immutables Usage: Leveraging immutables for Ocean IDs, token indices, and decimals enhances security and prevents unintended modifications.

  • Custom Errors: The definition of custom errors, such as INVALID_COMPUTE_TYPE() and SLIPPAGE_LIMIT_EXCEEDED(), contributes to effective error handling.

  • Use of Events: Proper use of events like Swap, Deposit, and Withdraw provides transparency and aids in tracking on-chain activities.

  • Potential Improvements: While the codebase is sound, addressing concerns such as unlimited approvals, index validation, and reentrancy guards would elevate its security posture.

Centralization risks:

The contracts exhibit minimal centralization risks within their intrinsic design. However, external dependencies on platforms like Curve Finance and the Ocean system introduce potential points of centralization.

  • External Dependencies: Relying on external contracts, such as Curve Finance pools and the Ocean platform, may introduce centralization risks if these external entities are compromised.

  • Address Validation: Ensuring the legitimacy and security of external addresses, especially the primitive address, is vital to prevent centralization vulnerabilities.

  • Governance Consideration: The ability to change the unwrap fee divisor introduces centralization risks if not governed properly. Implementing decentralized governance mechanisms can mitigate this.

Mechanism review:

While the mechanisms within the contracts are generally effective, several areas require careful attention to ensure secure token interactions and prevent potential vulnerabilities.

  • Token Wrapping/Unwrapping: The mechanisms for wrapping and unwrapping tokens within the Ocean protocol are well-defined and facilitate seamless interactions.

  • Primitive Interaction: The contracts successfully interact with external primitives, executing actions like swaps, deposits, and withdrawals effectively.

  • Reentrancy Guards: Reentrancy guards are not consistently implemented across all contracts, potentially posing risks during external contract calls. Ensuring comprehensive reentrancy protection is crucial.

  • Custom Errors: The definition of custom errors enhances the contracts' error handling capabilities, providing users with meaningful feedback.

Systemic risks:

The systemic risks primarily revolve around the dependencies on external contracts and platforms, emphasizing the need for thorough audits and validation.

  • Curve Finance Contracts: Assuming the correctness of Curve pool indices and the security of Curve Finance contracts introduces systemic risks. A comprehensive audit of Curve Finance contracts is essential.

  • Ocean Platform: The reliance on the Ocean platform requires diligent validation to ensure its security. Thorough testing and auditing are recommended.

  • Address Verification: Verifying the legitimacy of addresses, particularly the primitive contract, is crucial to prevent systemic vulnerabilities resulting from incorrect or malicious addresses.

  • Comprehensive Audits: Conducting extensive audits of both external dependencies and the contract codebase is imperative to identify and mitigate systemic risks effectively.

In conclusion while the codebase exhibits strong design principles, addressing specific security considerations, implementing additional safeguards, and conducting thorough audits will fortify the contracts against potential risks and contribute to a more resilient DeFi ecosystem.

Time spent:

7 hours

#0 - c4-pre-sort

2023-12-10T16:47:52Z

raymondfam marked the issue as sufficient quality report

#1 - c4-judge

2023-12-17T11:43:57Z

0xA5DF 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