Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/fifty-owls-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`AccountERC7579`: `isModuleInstalled` return false for address zero fallback & hook modules
5 changes: 4 additions & 1 deletion contracts/account/extensions/draft-AccountERC7579.sol
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ abstract contract AccountERC7579 is Account, IERC1271, IERC7579Execution, IERC75
if (moduleTypeId == MODULE_TYPE_EXECUTOR) return _executors.contains(module);
if (moduleTypeId == MODULE_TYPE_FALLBACK)
// ERC-7579 requires this function to return bool, never revert. Check length to avoid out-of-bounds access.
return additionalContext.length > 3 && _fallbacks[bytes4(additionalContext[0:4])] == module;
return
module != address(0) &&
additionalContext.length > 3 &&
_fallbacks[bytes4(additionalContext[0:4])] == module;
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ abstract contract AccountERC7579Hooked is AccountERC7579 {
bytes calldata data
) public view virtual override returns (bool) {
return
(moduleTypeId == MODULE_TYPE_HOOK && module == hook()) ||
(moduleTypeId == MODULE_TYPE_HOOK && module != address(0) && module == hook()) ||
super.isModuleInstalled(moduleTypeId, module, data);
}

Expand Down
10 changes: 10 additions & 0 deletions test/account/extensions/AccountERC7579.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ function shouldBehaveLikeAccountERC7579({ withHooks = false } = {}) {
this.mock.isModuleInstalled(MODULE_TYPE_FALLBACK, this.modules[MODULE_TYPE_FALLBACK], '0x12345678'),
).to.eventually.equal(false);
});

it('returns false for address(0) as module', async function () {
const moduleTypes = [MODULE_TYPE_FALLBACK, MODULE_TYPE_VALIDATOR, MODULE_TYPE_EXECUTOR];
withHooks && moduleTypes.push(MODULE_TYPE_HOOK);
for (const moduleTypeId of moduleTypes) {
await expect(this.mock.isModuleInstalled(moduleTypeId, ethers.ZeroAddress, '0x12345678')).to.eventually.equal(
false,
);
}
});
});

describe('module installation', function () {
Expand Down
Loading