Rhinestone’s ERC-7579 adapter for Safe smart accounts ensures complete compliance with ERC-4337 and ERC-7579, functioning as both Safe’s Fallback handler and an enabled module. This configuration allows all Safe smart accounts to leverage the capabilities of ERC-7579 modules. The adapter can be integrated into existing Safe smart accounts, and a launchpad has also been created to facilitate the establishment of new Safe smart accounts with the ERC-7579 adapter pre-enabled.
Rhinestone engaged Ackee Blockchain Security for a comprehensive security review of the Rhinestone ERC-7570 adapter for Safe smart accounts, spanning a total of 16 engineering days from June 3 to June 14, 2024.
Additionally, Rhinestone enlisted Ackee Blockchain Security to conduct an incremental security review of an updated Safe7579 module, dedicating 3 engineering days from July 2 to July 5, 2024.
METHODOLOGY
Our review commenced with static analysis tools, utilizing Wake in conjunction with the Solidity (Wake) VS Code extension. We then conducted an in-depth analysis of the contract logic. For testing and fuzzing, we employed the Wake testing framework. Throughout the review, we focused on:
- verifying Safe deployment via the Launchpad,
- assessing module management logic and the installation of various module types,
- evaluating fallback handler implementation,
- identifying potential DoS scenarios,
- examining front-running vulnerabilities,
- ensuring the correct use of delegatecalls,
- detecting potential reentrancy risks within the code,
- verifying compliance with the utilized ERCs,
- ensuring proper access control measures are enforced,
- identifying common issues, including data validation errors.
SCOPE
The audit was conducted on the commit 90dd363
, with the following scope:
- core/
- AccessControl.sol
- ExecutionHelper.sol
- Initializer.sol
- ModuleManager.sol
- RegistryAdapter.sol
- SetupDCUtil.sol
- lib/
- ExecutionLib.sol
- ModeLib.sol
- utils/
- DCUtil.sol
- Safe7579UserOperationBuilder.sol
- DataTypes.sol
- Safe7579.sol
- Safe7579Launchpad.sol
FINDINGS
Below are the findings from our audit.
Critical severity
C1: ERC-4337 counterfactual address vulnerability leading to potential theft
High severity
H1: initializeAccount
susceptible to front-running
H2: Inability to utilize Executors
Medium severity
M1: Event and onInstall
invocation absent in _initModules
M2: BatchedExecUtil._tryExecute
success value inverted
M3: Single return value in BatchedExecUtil.tryExecute
M4: ModuleManager._installHook
SIG hook being overwritten
M5: Ether locked without a method to retrieve
Low severity
L1: Validation issues with fallback handler CallType
L2: Missing domain-specific message encoding in signedMessages
L3: Violation of ERC-4337 factory standards
L4: Validation deficiencies for _multiTypeInstall
module type
Warning severity
W1: postCheck
function diverges from EIP-7579 interface
W2: uninstallModule
fails on multi-type module
W3: Hook functionality may obstruct module uninstallation
W4: Absence of necessary data validations
W5: Public function prefixing with underscore
W6: Hardcoded Enum.Operation values present
W7: Incomplete Safe7579UserOperationBuilder implementation
W8: Lack of TryExecutionFailed
emit statements
Information severity
I1: Instances of duplicated code
I2: Unused code segments
I3: Typographical errors and inaccuracies in documentation
I4: Issues with overall code structure
W9: Safe lacking implementation of validator interface
W10: Inconsistent checking of signatures
I5: Unneeded usage of using-for
I6: Typographical error detected
CONCLUSION
Our review identified 28 findings, categorized from Informational to Critical severity. The most significant issue allows an attacker to potentially control Safe deployments via the Launchpad (refer to C1). Additional high-severity issues are related to the front-running risk associated with the Safe7579.initializeAccount function (H1) and the improper context in the withRegistry modifier within the Safe7579.executeFromExecutor function (H2). The medium severity findings include mostly overlooked trivial errors. Overall, the code quality is average, with some TODO comments, unused code, and a lack of comprehensive NatSpec documentation.
Ackee Blockchain Security advises Rhinestone to:
- address the potential for newly deployed Safe takeovers,
- protect the
Safe7579.initializeAccount
function from front-running vulnerabilities, - correct the context in the
withRegistry
modifier withinSafe7579.executeFromExecutor
, - resolve the SIG hooks that are being overridden,
- fix batch execution return value issues,
- invoke the module
onInstall
function during the_initModule
process, - eliminate all TODOs and remove any unused code,
- ensure the entire codebase is covered with NatSpec documentation,
- attend to all remaining reported issues,
- additionally, we suggest ongoing internal peer code reviews.
The complete audit report from Ackee Blockchain Security for Rhinestone, detailing all findings and recommendations, is available here.
We were pleased to conduct the audit for Rhinestone and look forward to future collaborations.