Skip to content

Port to master: V2-precondition signing fix + Amplitude remote-code stripping#2862

Merged
piyalbasu merged 5 commits into
masterfrom
port/sign-v2-and-amplitude-strip
Jun 22, 2026
Merged

Port to master: V2-precondition signing fix + Amplitude remote-code stripping#2862
piyalbasu merged 5 commits into
masterfrom
port/sign-v2-and-amplitude-strip

Conversation

@piyalbasu

Copy link
Copy Markdown
Contributor

TL;DR

Ports two fixes from the 5.42.1 emergency release into master so the next regular release doesn't regress them:

  1. Soroban/V2-precondition transactions can be signed again. On the current SDK, signing any transaction with V2 preconditions (most Soroban dApp txs, e.g. Soroswap swaps) silently failed — the confirm popup never opened.
  2. Amplitude autocapture remote-code is deterministically stripped from the build. This is the code that gets the extension rejected by the Chrome Web Store ("remotely hosted code"); a guard so a dependency bump can't silently reintroduce it.

Both shipped in the 5.42.1 emergency release but were never on master, so master currently has both regressions.

Implementation details (for agents)

Why master is missing these: the emergency-release fix (PR #2860) merged into the v5.42.1 branch, not master. The Amplitude stripping originally landed via #2822 into the v5.41.2 release line and was likewise never forward-ported. So master has neither.

Change 1 — V2-precondition signing fix (b04acf1e)

  • freighterApiMessageListener.ts embedded the live stellar-sdk Transaction in the signing-popup URL blob and JSON.stringify'd it in encodeObject. On stellar-sdk v16, a V2-precondition tx carries a native BigInt (_minAccountSequenceAge), which JSON.stringify throws on (Do not know how to serialize a BigInt). The throw was swallowed as FreighterApiInternalError, so the popup never opened.
  • Fix: new extension/src/background/helpers/transactionInfo.tsgetSerializableTransaction() serializes only the fields the popup reads (_networkPassphrase, _fee, operation types). The popup already rebuilds the full tx from transactionXdr. No BigInt path, future-proof against other BigInt fields.
  • Test: extension/src/background/helpers/__tests__/transactionInfo.test.ts (4 cases) against a real V2-precondition Soroban XDR.

Change 2 — Amplitude autocapture stripping (6f6c3d78, re-applies #2822's mechanism)

  • webpack.common.js: resolve.alias maps @amplitude/plugin-autocapture-browser → a no-op stub.
  • extension/webpack/amplitude-autocapture-stub.js: the stub.
  • The flagged remote-code (loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz")) still exists in the installed dependency (@amplitude/plugin-autocapture-browser). It currently tree-shakes out of the bundle, but that's an incidental side effect of the resolved dep versions — master's amplitude deps have already drifted (analytics-browser 2.44.1 here vs 2.37.0 in 5.42.1), and the next bump could silently reintroduce it. We run autocapture: false, so the alias is behavior-neutral; it just makes exclusion deterministic and version-independent.

Verification (on master's dependency set):

  • yarn jest .../transactionInfo.test.ts → 4/4 pass (stellar-sdk v16).
  • yarn build:extension:production → succeeds; recursive grep of the build dir incl. .map files → 0 occurrences of cdn.amplitude.com / visual-tagging-selector.
  • npx tsc --noEmit -p extension/tsconfig.json clean; eslint clean on changed source.

Permalinks (head 6f6c3d788c454b27cdc500e87ec9cf2af10783f2):

Follow-up (out of scope): the emergency-release tooling (newRelease/submitBeta/submitProduction) has a target_commitish vs commitish typo that mis-tags releases, and newRelease branched the hotfix from master instead of the release tag — both tracked separately.

piyalbasu and others added 2 commits June 18, 2026 17:47
The freighter-api signTransaction flow embedded the live stellar-sdk
Transaction object in the signing-popup URL blob, then JSON.stringify'd
it in encodeObject. On stellar-sdk v16 (Protocol 27), a parsed tx carries
a native BigInt for the V2 precondition minSeqAge (transaction
._minAccountSequenceAge), which JSON.stringify cannot serialize. The throw
was swallowed as FreighterApiInternalError, so the popup never opened and
signing silently failed for any V2-precondition transaction (common for
Soroban dApp txs assembled via soroban-rpc).

Serialize only the fields the popup actually reads (_fee,
_networkPassphrase, operation types) via a new getSerializableTransaction
helper. The popup already rebuilds the full transaction from
transactionXdr, so dropping the live object is safe and sidesteps this and
any future BigInt-bearing field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Re-applies the webpack alias + stub from #2822 (which was merged into the
v5.41.2 release line but never forward-ported to master, so 5.42.0 and this
emergency release regressed). Aliases @amplitude/plugin-autocapture-browser
to a no-op stub so the autocapture "visual tagging" / "background capture"
remote-script code can never be bundled — a deterministic guard against
Chrome Web Store / Firefox AMO "remotely hosted code" rejection. We run with
autocapture: false, so this code is dead anyway.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit f50afc8)
Copilot AI review requested due to automatic review settings June 19, 2026 00:44
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-add0cded6bfa6cd13670 (SDF collaborators only — install instructions in the release description)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f6c3d788c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extension/webpack/amplitude-autocapture-stub.js Outdated

Copilot AI 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.

Pull request overview

Ports two production fixes from the v5.42.1 emergency release line back onto master to prevent regressions in the next regular release: (1) restore signing for Soroban / V2-precondition transactions impacted by BigInt JSON serialization, and (2) deterministically strip Amplitude autocapture’s remotely-hosted-script code paths from the extension bundle to satisfy store policies.

Changes:

  • Avoid serializing live stellar-sdk Transaction objects into the signing popup URL blob by replacing them with a minimal JSON-serializable shape (_networkPassphrase, _fee, operation types).
  • Add a regression test suite covering V2-precondition Soroban XDR serialization (including fee-bump op-type preservation).
  • Add a webpack alias that replaces @amplitude/plugin-autocapture-browser with a no-op stub to prevent remote-code strings from appearing in the built artifacts.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
extension/webpack/amplitude-autocapture-stub.js Adds a stub module used to replace Amplitude autocapture plugin at build time.
extension/webpack.common.js Adds webpack resolve.alias to force the autocapture plugin to resolve to the stub.
extension/src/background/messageListener/freighterApiMessageListener.ts Uses a minimal serializable transaction representation when encoding the signing popup URL blob.
extension/src/background/helpers/transactionInfo.ts Introduces getSerializableTransaction() helper to safely serialize only popup-consumed fields.
extension/src/background/helpers/__tests__/transactionInfo.test.ts Adds regression tests ensuring V2-precondition transactions can be encoded/decoded without BigInt serialization failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread extension/webpack/amplitude-autocapture-stub.js Outdated
Comment thread extension/webpack/amplitude-autocapture-stub.js Outdated
Comment thread extension/webpack/amplitude-autocapture-stub.js Outdated
piyalbasu and others added 2 commits June 22, 2026 12:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ix fragment)

The applied auto-fix left a flagged 'background-capture' token and a dangling
sentence fragment. Rephrase without the host/lib-name/identifier literals so no
remote-code string can ride into shipped source maps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5b9bf623b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +46 to +48
export const frustrationPlugin = noopPlugin(
"@amplitude/plugin-frustration-browser",
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add the missing performancePlugin export

The current lockfile resolves @amplitude/analytics-browser to 2.44.1, whose browser client imports performancePlugin from @amplitude/plugin-autocapture-browser along with the two factories stubbed here. Because this alias does not export performancePlugin, any path that enables Amplitude's performance autocapture resolves to a missing/undefined binding instead of the intended no-op, so initialization can break despite the stub; add a no-op performancePlugin export next to these plugin stubs.

Useful? React with 👍 / 👎.

@piyalbasu piyalbasu merged commit c3d209c into master Jun 22, 2026
11 of 12 checks passed
@piyalbasu piyalbasu deleted the port/sign-v2-and-amplitude-strip branch June 22, 2026 21:01
@github-actions github-actions Bot mentioned this pull request Jul 7, 2026
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.

3 participants