Skip to content

fix: upgrade mockttp to 4.6.5 to resolve @graphql-tools/utils advisory - #40542

Merged
weitingsun merged 9 commits into
mainfrom
fix/mockttp-4-graphql-tools-utils
Dec 2, 2026
Merged

weitingsun merged 9 commits into
mainfrom
fix/mockttp-4-graphql-tools-utils

Conversation

@weitingsun

@weitingsun weitingsun commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Upgrades mockttp, the E2E mock server (test-only), from 3.15.2 to 4.6.5 and removes 1241230 (MCWP-1041) from npmAuditIgnoreAdvisories.

@graphql-tools/utils: mockttp 3.x pulled in @graphql-tools/utils@8.9.0 and 8.13.1 (via @graphql-tools/schema@8 and merge@8), affected by GHSA-7mx3-vvmw-hjmv (high, prototype pollution in mergeDeep). No 3.x mockttp release has a fix. mockttp 4.6.5 depends on utils@^12.0.3 and schema@^10, so the tree now has utils@12.1.0 with no pins needed.

mockttp 4 follow-ups:

  • package.json: removed the mockttp@npm:3.15.2/body-parser pin (4.x no longer uses body-parser). Added "mockttp>tls-impersonate": false to allowScripts. It's an optional native addon that ships prebuilds for every platform we use and loads without its install script.
  • jest.config.js: transpile ESM-only milliparsec and get-port 7 (nested under mockttp).
  • tests/api-mocking/helpers/cryptoRandomUUID.ts: mockttp 4 calls globalThis.crypto.randomUUID(), which the shared Jest crypto stub lacks. The four unit suites that start a mockttp server install Node's randomUUID in beforeAll. This is scoped on purpose: adding it to the global stub would switch every test's uuid.v4() to a different code path.
  • tests/smoke/identity/utils/mocks.ts: body.getJson<object>(), since getJson() now types JSON primitives too.
  • We don't use any of the v4 breaking APIs (thenForwardTo/forwarding, handler classes, getRemote, CA generation, or status in callback results).

validator: also removes the "@metamask/react-native-payments/validator" resolution, which no longer matches anything. It was added in #9483 for react-native-payments@2.0.0 (validator@^7), and 2.0.1+ dropped the dependency.

Verification:

  • yarn install --immutable and yarn audit:ci pass. A full audit with --environment all reports no new advisories.
  • yarn allow-scripts list shows no unconfigured packages. yarn lint:tsc passes, and ESLint and Prettier are clean on changed files.
  • All 216 unit suites under tests/ pass (3,262 tests), including the mockttp server suites, and NotificationsView.view.test.tsx passes.
  • getLocal() with thenJson and thenCallback works in plain Node 24 (the Appium runner path).

Test layer placement

No new tests. Existing unit suites that start a mockttp server now call installCryptoRandomUUID in beforeAll. E2E coverage comes from the Appium smoke run in CI.

Changelog

CHANGELOG entry:null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-1041

Manual testing steps

Feature: mockttp 4 upgrade resolves the @graphql-tools/utils advisory

  Background:
    Given this branch is checked out
    And Node 24.22.1 is active and `yarn install --immutable` has run

  Scenario: Only the patched @graphql-tools/utils is installed
    When the tester runs `yarn why @graphql-tools/utils`
    Then it resolves only `@graphql-tools/utils@npm:12.1.0`

  Scenario: Mock server unit tests pass
    When the tester runs `yarn jest tests/api-mocking tests/smoke/identity`
    Then all test suites pass

  Scenario: Appium smoke tests still mock APIs
    When the E2E smoke workflow runs on this PR in CI
    Then tests using `MockServerE2E` pass as on main

  Scenario: Audit passes
    When the tester runs `yarn audit:ci`
    Then the command exits with code 0
    And the output ends with `No audit suggestions`

  Scenario: iOS bundle builds
    When the tester runs `yarn react-native bundle --platform ios --dev false --minify false --reset-cache --entry-file index.js --bundle-output /tmp/main.jsbundle --sourcemap-output /tmp/main.map`
    Then the command exits with code 0
    And `/tmp/main.jsbundle` is written

  Scenario: App launches (optional smoke test)
    When the tester runs `yarn start:ios` or `yarn start:android` and unlocks the wallet
    Then the home screen loads with no red-box errors

Screenshots/Recordings

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Note

Low Risk
Test-only mock server and dependency lockfile changes with no production app logic touched; main risk is E2E/unit suites that depend on mockttp behavior.

Overview
Upgrades the E2E mock server dependency mockttp from 3.15.2 to 4.6.5 so the dependency tree picks up @graphql-tools/utils@12.x instead of the vulnerable 8.x line, and removes the MCWP-1041 audit ignore from .yarnrc.yml.

Supporting changes keep tests and installs working on mockttp 4: Jest transpiles ESM-only milliparsec and get-port; LavaMoat disables install scripts for optional mockttp>tls-impersonate; obsolete Yarn resolutions are dropped (mockttp 3 body-parser pin and unused @metamask/react-native-payments/validator).

Test harness updates: a scoped installCryptoRandomUUID helper is wired into the unit suites that start a local mockttp server, and smoke mocks use body.getJson<object>() for mockttp 4’s typing.

Reviewed by Cursor Bugbot for commit d6b77b5. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions Bot added size-S pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels Nov 25, 2026
@metamask-ci metamask-ci Bot added the team-mobile-platform Mobile Platform team label Nov 25, 2026
@metamask-ci

metamask-ci Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

