Skip to content

Commit 9b7b59c

Browse files
authored
Merge pull request #14 from base-org/amie/blocksec-review-changes
Validate constructor arguments to proxy are nonzero
2 parents be89153 + 132ed01 commit 9b7b59c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/EIP7702Proxy.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,17 @@ contract EIP7702Proxy is Proxy {
3636
/// @notice Emitted when initialization is attempted on a non-initial implementation
3737
error InvalidImplementation();
3838

39+
/// @notice Emitted when constructor arguments are zero
40+
error ZeroValueConstructorArguments();
41+
3942
/// @notice Initializes the proxy with an initial implementation and guarded initializer
4043
/// @param implementation The initial implementation address
4144
/// @param initializer The selector of the `guardedInitializer` function
4245
constructor(address implementation, bytes4 initializer) {
46+
if (implementation == address(0))
47+
revert ZeroValueConstructorArguments();
48+
if (initializer == bytes4(0)) revert ZeroValueConstructorArguments();
49+
4350
proxy = address(this);
4451
initialImplementation = implementation;
4552
guardedInitializer = initializer;

test/EIP7702Proxy/initialize.t.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,14 @@ contract InitializeTest is EIP7702ProxyBase {
147147
vm.expectRevert(EIP7702Proxy.InvalidSignature.selector);
148148
EIP7702Proxy(_eoa).initialize(differentArgs, signature);
149149
}
150+
151+
function test_constructor_reverts_whenImplementationZero() public {
152+
vm.expectRevert(EIP7702Proxy.ZeroValueConstructorArguments.selector);
153+
new EIP7702Proxy(address(0), MockImplementation.initialize.selector);
154+
}
155+
156+
function test_constructor_reverts_whenInitializerZero() public {
157+
vm.expectRevert(EIP7702Proxy.ZeroValueConstructorArguments.selector);
158+
new EIP7702Proxy(address(_implementation), bytes4(0));
159+
}
150160
}

0 commit comments

Comments
 (0)