fix: bind EIP-712 domain separator to proxy, not implementation#52
Merged
Conversation
The non-upgradeable `ERC712Extended` cached the domain separator in a constructor `immutable` keyed only on `block.chainid`. Behind a `Proxy`, that immutable is baked with `address(this) = implementation` and read from the implementation bytecode during `delegatecall`, so the live proxy reported a separator bound to the implementation rather than itself — breaking standards-compliant `permit`/ERC-3009 signatures (which wallets build from the proxy address via `eip712Domain()`) and silently rotating the domain on every upgrade. Add an `_INITIAL_THIS` immutable (the construction-time address) and require `address(this) == _INITIAL_THIS` before trusting the cache. Under a proxy this is always false, so `DOMAIN_SEPARATOR()` recomputes from the live `address(this)` (the proxy) and stays stable across upgrades, while direct home-chain calls keep the gas-saving cache. The upgradeable variant is unaffected (it initializes the separator through the proxy in proxy storage).
|
|
Changes to gas cost
🧾 Summary (20% most significant diffs)
Full diff report 👇
|
LCOV of commit
|
toninorair
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The non-upgradeable
ERC712Extendedcached the domain separator in a constructorimmutablekeyed only onblock.chainid. Behind aProxy, that immutable is baked withaddress(this) = implementationand read from the implementation bytecode duringdelegatecall, so the live proxy reported a separator bound to the implementation rather than itself — breaking standards-compliantpermit/ERC-3009 signatures (which wallets build from the proxy address viaeip712Domain()) and silently rotating the domain on every upgrade.Add an
_INITIAL_THISimmutable (the construction-time address) and requireaddress(this) == _INITIAL_THISbefore trusting the cache. Under a proxy this is always false, soDOMAIN_SEPARATOR()recomputes from the liveaddress(this)(the proxy) and stays stable across upgrades, while direct home-chain calls keep the gas-saving cache.The upgradeable variant is unaffected (it initializes the separator through the proxy in proxy storage).