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: 21/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
List | Head | Details |
---|---|---|
a) | The approach I followed when reviewing the code | Stages in my code review and analysis |
b) | Analysis of the code base | What is unique? How are the existing patterns used? "Solidity-metrics" was used |
c) | Test analysis | Test scope of the project and quality of tests |
d) | Security Approach of the Project | Audit approach of the Project |
e) | Other Audit Reports and Automated Findings | What are the previous Audit reports and their analysis |
f) | Packages and Dependencies Analysis | Details about the project Packages |
g) | Other recommendations | What is unique? How are the existing patterns used? |
h) | New insights and learning from this audit | Things learned from the project |
First, by examining the scope of the code, I determined my code review and analysis strategy. https://github.com/code-423n4/2023-11-shellprotocol
Accordingly, I analyzed and audited the subject in the following steps;
Number | Stage | Details | Information |
---|---|---|---|
1 | Compile and Run Test | Installation | Test and installation structure is simple, cleanly designed |
2 | Architecture Review | Shell | Provides a basic architectural teaching for General Architecture |
3 | Graphical Analysis | Graphical Analysis with Solidity-metrics | A visual view has been made to dominate the general structure of the codes of the project. |
4 | Slither Analysis | Slither Report | |
5 | Test Suits | Tests | In this section, the scope and content of the tests of the project are analyzed. |
6 | Manuel Code Review | Scope | |
7 | Infographic | Figma | I made Visual drawings to understand the hard-to-understand mechanisms |
8 | Special focus on Areas of Concern | Areas of Concern |
The most important summary in analyzing the code base is the stacking of codes to be analyzed. In this way, many predictions can be made, including the difficulty levels of the contracts, which one is more important for the auditor, the features they contain that are important for security (payable functions, uses assembly, etc.), the audit cost of the project, and the time to be allocated to the audit; Uses Consensys Solidity Metrics
</br>// Sample labels vm.label(bob, 'bob'); vm.label(alice, 'alice'); vm.label(DEPLOYER, 'deployer'); vm.label(USDE_OWNER, 'usde owner'); vm.label(POOL_PROXY, 'lending pool');
1 - First they did the main audit from Consensys Diligence and Trail of Bits and resolved all the security concerns in the report
2- They manage the 2nd audit process with an innovative audit such as Code4rena, in which many auditors examine the codes.
1- By distributing the project to testnets, ensuring that the audits are carried out in onchain audit. (This will increase coverage)
2- After the project is published on the mainnet, there should be emergency action plans (not found in the documents)
3- Emergency Action Plan In a high-level security approach, there should be a crisis handbook like the one below and the strategic members of the project should be trained on this subject and drills should be carried out. Naturally, this information and road plan will not be available to the public. https://docs.google.com/document/u/0/d/1DaAiuGFkMEMMiIuvqhePL5aDFGHJ9Ya6D04rdaldqC0/mobilebasic#h.27dmpkyp2k1z
4- ChainAnalysis oracle With the ChainAnalysis oracle, OFAC interaction can be blocked so that legal issues do not arise
</br> </br>Automated Findings: https://github.com/code-423n4/2023-11-shellprotocol/blob/main/bot-report.md
Other Audit Reports (Consensys Diligence and Trail of Bits): https://wiki.shellprotocol.io/getting-started/security-and-bounties#audits
</br> </br>Package | Version | Usage in the project | Audit Recommendation |
---|---|---|---|
openzeppelin | @openzeppelin contracts | - Version 4.8.1 is used by the project, it is recommended to use the newest version 5.0.0 |
✅ The use of assembly in project codes is very low, I especially recommend using such useful and gas-optimized code patterns; https://github.com/dragonfly-xyz/useful-solidity-patterns/tree/main/patterns/assembly-tricks-1
✅ A good model can be used to systematically assess the risk of the project, for example this modeling is recommended; https://www.notion.so/Smart-Contract-Risk-Assessment-3b067bc099ce4c31a35ef28b011b92ff#7770b3b385444779bf11e677f16e101e
✅ All staff accounts for the project should have control policies that require 2FA and must use 2FA wherever possible. 100% comprehensive security cannot be achieved based on smart contract codes alone. Implement a more comprehensive policy to enforce non-SMS 2FA. You can find the latest Simswap attack on Code4rena and details about it in this article: https://medium.com/code4rena/code4rena-twitter-x-incident-8b7f308a555d
✅ The Reentrancy modifier used by Opensea is more gas optimized and battle tested, I recommend you replace the reentrancy structure in the project with this code; https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ReentrancyGuard.sol
✅ I recommend you to set up a system.sol
basic architecture where all contracts are registered.
The entire system can revolve around a single contract, like SystemRegistry. This is the contract that ties all the other contracts together, and from this contract we should be able to list all the other contracts in the system. It's almost like a registry.
🔎 1- Updates to The Ocean in Shell v3: Significant changes include the removal of reentrancy guards for specific methods, enabling Ether wrapping, and a refactoring of the order in which a primitive's balances are updated. These updates facilitate better interaction with external protocols and improve the efficiency of token handling.
🔎 2- Liquidity Pools Adaptation: The LiquidityPoolProxy.sol has been refactored to align with the updated balance management in The Ocean. This involves adjusting values post-balance retrieval, ensuring seamless integration with the new system.
🔎 3- Introduction of Adapter Primitives: Shell v3 introduces OceanAdapter.sol, a generalized interface for adapter primitives, along with example implementations like Curve2PoolAdapter.sol and CurveTricryptoAdapter.sol. These serve as templates for integrating various external protocols with The Ocean.
🔎 4- Invariants and Security Measures in Shell v3: The project outlines several invariants to ensure security and consistency, such as user balance protection, adherence to ERC standards, and specific conditions under which the Ocean can make external transfers or mint tokens. It also notes the Ocean's non-support for rebasing tokens and fee on transfer tokens, along with the implementation of reentrancy checks for enhanced security.
16 hours
#0 - c4-pre-sort
2023-12-10T16:40:58Z
raymondfam marked the issue as high quality report
#1 - c4-sponsor
2023-12-12T04:11:31Z
viraj124 (sponsor) acknowledged
#2 - c4-judge
2023-12-17T11:43:51Z
0xA5DF marked the issue as grade-b