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
Rank: 20/22
Findings: 1
Award: $44.92
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Sathish9098
Also found by: 0xSmartContract, 0xepley, LinKenji, Myd, ZanyBonzy, albahaca, alexbabits, clara, foxb868, invitedtea, oakcobalt, peanuts
44.915 USDC - $44.92
The Ocean protocol aims to serve as a flexible foundation for composable DeFi primitives using a single ledger and unified token standard. The core contracts include the main Ocean engine for managing interactions and accounting, ERC-1155 tokenization, and various adapter implementations.
Overall the protocol exhibits well-factored modular design and a novel approach to interoperability and gas optimization. However, the increased flexibility and removal of constraints around reentrancy, permissions, and state management in v3 opens new potential risk vectors that should be carefully assessed.
My analysis evaluated code quality, documentation, functional correctness, security assumptions, risk analysis, adherence to specifications, extensibility, and customizability.
Findings are categorized by severity and tagged for ease of triage by developers. Recommendations in the Mitigations section aim to spur discussion rather than serve as prescriptions.
Ocean Core Engine
This serves as the hub for executing interactions, managing accounting, and integrating with external contracts. Key capabilities:
doInteraction
and doMultipleInteractions
transaction batchesTokenization (OceanERC1155)
The built-in ERC-1155 implementation handles token minting, burning, and transfers. It:
Adapters
These bridge external protocols like Curve by adapting their interfaces into normalized Ocean interactions. Adapters:
Primitives
The target DeFi protocols integrated with Ocean like lending pools, AMMs etc.
Token Wrapping
doInteraction()
Swapping
primitiveOutputAmount
Liquidity Pools
_doInteraction()
_executeInteraction()
_getSpecifiedToken()
OceanERC1155
safeTransferFrom()
_mintBatch()
_convertDecimals()
_determineComputeType()
Mitigations
The Ocean protocol facilitates decentralized finance interactions between users and external DeFi primitives by wrapping assets, executing computed exchanges via adapters, and maintaining a unified ledger.
User submits transactions
doInteraction()
or doMultipleInteractions()
Core engine unpacks details
Adapter processes details
Primitive executes operation
Adapter normalizes output
Ocean logs internal state changes
This architecture supports modular integration of external DeFi protocols using adapters while maintaining a unified ledger and token standard via Ocean's backend.
Strengths
Extensions
Severity Levels
Issue | Severity | Detection |
---|---|---|
Reentrancy in Adapters | High | Dynamic Analysis |
Centralization Risks | Medium | Architecture Review |
Input Validation Gaps | Medium | Static Analysis |
<a id="reentrancy-in-adapters"></a>
Impact: Loss of funds, arbitrary state changes
Removing reentrancy guards allows attackers to initiate recursive calls back into adapters before state is committed.
Mitigations:
<a id="centralization-risks"></a>
Impact: Unauthorized modification of critical parameters
Owner role in core contracts enable unilateral control of fee rates, pause status, and other sensitivie functions.
Mitigations:
<a id="input-validation-gaps"></a>
Impact: Unexpected behavior, contract exploits
Lack of validation around key assumptions could allow attacks like force wrapping unowned tokens.
Mitigations:
36 hours
#0 - c4-pre-sort
2023-12-10T16:46:28Z
raymondfam marked the issue as sufficient quality report
#1 - c4-judge
2023-12-17T11:43:51Z
0xA5DF marked the issue as grade-b