Comment thread package.json
"@react-native-community/viewpager": "patch:@react-native-community/viewpager@npm%3A3.3.0#~/.yarn/patches/@react-native-community-viewpager-npm-3.3.0.patch",
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.5",
"@appium/schema/json-schema": "^0.4.0",
"@metamask/react-native-payments/validator": "^13.7.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react-native-payments does not use validator anymore

@weitingsun
weitingsun marked this pull request as ready for review November 25, 2026 22:44
@weitingsun
weitingsun requested review from a team as code owners November 25, 2026 22:44
@socket-security

socket-security Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​tslib@​2.8.1 ⏵ 2.9.1100100100 +188100
Updatednpm/​mockttp@​3.15.2 ⏵ 4.7.089 -410010089100

View full report

@socket-security

socket-security Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Priority Alert  (click "▶" to expand/collapse) Action
Low priority
Potential code anomaly (AI signal): npm mockttp is 96.0% likely to have a medium risk anomaly

Notes: This code implements an administrative mock-session server and does not show clear malware, credential theft, or suspicious external network communication. Its primary security risk is unauthenticated access to session creation, reset, plugin lifecycle, GraphQL, and WebSocket functionality if configured to listen on an externally reachable host; debug logging can also expose configuration and stream data. The default bind address is 127.0.0.1, and request bodies are limited to 50 MiB. Severity is context-dependent and elevated if exposed beyond a trusted local environment.

Confidence: 0.96

Severity: 0.57

From: package.json → npm/mockttp@4.7.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/mockttp@4.7.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Potential code anomaly (AI signal): npm mockttp is 96.0% likely to have a medium risk anomaly

Notes: The code is a readable SOCKS proxy server implementation with no clear malware or supply-chain backdoor indicators. Its intended behavior inherently accepts client-controlled network destinations and, by default, requires no authentication; deployments must enforce authentication and destination policies in the event consumer. The unbounded SOCKS4 string reader presents a plausible memory-exhaustion risk for malicious clients. The metadata handling should also be reviewed together with getSocketMetadata(), which is outside this fragment.

Confidence: 0.96

Severity: 0.62

From: package.json → npm/mockttp@4.7.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/mockttp@4.7.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Potential code anomaly (AI signal): npm ws is 75.0% likely to have a medium risk anomaly

Notes: The code implements a standard EventTarget-like mixin for wrapping event listeners and dispatching events to user callbacks. There are no suspicious patterns such as dynamic code execution, hardcoded secrets, or network activity. The risk is contingent on what the consumer does inside their handlers; the snippet itself does not introduce malware or data leakage mechanisms beyond normal event dispatch. Overall security risk is low in isolation.

Confidence: 0.75

Severity: 0.50

From: package.json → npm/webdriverio@9.27.0 → npm/@ledgerhq/device-management-kit@1.7.1 → npm/appium-uiautomator2-driver@8.2.2 → npm/appium-xcuitest-driver@12.1.4 → npm/expo@57.0.22 → npm/@metamask/platform-api-docs@0.2.1 → npm/storybook@10.6.2 → npm/@storybook/react-native@10.7.0 → npm/mockttp@4.7.0 → npm/@open-rpc/mock-server@1.7.5 → npm/@viem/anvil@0.0.10 → npm/@metamask/test-dapp-solana@0.3.1 → npm/jest-environment-jsdom@29.7.0 → npm/ws@8.23.1

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ws@8.23.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

Ignoring alerts on:

  • npm/tls-impersonate@0.2.2
  • npm/tslib@2.9.1

View full report

@weitingsun

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/tslib@2.9.1
@SocketSecurity ignore npm/tls-impersonate@0.2.2
@SocketSecurity ignore npm/mockttp@4.6.5
Research:

  • tslib@2.9.1 (publisher changed): all 14 files in the published tarball are byte-identical to the upstream v2.9.1 tag in microsoft/tslib. The publisher change matches upstream's move to a new release pipeline (per the v2.9.1 release notes). The only runtime change from 2.8.1 is an optional parameter on __rewriteRelativeImportExtension (Port content mapper changes to rewriteRelativeImportExtension microsoft/tslib#295).
  • mockttp@4.6.5 (AI anomaly): npm provenance verified with gh attestation verify: built on a GitHub-hosted runner from tag v4.6.5 (commit 10be5854) by .github/workflows/ci.yml. The flagged SOCKS server only runs when the socks option is set, which this repo never does. Test-only dependency.
  • tls-impersonate@0.2.2 (native binaries, network access): npm provenance verified the same way (tag v0.2.2, commit 2e3ae6ad, same maintainer as mockttp). The prebuilds are not committed to the repo; CI compiles them per platform and publishes them in the same signed run. The macOS arm64 binary links only libc++ and libSystem, with no URLs, shell or exec strings, or socket imports. Only loaded when mirrorTlsFingerprint is enabled (default off, not used here). Install scripts are disabled via lavamoat allowScripts. Its only network-related import is node:tls.

@weitingsun weitingsun self-assigned this Nov 30, 2026
@weitingsun weitingsun removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

@tommasini tommasini added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label Nov 30, 2026
weitingsun and others added 3 commits December 1, 2026 09:58
Restores STRATEGY.md and marketing-consent-use-cases.md to main's content. The merge of main had reformatted them; no content changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@weitingsun
weitingsun enabled auto-merge December 2, 2026 00:47

@LeVinhGithub LeVinhGithub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weitingsun
weitingsun added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 65d3df1 Dec 2, 2026
193 of 195 checks passed
@weitingsun
weitingsun deleted the fix/mockttp-4-graphql-tools-utils branch December 2, 2026 05:00
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 2, 2026
@metamask-ci metamask-ci Bot added the release-8.24.0 Issue or pull request that will be included in release 8.24.0 label Dec 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.24.0 Issue or pull request that will be included in release 8.24.0 size-S skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants