Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update callling function name in DeployEmailRecoveryModuleScript. #20

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
BASE_SEPOLIA_RPC_URL=
PRIVATE_KEY=
BASE_SCAN_API_KEY=
PRIVATE_KEY=
VERIFIER=
DKIM_REGISTRY=
SIGNER=
EMAIL_AUTH_IMPL=
VALIDATOR=
FUNCTION_NAME= # It's used to override the function name in DeployEmailRecoveryModule.s.sol
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,11 @@ The deployment function for this factory deploys an `UniversalEmailRecoveryModul
While the subject handler for `EmailRecoveryUniversalFactory` will be more stable in comparison to a subject handlers used for `EmailRecoveryModule`, developers may want to write a generic subject handler in a slightly different way, or even in a non-english lanaguage, so the bytecode is still passed in here directly. The security of each module deployment and associated contracts can then be attested to via a ERC 7484 registry.

## Threat model
Importantly this contract offers the functonality to recover an account via email in a scenario where a private key has been lost. This contract does NOT provide an adequate mechanism to protect an account from a stolen private key by a malicious actor. This attack vector requires a holistic approach to security that takes specific implementation details of an account into consideration. For example, adding additional access control when cancelling recovery to prevent a malicious actor stopping recovery attempts, and adding spending limits to prevent account draining. Additionally, the current 7579 spec allows accounts to forcefully uninstall modules in the case of a malicious module, this means an attacker could forcefully uninstall a recovery module anyway. This is expected to be addressed in the future. This contract is designed to recover modular accounts in the case of a lost device/authentication method (private key), but does not provide adequate security for a scenario in which a malicious actor has control of the lost device/authentication method (private key).
Importantly this contract offers the functonality to recover an account via email in a scenario where a private key has been lost. This contract does NOT provide an adequate mechanism to protect an account from a stolen private key by a malicious actor. This attack vector requires a holistic approach to security that takes specific implementation details of an account into consideration. For example, adding additional access control when cancelling recovery to prevent a malicious actor stopping recovery attempts, and adding spending limits to prevent account draining. This contract is designed to be extended to take these additional considerations into account, but does not provide them by default.

# Deployment

```
source .env
forge script script/DeployEmailRecoveryModule.s.sol:DeployEmailRecoveryModuleScript --rpc-url $BASE_SEPOLIA_RPC_URL --etherscan-api-key $BASE_SCAN_API_KEY --verify --broadcast -vvvv
```
7 changes: 7 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ libs = [
fs_permissions = [
{ access = "read", path = "out-optimized" },
{ access = "read-write", path = "gas_calculations" },
{ access = "read", path = "./zkout/ERC1967Proxy.sol/ERC1967Proxy.json" },
]
allow_paths = [
"*",
Expand All @@ -21,6 +22,9 @@ ignored_warnings_from = [
"lib",
]

#libraries = ["{PROJECT_ROOT}/lib/ether-email-auth/packages/contracts/src/libraries/DecimalUtils.sol:DecimalUtils:0x91cc0f0a227b8dd56794f9391e8af48b40420a0b", "{PROJECT_ROOT}/lib/ether-email-auth/packages/contracts/src/libraries/SubjectUtils.sol:SubjectUtils:0x981e3df952358a57753c7b85de7949da4abcf54a"]
solc = "0.8.26"

[rpc_endpoints]
sepolia = "${BASE_SEPOLIA_RPC_URL}"

Expand All @@ -39,3 +43,6 @@ wrap_comments = true
ignore = [
"./src/libraries/L2ContractHelper.sol",
]

[profile.default.zksync]
zksolc = "1.5.0"
17 changes: 14 additions & 3 deletions script/DeployEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,24 @@ contract DeployEmailRecoveryModuleScript is Script {
console.log("Deployed Ownable Validator at", validatorAddr);
}

EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();
{
EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();
}

address _factory = vm.envOr("RECOVERY_FACTORY", address(0));
if (_factory == address(0)) {
_factory = address(new EmailRecoveryFactory(verifier, emailAuthImpl));
console.log("Deployed Email Recovery Factory at", _factory);
}

bytes4 functionSelector;
{
string memory functionName = vm.envOr("FUNCTION_NAME", string("changeOwner(address)"));
functionSelector = bytes4(keccak256(bytes(functionName)));
console.log("Function Name", functionName);
console.log("Function Selector");
console.logBytes4(functionSelector);
}
{
EmailRecoveryFactory factory = EmailRecoveryFactory(_factory);
(address module, address manager, address subjectHandler) = factory
Expand All @@ -58,9 +69,9 @@ contract DeployEmailRecoveryModuleScript is Script {
type(EmailRecoverySubjectHandler).creationCode,
dkimRegistry,
validatorAddr,
bytes4(keccak256(bytes("changeOwner(address)")))
functionSelector
);

console.log("Deployed Email Recovery Module at", vm.toString(module));
console.log("Deployed Email Recovery Manager at", vm.toString(manager));
console.log("Deployed Email Recovery Handler at", vm.toString(subjectHandler));
Expand Down