-
Notifications
You must be signed in to change notification settings - Fork 10
Security Considerations
The Nexus Smart Account framework is designed with robust security mechanisms to ensure the safety and integrity of smart contract 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. This is critical to ensure that all transactions and operations are validated against predefined rules and criteria.
- 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.
Note
Nexus decided not to implement any delegate call type. This decision enhances security by avoiding the complexities and potential vulnerabilities associated with delegate calls.
- 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 uses the ERC-7201 namespaced storage pattern for isolated storage access, making it more collision-resistant.
- 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 utilize multiple layers of access control to ensure that only authorized entities can perform sensitive operations. Key access control mechanisms include:
- Modifiers like onlyEntryPointOrSelf, onlyEntryPoint, and onlyExecutorModule: These restrict access to critical functions, ensuring that only the entry point, the contract itself, or authorized executor modules can execute them.
- Immutable EntryPoint Address: This ensures that the entry point remains constant post-deployment, providing a secure and consistent point of interaction for all 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.
- Replay Safe Hash: The replaySafeHash function generates EIP-712 compliant hashes, ensuring message uniqueness and binding them to specific contexts to prevent replay attacks across different accounts.
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