Repository navigation
fix(typedData): reject invalid field types in validateTypedData - #5370
Merged
Merged
Conversation
validateTypedData only matched a field type against the integer and bytes regexes to check its value, so a type that matched neither, such as uint7, uint264, uint08, int0 or bytes0, passed and hashTypedData encoded it as uint256 under a type hash no Solidity struct can produce. A field's base type must now be a struct in types or an EIP-712 atomic or dynamic type.
Field types were only checked while walking the message, so structs only referenced as array elements (e.g. `Person[]`) were never checked and `uint7` or `bytes0` fields were still hashed. Validate every struct's field types up front, and use own-property lookups so field types like `constructor` or `toString` are rejected instead of crashing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWjRL6So1WQiDdN7nnu
🦋 Changeset detectedLatest commit: d3952ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merged
jxom
added a commit
to wevm/ox
that referenced
this pull request
Nov 1, 2026
…s, and `AbiItem` (#561) * fix: validate struct names and field types in `TypedData.assert` Ports wevm/viem#5308 and wevm/viem#5370. A struct name must contain only letters, digits, `_` and `$`, and must not be a Solidity type. A field type must be a struct in `types` or an EIP-712 atomic or dynamic type, so `uint`, `uint7` and `bytes0` throw the new `TypedData.InvalidTypeError`. Every struct is checked, including structs referenced only as array elements. `findTypeDependencies` strips only the array suffix, so struct names with `$` are encoded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: reject a tip above a zero `maxFeePerGas` in transaction envelopes Ports wevm/viem#5318 and wevm/viem#5319. `TxEnvelopeEip1559.assert` and `TxEnvelopeTempo.assert` compared fees only when both were truthy, so a zero `maxFeePerGas` skipped the check. `deserialize` for EIP-1559, EIP-4844, EIP-7702, and Tempo envelopes reads an empty `maxFeePerGas` as zero when a tip is set. `TipAboveFeeCapError` and `FeeCapTooHighError` now show zero values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: treat indistinguishable overloads as ambiguous in `AbiItem.fromAbi` Ports wevm/viem#5339. Distinct types that both match an argument, such as `bytes32` and `bytes` or `uint256` and `int256`, and arrays of the same element type with different shapes now throw `AbiItem.AmbiguityError` instead of resolving to the last match. An integer overload matches only a value in its range, and a fixed bytes overload matches only a value of its size. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq --------- Co-authored-by: Claude <[email protected]>
jxom
added a commit
to wevm/ox
that referenced
this pull request
Nov 1, 2026
…d `AbiItem` (#560) * fix: validate struct names and field types in `TypedData.assert` Ports wevm/viem#5308 and wevm/viem#5370. A struct name must contain only letters, digits, `_` and `$`, and must not be a Solidity type. A field type must be a struct in `types` or an EIP-712 atomic or dynamic type, so `uint`, `uint7` and `bytes0` throw the new `TypedData.InvalidTypeError`. Every struct is checked, including structs referenced only as array elements. `findTypeDependencies` strips only the array suffix, so struct names with `$` are encoded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: reject a tip above a zero `maxFeePerGas` in transaction envelopes Ports wevm/viem#5318 and wevm/viem#5319. `TxEnvelopeEip1559.assert` and `TxEnvelopeTempo.assert` compared fees only when both were truthy, so a zero `maxFeePerGas` skipped the check. `deserialize` for EIP-1559, EIP-4844, EIP-7702, and Tempo envelopes reads an empty `maxFeePerGas` as zero when a tip is set. `TipAboveFeeCapError` and `FeeCapTooHighError` now show zero values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq * fix: treat indistinguishable overloads as ambiguous in `AbiItem.fromAbi` Ports wevm/viem#5339. Distinct types that both match an argument, such as `bytes32` and `bytes` or `uint256` and `int256`, and arrays of the same element type with different shapes now throw `AbiItem.AmbiguityError` instead of resolving to the last match. An integer overload matches only a value in its range, and a fixed bytes overload matches only a value of its size. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D3nmWgFaNg3t1E6VyYCzXq --------- Co-authored-by: Claude <[email protected]>
This branch was successfully deployed
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.
Supersedes #5366: it keeps that PR's commit and fixes the cases it missed.
validateTypedData(and sohashTypedDataandsignTypedData) accepted field types that are not EIP-712 types, such asuint7,uint264,uint08,int0orbytes0, and field types that reference a struct missing fromtypes. It now throwsInvalidTypedDataTypeErrorfor them.What changed compared with #5366:
Person[], so auint7orbytes0field there was still hashed. Every struct's field types are now checked up front, next to the existing struct-name check. Struct names are checked first, so an invalid struct name still throwsInvalidStructTypeError.constructor,toStringorhasOwnPropertywas found on the object prototype and treated as a defined struct, which crashed with a rawTypeError. The lookups now only count keys defined intypesitself (Object.hasOwn).uint256instead." hint is still shown only for theint/uintaliases. The canonical type is now built only in that case.Tests added:
Person[],Person[][]andPerson[2]structs containingbytes0,uint,uint7,uint7[]or an undefined struct, plus the four property-name types, and ahashTypedDatasnapshot for the array-element case.Verification:
src/utils/typedData.test.tsandsrc/utils/signature/hashTypedData.test.tspass (84 tests), andtsc --noEmit -p src/tsconfig.jsonand Biome are clean on the changed files. I ran the tests with a minimal Vitest config, because the repo's global setup could not start Anvil in my environment. Tests that need the local chain were not run.Generated by Claude Code