Skip to content

Commit 950d364

Browse files
fix: STAA-14 remediation commit i
1 parent e0b6d6e commit 950d364

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/StartaleSmartAccount.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import {
3838
} from './types/Constants.sol';
3939

4040
import {EmergencyUninstall} from './types/Structs.sol';
41+
42+
import {_packValidationData} from '@account-abstraction/core/Helpers.sol';
4143
import {PackedUserOperation} from '@account-abstraction/interfaces/PackedUserOperation.sol';
4244
import {SENTINEL, SentinelListLib, ZERO_ADDRESS} from 'sentinellist/SentinelList.sol';
4345
import {UUPSUpgradeable} from 'solady/utils/UUPSUpgradeable.sol';
@@ -113,7 +115,11 @@ contract StartaleSmartAccount is
113115
} else if (op.nonce.isModuleEnableMode()) {
114116
// if it is module enable mode, we need to enable the module first
115117
// and get the cleaned signature
116-
userOp.signature = _enableMode(userOpHash, op.signature);
118+
(bool enableModeSigValid, bytes calldata userOpSignature) = _enableMode(userOpHash, op.signature);
119+
if (!enableModeSigValid) {
120+
return _packValidationData(true, 0, 0);
121+
}
122+
userOp.signature = userOpSignature;
117123
}
118124
validator = _handleValidator(op.nonce.getValidator());
119125
(userOpHash, userOp.signature) = _withPreValidationHook(userOpHash, userOp, missingAccountFunds);

src/core/ModuleManager.sol

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,12 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
141141

142142
/// @dev Implements Module Enable Mode flow.
143143
/// @param packedData Data source to parse data required to perform Module Enable mode from.
144+
/// @return enableModeSigValid true if the enable mode signature is valid, false otherwise
144145
/// @return userOpSignature the clean signature which can be further used for userOp validation
145-
function _enableMode(bytes32 userOpHash, bytes calldata packedData) internal returns (bytes calldata userOpSignature) {
146+
function _enableMode(
147+
bytes32 userOpHash,
148+
bytes calldata packedData
149+
) internal returns (bool enableModeSigValid, bytes calldata userOpSignature) {
146150
address module;
147151
uint256 moduleType;
148152
bytes calldata moduleInitData;
@@ -161,9 +165,11 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
161165
validator: enableModeSigValidator
162166
})
163167
) {
164-
revert EnableModeSigError();
168+
// Review
169+
return (false, userOpSignature);
165170
}
166171
this.installModule{value: msg.value}(moduleType, module, moduleInitData);
172+
return (true, userOpSignature);
167173
}
168174

169175
/// @notice Installs a new module to the smart account.
@@ -578,11 +584,7 @@ abstract contract ModuleManager is AllStorage, EIP712, IModuleManager {
578584
// Even if the validator doesn't support 7739 under the hood, it is still secure,
579585
// as eip712digest is already built based on 712Domain of this Smart Account
580586
// This interface should always be exposed by validators as per ERC-7579
581-
try IValidator(validator).isValidSignatureWithSender(address(this), eip712Digest, sig) returns (bytes4 res) {
582-
return res == ERC1271_MAGICVALUE;
583-
} catch {
584-
return false;
585-
}
587+
return IValidator(validator).isValidSignatureWithSender(address(this), eip712Digest, sig) == ERC1271_MAGICVALUE;
586588
}
587589

588590
/// @notice Builds the enable mode data hash as per eip712

test/foundry/unit/concrete/modulemanager/TestModuleManager_EnableMode.t.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,7 @@ contract TestModuleManager_EnableMode is Test, TestModuleManagerBase {
492492
PackedUserOperation[] memory userOps = new PackedUserOperation[](1);
493493
userOps[0] = op;
494494

495-
bytes memory expectedRevertReason = abi.encodeWithSelector(
496-
FailedOpWithRevert.selector, 0, 'AA23 reverted', abi.encodeWithSelector(EnableModeSigError.selector)
497-
);
495+
bytes memory expectedRevertReason = abi.encodeWithSelector(FailedOpWithRevert.selector, 0, 'AA23 reverted', 0x0);
498496

499497
vm.expectRevert(expectedRevertReason);
500498
ENTRYPOINT.handleOps(userOps, payable(BOB.addr));

0 commit comments

Comments
 (0)