Skip to content

Commit 503b00c

Browse files
committed
draft msg.sender gated approach to resetImplementation
1 parent be46e72 commit 503b00c

File tree

2 files changed

+9
-65
lines changed

2 files changed

+9
-65
lines changed

src/EIP7702Proxy.sol

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ contract EIP7702Proxy is Proxy {
5151
/// @notice Emitted when the implementation is reset
5252
event ImplementationReset(address newImplementation);
5353

54+
/// @notice Emitted when caller is not the EOA
55+
error UnauthorizedCaller();
56+
5457
/// @notice Initializes the proxy with an initial implementation and guarded initializer
5558
/// @param implementation The initial implementation address
5659
/// @param initializer The selector of the `guardedInitializer` function
@@ -164,31 +167,14 @@ contract EIP7702Proxy is Proxy {
164167
receive() external payable {}
165168

166169
/**
167-
* @notice Resets the ERC-1967 implementation slot after signature verification
168-
* @dev Uses raw hash (no Ethereum signed message prefix) to prevent phishing
170+
* @notice Resets the ERC-1967 implementation slot
171+
* @dev Can only be called directly by the EOA (address(this))
169172
* @param newImplementation The implementation address to set
170-
* @param nonce The nonce for this operation (verified against NonceTracker)
171-
* @param signature The EOA signature authorizing this change
172173
*/
173-
function resetImplementation(
174-
address newImplementation,
175-
uint256 nonce,
176-
bytes calldata signature
177-
) external {
178-
// Verify nonce hasn't been used
179-
if (
180-
!INonceTracker(nonceTracker).verifyAndUseNonce(address(this), nonce)
181-
) {
182-
revert NonceAlreadyUsed();
183-
}
184-
185-
// Raw hash without Ethereum signed message prefix
186-
bytes32 hash = keccak256(abi.encode(newImplementation, nonce));
187-
188-
// Verify signature is from this address (the EOA)
189-
address recovered = ECDSA.recover(hash, signature);
190-
if (recovered != address(this)) {
191-
revert InvalidSignature();
174+
function resetImplementation(address newImplementation) external {
175+
// Verify caller is the EOA
176+
if (msg.sender != address(this)) {
177+
revert UnauthorizedCaller();
192178
}
193179

194180
// Reset the implementation slot

src/NonceTracker.sol

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)