Skip to content

Commit 2547fe5

Browse files
authored
Prevent revert in isModuleInstalled for fallback modules on short additionalContext
1 parent 5eb047a commit 2547fe5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contracts/account/extensions/draft-AccountERC7579.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ abstract contract AccountERC7579 is Account, IERC1271, IERC7579Execution, IERC75
149149
) public view virtual returns (bool) {
150150
if (moduleTypeId == MODULE_TYPE_VALIDATOR) return _validators.contains(module);
151151
if (moduleTypeId == MODULE_TYPE_EXECUTOR) return _executors.contains(module);
152-
if (moduleTypeId == MODULE_TYPE_FALLBACK) return _fallbacks[bytes4(additionalContext[0:4])] == module;
152+
if (moduleTypeId == MODULE_TYPE_FALLBACK) {
153+
// For fallback modules, the additionalContext is expected to start with a 4-byte selector.
154+
// Per IERC7579ModuleConfig spec, this function MUST return true/false and not revert.
155+
// Treat malformed context (< 4 bytes) as "not installed" to avoid out-of-bounds slice reverts.
156+
if (additionalContext.length < 4) return false;
157+
return _fallbacks[bytes4(additionalContext[0:4])] == module;
158+
}
153159
return false;
154160
}
155161

0 commit comments

Comments
 (0)