feat: adding more validations for types sign v4 messages - #8526
Merged
Conversation
jpuri
marked this pull request as ready for review
April 21, 2026 08:35
jpuri
enabled auto-merge
April 21, 2026 08:41
ffmcgee725
previously approved these changes
Apr 21, 2026
pedronfigueiredo
self-requested a review
April 21, 2026 14:19
pedronfigueiredo
previously approved these changes
Apr 21, 2026
jiexi
previously approved these changes
Apr 21, 2026
mcmire
reviewed
Apr 21, 2026
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
jpuri
dismissed stale reviews from pedronfigueiredo, ffmcgee725, and jiexi
via
April 22, 2026 03:28
11a16b7
Co-authored-by: jiexi <jiexiluan@gmail.com>
Contributor
Author
|
Hey @mcmire : thanks for the feedback, I merged the suggestion to make put the task under "Changed" |
pedronfigueiredo
approved these changes
Apr 22, 2026
ffmcgee725
approved these changes
Apr 22, 2026
7 tasks
jeffsmale90
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Apr 27, 2026
@metamask/eth-json-rpc-middleware@23.1.2 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions MetaMask/core#8526
This was referenced Apr 27, 2026
pull Bot
pushed a commit
to Reality2byte/core
that referenced
this pull request
Apr 28, 2026
…k#8603) ## Explanation MetaMask#8526 adds tighter validation to signtypeddata v4 payloads, to ensure that no extraneous properties are added. This additional validation disallows Advanced Permissions `metadata` which is used to communicate the origin and justification of the permission. This change loosens the validation just enough to allow `metadata: { justification: string; origin: string }` as a property on the payload that is not used within the message encoding. ## References MetaMask#8526 MetaMask/metamask-extension#42181 <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches security-adjacent request validation for typed-data signing; while the new `metadata` allowance is tightly constrained, any loosening here could affect input filtering behavior. > > **Overview** > Relaxes `signTypedData` (V4) payload validation to permit an additional top-level `metadata` field used by Advanced Permissions. > > `validateTypedMessageKeys` now explicitly allows `metadata` and enforces it is exactly `{ justification: string, origin: string }` (rejecting non-objects, missing/typed fields, or extra keys), with new unit tests covering the allowed and rejected cases; changelog updated accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 17f9432. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github Bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Apr 28, 2026
…23.1.3 cp-13.29.0 (#42177) ## **Description** MetaMask/core#8526 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions, which passes `metadata` in the top level typed data payload. This change was introduced in @metamask/eth-json-rpc-middleware@23.1.2. This PR bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 which explicitly allows the `metadata` field used in Advanced Permissions. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #42180 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes a core JSON-RPC middleware dependency version, which can affect request validation/signing flows and dapp compatibility. Scope is small (dependency pin/revert) but behavior impact could be broad at runtime. > > **Overview** > Reverts `@metamask/eth-json-rpc-middleware` from `23.1.2` back to `23.1.1` and adds a top-level `resolutions` pin to force that version across the dependency tree. > > Updates `yarn.lock` accordingly so installs consistently resolve `23.1.1`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 930f08f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github Bot
added a commit
to MetaMask/metamask-extension
that referenced
this pull request
Apr 28, 2026
…23.1.3 cp-13.29.0 (#42177) ## **Description** MetaMask/core#8526 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions, which passes `metadata` in the top level typed data payload. This change was introduced in @metamask/eth-json-rpc-middleware@23.1.2. This PR bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 which explicitly allows the `metadata` field used in Advanced Permissions. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #42180 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes a core JSON-RPC middleware dependency version, which can affect request validation/signing flows and dapp compatibility. Scope is small (dependency pin/revert) but behavior impact could be broad at runtime. > > **Overview** > Reverts `@metamask/eth-json-rpc-middleware` from `23.1.2` back to `23.1.1` and adds a top-level `resolutions` pin to force that version across the dependency tree. > > Updates `yarn.lock` accordingly so installs consistently resolve `23.1.1`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 930f08f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
runway-github Bot
pushed a commit
to MetaMask/metamask-extension
that referenced
this pull request
Apr 28, 2026
…leware from ^23.1.2 to ^23.1.3 cp-13.29.0 (#42177) ## **Description** MetaMask/core#8526 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions, which passes `metadata` in the top level typed data payload. This change was introduced in @metamask/eth-json-rpc-middleware@23.1.2. This PR bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 which explicitly allows the `metadata` field used in Advanced Permissions. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #42180 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes a core JSON-RPC middleware dependency version, which can affect request validation/signing flows and dapp compatibility. Scope is small (dependency pin/revert) but behavior impact could be broad at runtime. > > **Overview** > Reverts `@metamask/eth-json-rpc-middleware` from `23.1.2` back to `23.1.1` and adds a top-level `resolutions` pin to force that version across the dependency tree. > > Updates `yarn.lock` accordingly so installs consistently resolve `23.1.1`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 930f08f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
7 tasks
pull Bot
pushed a commit
to Reality2byte/metamask-extension
that referenced
this pull request
Apr 28, 2026
…3 cp-13.29.0 (MetaMask#42177) ## **Description** MetaMask/core#8526 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions, which passes `metadata` in the top level typed data payload. This change was introduced in @metamask/eth-json-rpc-middleware@23.1.2. This PR bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 which explicitly allows the `metadata` field used in Advanced Permissions. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: MetaMask#42180 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes a core JSON-RPC middleware dependency version, which can affect request validation/signing flows and dapp compatibility. Scope is small (dependency pin/revert) but behavior impact could be broad at runtime. > > **Overview** > Reverts `@metamask/eth-json-rpc-middleware` from `23.1.2` back to `23.1.1` and adds a top-level `resolutions` pin to force that version across the dependency tree. > > Updates `yarn.lock` accordingly so installs consistently resolve `23.1.1`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 930f08f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
gauthierpetetin
pushed a commit
to MetaMask/metamask-extension
that referenced
this pull request
Apr 28, 2026
…leware from ^23.1.2 to ^23.1.3 cp-13.29.0 (#42229) - chore: Bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 cp-13.29.0 (#42177) ## **Description** MetaMask/core#8526 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions, which passes `metadata` in the top level typed data payload. This change was introduced in @metamask/eth-json-rpc-middleware@23.1.2. This PR bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 which explicitly allows the `metadata` field used in Advanced Permissions. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #42180 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes a core JSON-RPC middleware dependency version, which can affect request validation/signing flows and dapp compatibility. Scope is small (dependency pin/revert) but behavior impact could be broad at runtime. > > **Overview** > Reverts `@metamask/eth-json-rpc-middleware` from `23.1.2` back to `23.1.1` and adds a top-level `resolutions` pin to force that version across the dependency tree. > > Updates `yarn.lock` accordingly so installs consistently resolve `23.1.1`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 930f08f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> [013064e](013064e) --------- Co-authored-by: jeffsmale90 <6363749+jeffsmale90@users.noreply.github.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
NidhiKJha
pushed a commit
to MetaMask/metamask-extension
that referenced
this pull request
Apr 30, 2026
…3 cp-13.29.0 (#42177) ## **Description** MetaMask/core#8526 introduces tighter validation of typeddata_v4 requests, breaking advanced permissions, which passes `metadata` in the top level typed data payload. This change was introduced in @metamask/eth-json-rpc-middleware@23.1.2. This PR bumps @metamask/eth-json-rpc-middleware from ^23.1.2 to ^23.1.3 which explicitly allows the `metadata` field used in Advanced Permissions. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #42180 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes a core JSON-RPC middleware dependency version, which can affect request validation/signing flows and dapp compatibility. Scope is small (dependency pin/revert) but behavior impact could be broad at runtime. > > **Overview** > Reverts `@metamask/eth-json-rpc-middleware` from `23.1.2` back to `23.1.1` and adds a top-level `resolutions` pin to force that version across the dependency tree. > > Updates `yarn.lock` accordingly so installs consistently resolve `23.1.1`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 930f08f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
4 tasks
OGPoyraz
pushed a commit
that referenced
this pull request
Jul 15, 2026
…nTransaction params Reject requests whose top-level params contain keys outside the allowlisted transaction fields or nest beyond MAX_TRANSACTION_PARAM_DEPTH (10). Prevents downstream normalization / PPOM WASM from crashing with RangeError on deeply-nested junk fields and silently bypassing security scans. Mirrors the guardrail pattern introduced for eth_signTypedData_v4 in #8526. CONF-1662
OGPoyraz
pushed a commit
that referenced
this pull request
Jul 20, 2026
…nTransaction params Reject requests whose top-level params contain keys outside the allowlisted transaction fields or nest beyond MAX_TRANSACTION_PARAM_DEPTH (10). Prevents downstream normalization / PPOM WASM from crashing with RangeError on deeply-nested junk fields and silently bypassing security scans. Mirrors the guardrail pattern introduced for eth_signTypedData_v4 in #8526. CONF-1662
OGPoyraz
pushed a commit
that referenced
this pull request
Jul 22, 2026
…nTransaction params Reject requests whose top-level params contain keys outside the allowlisted transaction fields or nest beyond MAX_TRANSACTION_PARAM_DEPTH (10). Prevents downstream normalization / PPOM WASM from crashing with RangeError on deeply-nested junk fields and silently bypassing security scans. Mirrors the guardrail pattern introduced for eth_signTypedData_v4 in #8526. CONF-1662
OGPoyraz
pushed a commit
that referenced
this pull request
Jul 31, 2026
…nTransaction params Reject requests whose top-level params contain keys outside the allowlisted transaction fields or nest beyond MAX_TRANSACTION_PARAM_DEPTH (10). Prevents downstream normalization / PPOM WASM from crashing with RangeError on deeply-nested junk fields and silently bypassing security scans. Mirrors the guardrail pattern introduced for eth_signTypedData_v4 in #8526. CONF-1662
OGPoyraz
pushed a commit
that referenced
this pull request
Aug 3, 2026
…nTransaction params Reject requests whose top-level params contain keys outside the allowlisted transaction fields or nest beyond MAX_TRANSACTION_PARAM_DEPTH (10). Prevents downstream normalization / PPOM WASM from crashing with RangeError on deeply-nested junk fields and silently bypassing security scans. Mirrors the guardrail pattern introduced for eth_signTypedData_v4 in #8526. CONF-1662
pull Bot
pushed a commit
to dmrazzy/core
that referenced
this pull request
Aug 3, 2026
…etaMask#9482) ## Explanation Malicious dapps can send `eth_sendTransaction` with a valid-looking payload plus a deeply-nested junk field (e.g. `test.b.b.b...` ~1200 levels). Downstream normalization in `@metamask/transaction-controller` recurses into these params and throws `RangeError: Maximum call stack size exceeded`. When this crash happens inside the extension/mobile PPOM middleware it short-circuits the security-scan pipeline: the request never reaches the Security Alerts API, and the user sees the confirmation without a Blockaid scan. The same class of attack was fixed for `eth_signTypedData_v4` in MetaMask#8526 by rejecting requests with extraneous top-level keys. This PR applies the equivalent guardrail to transaction methods. ### Changes - New `validateTransactionParams(params)` in `src/utils/validation.ts`, exported from the package. Rejects with `rpcErrors.invalidInput()` when: - `params` is not a plain object, or - contains a top-level key outside the dapp-facing subset of `TransactionParams` (`accessList`, `authorizationList`, `chainId`, `data`, `from`, `gas`, `gasLimit`, `gasPrice`, `maxFeePerGas`, `maxPriorityFeePerGas`, `nonce`, `to`, `type`, `value`), or - nests beyond depth 10 anywhere inside the params tree (legitimate params, including `accessList` / `authorizationList`, are ≤4 levels deep). - Wired into the `eth_sendTransaction` and `eth_signTransaction` handlers in `createWalletMiddleware`, before `validateAndNormalizeKeyholder`. - Also exported from `index.ts` so extension/mobile PPOM middleware can gate params before their own `normalizeTransactionParams` call (which is where the WASM crash actually originates in clients). ### Design notes - **Reject vs. strip:** matches MetaMask#8526 — reject the whole request with `invalidInput`. Stripping silently would hide the attack pattern from telemetry. - **Allowlist scope:** intentionally omits internal-only fields on `TransactionParams` (`estimateGasError`, `estimatedBaseFee`, `estimateSuggested`, `estimateUsed`, `gasUsed`) — dapps should not be able to inject those. - **Depth of 10:** ~2-3× headroom over legitimate use. Change if any real dapp turns out to nest deeper. ## References - Mirrors MetaMask#8526 (EIP-712 equivalent fix in this same package) - Related client-side counterpart: MetaMask/metamask-extension#42080 - Internal: CONF-1662 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **High Risk** > Breaking RPC validation on security-critical transaction paths may reject previously accepted dapp payloads; changes directly target bypass of Blockaid/PPOM scanning. > > **Overview** > **BREAKING:** `eth_sendTransaction` and `eth_signTransaction` now run new **`validateTransactionParams`** before address checks. Requests must match a fixed transaction field schema (no extra top-level keys, typed `accessList` / `authorizationList`, quantity fields as hex string or number) and stay under **200 KB** serialized size or they fail with invalid params. > > The helper is **exported** from the package so clients can reuse the same guard ahead of normalization/PPOM. This mirrors the earlier `eth_signTypedData_v4` hardening and blocks junk nested fields and padded payloads that could crash downstream normalization and skip security scans. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a4e603a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Ogulcan Poyraz <ogp@metamask.io> Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
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.
Explanation
Adding more validations for typed sign v4 messaged.
References
Checklist
Note
Medium Risk
Tightens validation on
eth_signTypedData_v4inputs, which may break dapps that previously sent additional top-level fields in typed data. Change is localized but affects a commonly used signing path.Overview
Stricter
eth_signTypedData_v4input validation: the wallet middleware now rejects EIP-712 typed-data JSON that includes any extraneous top-level keys beyond those defined by@metamask/eth-sig-util’sTYPED_MESSAGE_SCHEMA.This introduces a new
validateTypedMessageKeysutility (and tests) and wires it into theeth_signTypedData_v4flow, plus adds coverage ensuring requests with unexpected keys fail withInvalid input.; the changelog is updated accordingly.Reviewed by Cursor Bugbot for commit 3c2ae43. Bugbot is set up for automated code reviews on this repo. Configure here.