Skip to content

fix(security): prevent trezor-connect-src connectSrc-override XSS (Immunefi #40463) - #1143

Merged
tjcloa merged 1 commit into
developfrom
fix/trezor-connect-src-xss
Jul 29, 2026
Merged

fix(security): prevent trezor-connect-src connectSrc-override XSS (Immunefi #40463)#1143
tjcloa merged 1 commit into
developfrom
fix/trezor-connect-src-xss

Conversation

@tjcloa

@tjcloa tjcloa commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

DOM-based reflected XSS via the @trezor/connect-web connectSrc override. parseConnectSettings picks up any query-string segment whose text contains the substring trezor-connect-src and uses its value verbatim as the Trezor popup/iframe URL, with no scheme check for non-http values. A ?…trezor-connect-src…=javascript:… payload therefore executes in our origin once the Trezor connect flow is launched.

Reported and bountied via Immunefi #40463 and previously patched with an exact-key filter (URLSearchParams.has('trezor-connect-src')) — which is trivially bypassed by appending any character (trezor-connect-srcz, x-trezor-connect-src, …), since the library matches by substring, not exact key.

Fix

Replace the exact-key guard with stripTrezorConnectSrcParam(), which strips any query segment containing the substring (case-insensitively — a superset of the library's case-sensitive match) before TrezorConnect.init() can read the query string. It only rewrites the URL when a match is present, preserving path, other query params, and #fragment otherwise.

Verification

  • Unit tests 8/8 (sanitizeUrl.test.ts): exact param, -srcz / x-prefixed / mixed-case bypasses, targeted multi-param removal, and no-op cases.
  • Branch preview: the -srcz payload and the original param are both stripped on load; walking Get started → Trezor → Continue, window.open targets https://connect.trezor.io/9/popup.html (never javascript:), no alert fires. Legit links, paths, query params, and #fragments are preserved.

Scope

App-layer fix only. A CSP backstop and the @trezor/connect-web upgrade (the Trezor popup currently shows a "deprecated version" notice for the pinned 9.1.4) are tracked separately.

…act key

@trezor/connect-web parseConnectSettings picks up connectSrc from any &-segment whose text contains the substring trezor-connect-src (indexOf >= 0), then uses it verbatim as the popup/iframe URL with no scheme validation for non-http values, so a javascript: value executes in our origin (Immunefi #40463).

The previous guard used URLSearchParams.has(trezor-connect-src), an exact-key match, trivially bypassed by variants like trezor-connect-srcz or x-trezor-connect-src that the library still matches by substring.

Replace it with stripTrezorConnectSrcParam(), which removes any query segment containing the substring case-insensitively (a superset of connect-web case-sensitive matching), before TrezorConnect.init() can read the query string. Unit-tested: exact param, the -srcz / x- prefixed / mixed-case bypasses, multi-param preservation, and no-op cases.
@netlify

netlify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploy Preview for sovryn-dapp ready!

Name Link
🔨 Latest commit d96a424
🔍 Latest deploy log https://app.netlify.com/projects/sovryn-dapp/deploys/6a69f6513f48b40008ba759c
😎 Deploy Preview https://deploy-preview-1143.preview.sovryns.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d96a424

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@tjcloa
tjcloa merged commit 911c950 into develop Jul 29, 2026
7 checks passed
@tjcloa
tjcloa deleted the fix/trezor-connect-src-xss branch July 29, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant