Skip to content

Commit 5aaf7e6

Browse files
fix: S2 auditor suggestions i
1 parent 50a921d commit 5aaf7e6

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

src/core/ModuleManager.sol

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,14 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
233233
// Perform the removal first
234234
validators.pop(prev, validator);
235235

236-
validator.excessivelySafeCall(
236+
(bool success, bytes memory returnData) = validator.excessivelySafeCall(
237237
gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, disableModuleData)
238238
);
239+
if (!success) {
240+
emit ExternalCallFailed(
241+
validator, abi.encodeWithSelector(IModule.onUninstall.selector, disableModuleData), returnData
242+
);
243+
}
239244
}
240245

241246
/// Review: _tryUninstallValidators Might as well not call onUninstall() at all
@@ -270,9 +275,14 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
270275
function _uninstallExecutor(address executor, bytes calldata data) internal virtual {
271276
(address prev, bytes memory disableModuleData) = abi.decode(data, (address, bytes));
272277
_getAccountStorage().executors.pop(prev, executor);
273-
executor.excessivelySafeCall(
278+
(bool success, bytes memory returnData) = executor.excessivelySafeCall(
274279
gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, disableModuleData)
275280
);
281+
if (!success) {
282+
emit ExternalCallFailed(
283+
executor, abi.encodeWithSelector(IModule.onUninstall.selector, disableModuleData), returnData
284+
);
285+
}
276286
}
277287

278288
/// Review: _tryUninstallExecutors Might as well not call onUninstall() at all
@@ -314,7 +324,11 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
314324
{
315325
_uninstallPreValidationHook(hook, hookType, data);
316326
}
317-
hook.excessivelySafeCall(gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, data));
327+
(bool success, bytes memory returnData) =
328+
hook.excessivelySafeCall(gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, data));
329+
if (!success) {
330+
emit ExternalCallFailed(hook, abi.encodeWithSelector(IModule.onUninstall.selector, data), returnData);
331+
}
318332
}
319333

320334
/// Review: _tryUninstallHook
@@ -341,9 +355,14 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
341355

342356
if (address(handler.handler) == address(0)) continue;
343357

344-
handler.handler.excessivelySafeCall(
358+
(bool success, bytes memory returnData) = handler.handler.excessivelySafeCall(
345359
gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, abi.encodePacked(selector))
346360
);
361+
if (!success) {
362+
emit ExternalCallFailed(
363+
handler.handler, abi.encodeWithSelector(IModule.onUninstall.selector, abi.encodePacked(selector)), returnData
364+
);
365+
}
347366

348367
ds.fallbacks[selector] = FallbackHandler(address(0), CallType.wrap(0x00));
349368
}
@@ -479,7 +498,14 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
479498
}
480499
}
481500

482-
fallbackHandler.excessivelySafeCall(gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, data[4:]));
501+
(bool success, bytes memory returnData) = fallbackHandler.excessivelySafeCall(
502+
gasleft(), 0, 0, abi.encodeWithSelector(IModule.onUninstall.selector, data[4:])
503+
);
504+
if (!success) {
505+
emit ExternalCallFailed(
506+
fallbackHandler, abi.encodeWithSelector(IModule.onUninstall.selector, data[4:]), returnData
507+
);
508+
}
483509
}
484510

485511
/// @dev Installs a pre-validation hook module, ensuring no other pre-validation hooks are installed before proceeding.
@@ -523,12 +549,14 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
523549
emit PreValidationHookUninstallFailed(hook, '');
524550
}
525551
_setPreValidationHook(hookType, address(0));
552+
emit ModuleUninstalled(hookType, hook);
526553
} else if (hookType == MODULE_TYPE_PREVALIDATION_HOOK_ERC4337) {
527554
try _getAccountStorage().preValidationHookERC4337.onUninstall('') {}
528555
catch {
529556
emit PreValidationHookUninstallFailed(hook, '');
530557
}
531558
_setPreValidationHook(hookType, address(0));
559+
emit ModuleUninstalled(hookType, hook);
532560
} else {
533561
revert InvalidHookType(hookType);
534562
}

src/interfaces/core/IModuleManagerEventsAndErrors.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ interface IModuleManagerEventsAndErrors {
3737
/// @param data The data of the hook.
3838
event HookUninstallFailed(address hook, bytes data);
3939

40+
/// @notice Emitted when an external call fails.
41+
/// @param target The address of the target.
42+
/// @param callData The data of the call.
43+
/// @param returnData The return data of the call.
44+
event ExternalCallFailed(address target, bytes callData, bytes returnData);
45+
4046
/// @notice Thrown when attempting to remove the last validator.
4147
error CanNotRemoveLastValidator();
4248

src/modules/validators/ECDSAValidator.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ contract ECDSAValidator is IValidator, ERC7739Validator {
6363
*/
6464
event OwnerRegistered(address indexed account, address indexed owner);
6565

66+
/**
67+
* @notice Emitted when an owner is removed for an account
68+
* @param account The smart account address
69+
*/
70+
event OwnerRemoved(address indexed account);
71+
6672
// Storage
6773
/**
6874
* @notice Mapping of smart account addresses to their respective owner addresses
@@ -108,6 +114,7 @@ contract ECDSAValidator is IValidator, ERC7739Validator {
108114
}
109115

110116
delete smartAccountOwners[msg.sender];
117+
emit OwnerRemoved(msg.sender);
111118
_safeSenders.removeAll(msg.sender);
112119
}
113120

@@ -138,6 +145,7 @@ contract ECDSAValidator is IValidator, ERC7739Validator {
138145
}
139146

140147
smartAccountOwners[msg.sender] = _newOwner;
148+
emit OwnerRegistered(msg.sender, _newOwner);
141149
}
142150

143151
/**

0 commit comments

Comments
 (0)