-
Notifications
You must be signed in to change notification settings - Fork 8
Security Considerations
The security architecture of Nexus Smart Accounts is designed to ensure the integrity, authenticity, and reliability of all operations. By implementing strict validation protocols, preventing delegate calls, enforcing validator presence, and leveraging ERC-7739 and EIP-712 security standards, Nexus delivers a secure and modular smart account framework suitable for complex and high-value operations. This section outlines the key security considerations and measures implemented in Nexus Smart Accounts.
Important
A validation module must always be present in the Nexus Smart Account. Without a validator, the account cannot securely process operations. Validators ensure compliance with the rules and prevent unauthorized operations.
- Ensures Authenticity: Validates the authenticity of transactions, preventing unauthorized access and operations.
- Mitigates Risks: Reduces the risk of fraudulent activities by ensuring that only validated transactions are executed.
- Maintains Integrity: Helps maintain the integrity of the smart account by enforcing validation rules.
The addDeposit
function allows adding deposits to the smart account without checking if the amount is zero (msg.value
). While this simplifies the function, it is important to be aware of this behavior to avoid accidental zero-value transactions.
Caution
Be cautious when calling the addDeposit
function to ensure that a non-zero amount is provided. This helps avoid unnecessary calls that do not affect the account balance.
Nexus implements delegate call functionality for greater flexibility when executing complex transactions. While delegate calls can introduce additional security challenges, Nexus mitigates these risks through the following measures:
- Strict Access Controls: Only trusted modules and authorized entities can invoke delegate calls, minimizing the risk of malicious execution.
- Enhanced Security Auditing: Each delegate call is subject to strict security audits to ensure it does not introduce vulnerabilities like reentrancy or state manipulation.
- Controlled Context: Delegate calls are limited to predefined operations, ensuring that they operate within a secure context without overriding the account's storage unexpectedly.
Note
Nexus decided not to implement any delegate call type. This decision enhances security by avoiding vulnerabilities like reentrancy attacks and state manipulation, which are common risks associated with delegate calls in smart contracts.
- Prevents Code Injection: Reduces the risk of code injection attacks where malicious code could be executed within the context of the calling contract.
- Simplifies Security: Simplifies the security model by eliminating the need to handle the additional risks associated with delegate calls.
The Nexus framework includes checks to ensure that the last validator cannot be removed. This is crucial for maintaining the security and integrity of the smart account.
Warning
The system reverts if attempting to remove the last validator. This prevents the smart account from operating without any validators, which is critical for maintaining security.
-
Selectors Restriction: The selectors
onInstall(bytes)
(0x6d61fe70) andonUninstall(bytes)
(0x8a91b0e3) are explicitly forbidden. This prevents unauthorized users from uninstalling and reinstalling critical modules.
Nexus implements the ERC-7201 namespaced storage pattern for isolated storage access. Each module operates within its own storage namespace, drastically reducing the chance of storage collisions or unauthorized access across modules. This ensures storage independence and enhances modularity.
- Isolated Storage: Ensures that each module operates within its own storage namespace, preventing data collision.
- Enhanced Security: Reduces the risk of storage conflicts and unauthorized data access across modules.
Tip
Using the ERC-7201 namespaced storage pattern enhances modularity and security by ensuring that storage operations are scoped to specific modules.
Note
Hook modules add additional logic before and after transaction executions, enhancing security by enabling custom pre and post-execution checks.
- Pre-Execution Hooks: Validate and prepare data before the main execution.
- Post-Execution Hooks: Perform cleanup or additional validations after the main execution.
Caution
Fallback handlers manage transactions that do not match predefined function signatures or encounter errors, providing a mechanism for handling unexpected conditions gracefully.
- Error Handling: Ensure that the smart account can recover from unexpected conditions.
- Graceful Degradation: Allow the account to continue operating even when some operations fail.
Nexus contracts incorporate robust access control layers, with key mechanisms such as:
- onlyEntryPointOrSelf: Ensures only the EntryPoint or the smart account itself can invoke critical functions.
- onlyExecutorModule: Restricts execution to trusted modules.
- Immutable EntryPoint Address: This locks the EntryPoint address post-deployment, ensuring that it cannot be changed, which secures the primary point of interaction for operations.
Nonce management is crucial for preventing replay attacks:
Unique Nonces: Each transaction is ensured to be unique, with the nonce encoding the validator’s address, tying each operation to a specific validator.
The replaySafeHash function generates EIP-712 compliant hashes, ensuring message uniqueness by binding each operation to specific contexts, including the validator’s address and other transaction data. This prevents replay attacks across different smart accounts by ensuring signatures are valid only for the intended recipient and context.
The security considerations in Nexus Smart Accounts are designed to ensure the integrity, authenticity, and reliability of smart contract operations. By implementing strict validation rules, avoiding delegate calls, enforcing validator checks, and using isolated storage patterns, Nexus provides a secure and robust framework for managing smart accounts.
Note
For more detailed information on Nexus Smart Accounts and their security features, refer to the Nexus GitHub repository.
- Home
- Nexus Architecture
- Access Control
- Execution Framework
- Modules
- Factories
- Migration Guide
- Testing Documentation
- Configuration and Security
- Libraries
- FAQ
- Biconomy Solidity Style Guide
- Security Considerations
- Team
-
Contracts
- Nexus
- Base
- Common
- Factory
- AbstractNexusFactory
- BiconomyMetaFactory
- K1ValidatorFactory
- ModuleWhitelistFactory
- NexusAccountFactory
- Modules
- Utils