feat(lint): validate EIP-712 format keys in v2 linter - #307
Open
manuelwedler wants to merge 1 commit into
Open
Conversation
v2 descriptors no longer embed EIP-712 schemas: the display.formats key is itself the schema, and MUST be the encodeType string of the message primary type, so that keccak256(TYPE_KEY) matches the type hash the wallet computes from the message. A malformed key silently never matches. Add ValidateEIP712KeysLinter, checking keys purely syntactically (neither the domain nor the struct definitions are available in the descriptor): encodeType grammar and whitespace, duplicate types and members, valid atomic types, referenced types defined and reachable, and dependent types sorted by name. Colon namespaced type names (e.g. Hyperliquid's HyperliquidTransaction:Withdraw) are tolerated, consistently with parse_encode_type.
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
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
display.formatskey pattern in the v2 schema was loosened in ethereum/ERCs#1868, so malformed EIP-712 keys now pass schema validation — whitespace in particular is accepted anywhere. But the key MUST be exactlyencodeType(primaryType): wallets compute the type hash from the message being signed and compare it againstkeccak256(TYPE_KEY), so any deviation means the descriptor silently never applies.ValidateEIP712KeysLinter, validating keys purely syntactically (the descriptor holds neither the domain nor the struct definitions).HyperliquidTransaction:Withdraw), consistently withparse_encode_type(fix: allow colon in EIP-712 type names in encodeType parser #289).master: 0 errors across all 125eip712-*root descriptors.