Platform: Code4rena
Start Date: 14/03/2024
Pot Size: $49,000 USDC
Total HM: 3
Participants: 51
Period: 7 days
Judge: 3docSec
Id: 350
League: ETH
Rank: 41/51
Findings: 1
Award: $21.28
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: roguereggiant
Also found by: 0xbrett8571, 0xepley, Circolors, JCK, JcFichtner, LinKenji, MSK, Myd, SAQ, SBSecurity, albahaca, cheatc0d3, clara, emerald7017, fouzantanveer, foxb868, hunter_w3b, kaveyjoe, popeye, unique
21.2754 USDC - $21.28
the Smart Wallet system provides a comprehensive framework for managing smart contract wallets, supporting multiple owners, secure signature verification, and efficient account management, all within a single, integrated protocol.It supports multiple owners for smart contracts, utilizing both Ethereum addresses and secp256r1 public keys, ensuring robust access control and permissions management. The MultiOwnable contract is a cornerstone of this system, enabling the management of multiple owners with a focus on security and efficiency.For signature verification, the system implements the ERC-1271 standard, specifically tailored for CoinbaseSmartWallet, to act as a proxy for signers and protect against cross-account replay attacks. This standard is crucial for verifying signatures on behalf of contracts, enhancing the system's security posture.The CoinbaseSmartWalletFactory contract, compliant with ERC-4337, serves as a factory for creating CoinbaseSmartWallet accounts, introducing account abstraction in Ethereum for more flexible and user-friendly account management. This contract leverages the Solidity library LibClone for creating deterministic ERC-1967 proxy contracts, ensuring each new account is uniquely identified.The CoinbaseSmartWallet contract itself is an ERC-4337 compliant smart account, incorporating features from Solady's ERC4337 account implementation and inspired by Alchemy's LightAccount and Daimo's DaimoAccount. It supports both Ethereum addresses and secp256r1 public keys as identifiers for owners, offering a comprehensive set of functionalities including signature validation, batch execution of calls, and cross-chain replayable transactions.The MagicSpend contract supports signature-based withdrawals, compliant with the ERC-4337 EntryPoint v0.6 specification, facilitating secure and efficient withdrawals by leveraging signature validation and nonce management. This contract is part of the broader ecosystem of ERC-4337, enabling more flexible and user-friendly account management.The system also integrates the WebAuthn library for verifying WebAuthn Authentication Assertions, utilizing the RIP-7212 precompile for signature verification as a fallback to the FreshCryptoLib, ensuring secure authentication within the Ethereum ecosystem. Additionally, the FCL library is designed for verifying secp256r1 signatures, focusing on optimized elliptic curve cryptography (ECC) operations for Ethereum smart contracts, enhancing the system's security and efficiency.
_ ERC1271.sol: The contract is designed to work with EIP-712, a standard for hashing and signing of typed structured data. It aims to improve the usability of off-chain message signing for on-chain use, providing a secure and standardized method for verifying signatures. The contract includes functions for generating EIP-712 compliant hashes (_eip712Hash and replaySafeHash), validating signatures (isValidSignature), and defining the EIP-712 domain (eip712Domain and domainSeparator). These functionalities are crucial for ensuring the integrity and security of transactions and interactions within the smart contract ecosystem.
_ CoinbaseSmartWalletFactory.sol: The CoinbaseSmartWalletFactory operates by deploying new ERC-4337 compliant accounts using a deterministic addressing scheme. This is achieved through the use of CREATE2 for account creation, ensuring that the order of account creation does not interfere with the generated addresses. The factory contract is designed to be staked if it accesses global storage, as per the ERC-4337 specifications, to mitigate potential risks associated with global state access. The contract also includes functionality for predicting the address of an account before it is deployed, enhancing the user experience by allowing for address verification without the need for deployment.
_ CoinbaseSmartWallet.sol: The CoinbaseSmartWallet operates as a smart contract wallet that supports multiple owners, allowing for flexible access control and transaction management. It utilizes the UUPSUpgradeable contract for upgradeability, ensuring that the contract can be updated to fix bugs, add features, or improve security without affecting the existing state. The Receiver contract enables the wallet to receive funds, while the ERC1271 contract provides a standard interface for validating signatures, facilitating secure interactions with the wallet. The contract also includes mechanisms for executing batch transactions and validating user operations, enhancing its utility and efficiency.
_ MagicSpend.sol: The MagicSpend contract operates within the ERC-4337 framework, serving as a paymaster that enables accounts to withdraw funds securely. It supports ETH withdrawals, with a structured approach to managing withdrawal requests, including signature validation, nonce tracking, and expiry management. The contract is designed to be integrated with an ERC-4337 EntryPoint, which acts as the central point for validating and executing user operations. The MagicSpend contract's functionality is extended to support paymasters, allowing it to sponsor transactions for other users, facilitating use cases such as subsidizing fees or enabling fee payment with ERC-20 tokens.
_ WebAuthn.sol: The WebAuthn library operates by verifying the authenticity of WebAuthn assertions. It checks various aspects of the assertion, including the authenticator data, client data JSON, and the signature over the authenticator data and client data JSON. The library supports verification of the "User Present" and "User Verified" flags within the authenticator data, ensuring that the user was present and, if required, verified during the authentication process. It also verifies the type of the client data JSON and the challenge contained within it, aligning with the WebAuthn specification's requirements for assertion verification.
_ FCL.sol: The FCL library operates by providing a set of functions for ECDSA signature verification on the secp256r1 curve. It includes core functions for verifying signatures (ecdsa_verify) and supporting functions for elliptic curve operations, such as checking if a point is on the curve (ecAff_isOnCurve) and performing modular inversion (FCL_nModInv). The library is designed to be efficient and secure, utilizing assembly language for critical operations and optimizing memory access to minimize gas costs. It also supports the use of precomputations to further reduce the computational overhead of ECC operations on the EVM.
Codebase Quality Categories | Comments |
---|---|
Code Maintainability and Reliability | The system is well-structured and follows good practices for maintainability and reliability. It uses a modular approach with internal functions for adding and removing owners, which helps in keeping the codebase organized and reduces the risk of bugs. |
Code Comments | The contract is well-commented, providing clear explanations for the purpose of each function, modifier, and error. This enhances readability and maintainability |
Documentation | The contract includes detailed comments and documentation, which is crucial for understanding the contract's functionality and ensuring that it can be easily maintained and extended. |
Code Structure and Formatting | The contract is structured logically, with clear separation of concerns and consistent formatting. This makes the code easier to read and understand. |
Error Handling | The contract uses Solidity's error handling mechanism to provide clear and informative error messages, which aids in debugging and understanding the contract's behavior |
Testing | The audit scope of the contracts to be audited is in the range of 75% to 95% and it should be aimed to be 100%. |
CoinbaseSmartWalletFactory.sol
contract allows for the creation of CoinbaseSmartWallet accounts with a set of initial owners. While this design inherently requires some level of privileged access to manage the accounts, the risk lies in the potential for a small group of individuals to control a significant portion of the wallets if they are the initial owners. This could lead to centralization if these individuals have the power to manipulate the contract's logic or the wallets' operations.CoinbaseSmartWallet.sol
contract utilizes a MultiOwnable pattern, allowing for multiple owners. However, the access control mechanisms (onlyEntryPoint, onlyEntryPointOrOwner) are primarily focused on restricting actions to the EntryPoint or the owners. This setup does not inherently prevent a small group of owners from having disproportionate control over the contract's operations, especially if they are the initial owners.In general, The Smart Wallet protocol presents a well-designed architecture. the Smart Wallet Ethereum ecosystem, including owner management, signature verification, authentication, and account creation. While they effectively leverage respective standards and methodologies to ensure security and standardization, careful consideration is imperative regarding potential security risks, particularly in preventing frontrunning attacks.
18 hours
#0 - c4-pre-sort
2024-03-22T21:10:17Z
raymondfam marked the issue as sufficient quality report
#1 - c4-judge
2024-03-27T10:26:52Z
3docSec marked the issue as grade-b