Skip to content

fix(tanstack-start): patch CVE-2026-102989 server-function XSS - #1476

Merged
trueadm merged 1 commit into
mainfrom
fix/tanstack-start-cve-2026-102989
Sep 30, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/tanstack-start-cve-2026-102989

Conversation

@trueadm

@trueadm trueadm commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Applies the fix for CVE-2026-102989 (GHSA-qx66-fv34-fjm8, CVSS 9.3) — a critical unauthenticated reflected XSS in TanStack Start's server-function response handling — as a pnpm patch on the pinned @tanstack/[email protected].

@octanejs/tanstack-start re-exports @tanstack/start-server-core and drives requests through its createStartHandler, so the vulnerable handler ships inside that dependency. The backport mirrors the upstream fix (first released in [email protected]): server-function requests accept only the public { data, context, method } fields from the client, and the non-server-function path no longer returns a non-Response object as the raw HTTP response (only Response/null/primitives pass through; objects fall through to safe serialization).

⚠️ Scope: this protects the monorepo, not published consumers yet

patchedDependencies rewrites only the copy resolved inside this repository, so this PR protects the monorepo's own apps (website, examples) and CI. It is not included in the published @octanejs/tanstack-start tarball, so external consumers who install from npm still resolve the unpatched @tanstack/start-server-core.

The consumer-facing fix is a larger, separate project tracked in #1478. It is not a simple dependency bump: [email protected] pins @tanstack/[email protected], which is a ground-up rewrite of the router store model (removes matchStores/firstId/pending*/cached*/loadedAt/hasPending/matchesId/statusCode/hasNotFoundMatch, globalNotFound→_notFound) that @octanejs/tanstack-router is built on — so adopting it requires re-porting the router binding + SSR + HMR and bumping the parity baseline. Vendoring the runtime chain into the published src was also attempted and abandoned: the Start runtime chain is designed to be an external dependency (optimizeDeps-excluded, isomorphically stripped), and as app source vite fails to resolve createStartHandler's app-level virtual-entry imports. See #1478 for both viable designs.

Interim mitigation for consumers (from the advisory): an edge/WAF rule on the server-function path (default /_serverFn/*) blocking requests without x-tsr-serverFn: true or that look like document navigations, plus a restrictive CSP on server-function responses. Stopgaps, not a fix.

Changes

  • patches/@[email protected] — backported security fix (ESM dist/esm/server-functions-handler.js; the package is ESM-only).
  • pnpm-workspace.yaml — register the patch under patchedDependencies, with a comment recording the CVE, the repo-only scope, and Ship consumer-facing fix for CVE-2026-102989 (TanStack Start server-function XSS) #1478.
  • pnpm-lock.yaml — every in-repo [email protected] resolution now carries the patch hash.
  • packages/tanstack-start/tests/server-function-xss.test.ts — regression guard asserting the security invariant holds in the resolved dependency; fails if the patch stops applying. End-to-end server-function behaviour stays covered by rsbuild-plugin.test.ts.
  • 87 packages/*/audit/react-parity.json + the octane-evals manifest — pnpm sync output (lockfile-hash propagation only; verified no other field changed).

No changeset: there is no change to the published @octanejs/tanstack-start behaviour, so this does not warrant a release. The consumer-facing change ships via #1478.

Validation

Scoped validation — this is a repo-local dependency patch plus one test and generated files, so it cannot affect unrelated packages. What was run:

  • pnpm format:check (repo-wide, clean)
  • pnpm typecheck (not run repo-wide; ran pnpm typecheck:files on the new test — clean)
  • pnpm test (not run repo-wide)
  • targeted tests: tanstack-start (58), tanstack-start-rsbuild (end-to-end server function through the patched handler), and the new server-function-xss guard (2) — all green. Verified the guard fails against the unpatched copy.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


Note

High Risk
Patches critical unauthenticated reflected XSS in server-function HTTP handling; incorrect or missing patch would leave monorepo apps exposed until rebuild/redeploy.

Overview
Addresses CVE-2026-102989 (reflected XSS in TanStack Start server-function handling) by backporting upstream fixes onto the pinned @tanstack/[email protected] via a pnpm patch, avoiding a router-core bump that would break @octanejs/tanstack-router.

The patch tightens server-function request handling: client input is limited to { data, context, method }, and non-server-function paths no longer return arbitrary objects as raw HTTP responses (only Response, null, or primitives).

Adds packages/tanstack-start/tests/server-function-xss.test.ts, which inspects the resolved server-functions-handler.js so CI fails if the patch stops applying or vulnerable patterns return.

Generated follow-through: lockfileSha256 in many packages/*/audit/react-parity.json files and overlayLockfileHash in packages/octane-evals/.../manifest.jsonl are updated to match the new lockfile after pnpm sync.

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 30, 2026
@github-actions
github-actions Bot marked this pull request as draft September 30, 2026 20:29

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: CVE patch omitted from published package
    • Added a postinstall script that applies the CVE-2026-102989 security fix to the co-installed @tanstack/[email protected] on consumer install, and bundled the pnpm-format patch file for consumers who disable lifecycle scripts.

Create PR

Or push these changes by commenting:

@cursor push 7b7e5892c3
Preview (7b7e5892c3)
diff --git a/.changeset/tanstack-start-cve-2026-102989.md b/.changeset/tanstack-start-cve-2026-102989.md
--- a/.changeset/tanstack-start-cve-2026-102989.md
+++ b/.changeset/tanstack-start-cve-2026-102989.md
@@ -21,5 +21,17 @@
 HTTP response on the non-server-function path. The patch is removed once Octane
 can adopt start-server-core >= 1.169.39.
 
+Because pnpm `patchedDependencies` only apply inside the declaring workspace, the
+published package also ships a `postinstall` script that applies the same fix to
+the co-installed `@tanstack/[email protected]`. If your environment
+disables lifecycle scripts (`--ignore-scripts`), add the patch manually — a copy
+is bundled at `node_modules/@octanejs/tanstack-start/patches/@[email protected]`.
+For pnpm workspaces, add to `pnpm-workspace.yaml`:
+
+```yaml
+patchedDependencies:
+  '@tanstack/[email protected]': 'node_modules/@octanejs/tanstack-start/patches/@[email protected]'
+```
+
 Apps must rebuild and redeploy to pick up the fix; upgrading the dependency alone
 does not patch an already-deployed app.

diff --git a/packages/tanstack-start/package.json b/packages/tanstack-start/package.json
--- a/packages/tanstack-start/package.json
+++ b/packages/tanstack-start/package.json
@@ -31,6 +31,8 @@
   "types": "src/index.d.ts",
   "files": [
     "src",
+    "scripts/postinstall-cve-patch.mjs",
+    "patches",
     "LICENSE",
     "README.md",
     "THIRD_PARTY_NOTICES.md"
@@ -113,6 +115,7 @@
     "./src/default-entry/client.js"
   ],
   "scripts": {
+    "postinstall": "node scripts/postinstall-cve-patch.mjs",
     "test": "cd ../.. && vitest run --project tanstack-start --project tanstack-start-rsbuild"
   },
   "dependencies": {

diff --git a/packages/tanstack-start/patches/@[email protected] b/packages/tanstack-start/patches/@[email protected]
new file mode 100644
--- /dev/null
+++ b/packages/tanstack-start/patches/@[email protected]
@@ -1,0 +1,40 @@
+diff --git a/dist/esm/server-functions-handler.js b/dist/esm/server-functions-handler.js
+index c493774211d1ea4b966e9fcd437e3e833d8f932e..69e7b1590fbdc9640b62152e1aaff7331bf7f01c 100644
+--- a/dist/esm/server-functions-handler.js
++++ b/dist/esm/server-functions-handler.js
+@@ -49,21 +49,25 @@ var handleServerAction = async ({ request, context, serverFnId }) => {
+ 				if (methodUpper === "GET") {
+ 					const payloadParam = url.searchParams.get("payload");
+ 					if (payloadParam && payloadParam.length > MAX_PAYLOAD_SIZE) throw new Error("Payload too large");
+-					const payload = payloadParam ? parsePayload(JSON.parse(payloadParam)) : {};
+-					payload.context = safeObjectMerge(payload.context, context);
+-					payload.method = methodUpper;
+-					return await action(payload);
++					const payload = payloadParam ? parsePayload(JSON.parse(payloadParam)) : void 0;
++					return await action({
++						data: payload?.data,
++						context: safeObjectMerge(payload?.context, context),
++						method: methodUpper
++					});
+ 				}
+ 				let jsonPayload;
+ 				if (contentType?.includes("application/json")) jsonPayload = await request.json();
+-				const payload = jsonPayload ? parsePayload(jsonPayload) : {};
+-				payload.context = safeObjectMerge(payload.context, context);
+-				payload.method = methodUpper;
+-				return await action(payload);
++				const payload = jsonPayload ? parsePayload(jsonPayload) : void 0;
++				return await action({
++					data: payload?.data,
++					context: safeObjectMerge(payload?.context, context),
++					method: methodUpper
++				});
+ 			})();
+-			const unwrapped = res.result || res.error;
++			const unwrapped = res.error !== void 0 ? res.error : res.result;
+ 			if (isNotFound(res)) res = isNotFoundResponse(res);
+-			if (!isServerFn) return unwrapped;
++			if (!isServerFn && (unwrapped instanceof Response || unwrapped === null || typeof unwrapped !== "object")) return unwrapped;
+ 			if (unwrapped instanceof Response) {
+ 				if (isRedirect(unwrapped)) return unwrapped;
+ 				unwrapped.headers.set(X_TSS_RAW_RESPONSE, "true");

diff --git a/packages/tanstack-start/scripts/postinstall-cve-patch.mjs b/packages/tanstack-start/scripts/postinstall-cve-patch.mjs
new file mode 100644
--- /dev/null
+++ b/packages/tanstack-start/scripts/postinstall-cve-patch.mjs
@@ -1,0 +1,82 @@
+/**
+ * Backport the fix for CVE-2026-102989 onto an unpatched
+ * @tanstack/[email protected] that was installed from the public
+ * registry.  The workspace-level pnpm patch does the same thing locally, but
+ * patchedDependencies do not propagate to consumers of a published package, so
+ * this postinstall bridge fills the gap.
+ *
+ * The script is idempotent: it exits silently when the handler already carries
+ * the fix (patched by pnpm, or on a newer upstream release).
+ */
+
+import { readFileSync, writeFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
+import { dirname, join } from 'node:path';
+
+const require = createRequire(import.meta.url);
+
+let handlerPath;
+try {
+	const pkgPath = require.resolve('@tanstack/start-server-core/package.json');
+	handlerPath = join(dirname(pkgPath), 'dist', 'esm', 'server-functions-handler.js');
+} catch {
+	process.exit(0);
+}
+
+let source;
+try {
+	source = readFileSync(handlerPath, 'utf8');
+} catch {
+	process.exit(0);
+}
+
+if (!source.includes('payload.method = methodUpper')) {
+	process.exit(0);
+}
+
+const replacements = [
+	{
+		old: 'const payload = payloadParam ? parsePayload(JSON.parse(payloadParam)) : {};\n\t\t\t\t\tpayload.context = safeObjectMerge(payload.context, context);\n\t\t\t\t\tpayload.method = methodUpper;\n\t\t\t\t\treturn await action(payload)',
+		new: 'const payload = payloadParam ? parsePayload(JSON.parse(payloadParam)) : void 0;\n\t\t\t\t\treturn await action({\n\t\t\t\t\t\tdata: payload?.data,\n\t\t\t\t\t\tcontext: safeObjectMerge(payload?.context, context),\n\t\t\t\t\t\tmethod: methodUpper\n\t\t\t\t\t})',
+	},
+	{
+		old: 'const payload = jsonPayload ? parsePayload(jsonPayload) : {};\n\t\t\t\tpayload.context = safeObjectMerge(payload.context, context);\n\t\t\t\tpayload.method = methodUpper;\n\t\t\t\treturn await action(payload)',
+		new: 'const payload = jsonPayload ? parsePayload(jsonPayload) : void 0;\n\t\t\t\treturn await action({\n\t\t\t\t\tdata: payload?.data,\n\t\t\t\t\tcontext: safeObjectMerge(payload?.context, context),\n\t\t\t\t\tmethod: methodUpper\n\t\t\t\t})',
+	},
+	{
+		old: 'const unwrapped = res.result || res.error',
+		new: 'const unwrapped = res.error !== void 0 ? res.error : res.result',
+	},
+	{
+		old: 'if (!isServerFn) return unwrapped;',
+		new: 'if (!isServerFn && (unwrapped instanceof Response || unwrapped === null || typeof unwrapped !== "object")) return unwrapped;',
+	},
+];
+
+let patched = source;
+for (const { old: from, new: to } of replacements) {
+	patched = patched.replace(from, to);
+}
+
+if (patched === source) {
+	console.warn(
+		'[@octanejs/tanstack-start] Could not auto-apply the CVE-2026-102989 fix.\n' +
+			'If using pnpm, add to pnpm-workspace.yaml:\n' +
+			'  patchedDependencies:\n' +
+			"    '@tanstack/[email protected]': " +
+			"'node_modules/@octanejs/tanstack-start/patches/@[email protected]'",
+	);
+	process.exit(0);
+}
+
+try {
+	writeFileSync(handlerPath, patched);
+} catch {
+	console.warn(
+		'[@octanejs/tanstack-start] Could not write the CVE-2026-102989 fix (read-only node_modules).\n' +
+			'If using pnpm, add to pnpm-workspace.yaml:\n' +
+			'  patchedDependencies:\n' +
+			"    '@tanstack/[email protected]': " +
+			"'node_modules/@octanejs/tanstack-start/patches/@[email protected]'",
+	);
+}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 8e03fcb. Configure here.

@trueadm
trueadm marked this pull request as ready for review September 30, 2026 20:40
@octanejs/tanstack-start drives requests through @tanstack/start-server-core and
does not fork its server-function handler, so the critical unauthenticated
reflected XSS in CVE-2026-102989 (GHSA-qx66-fv34-fjm8) ships inside the pinned
@tanstack/[email protected] dependency: an attacker could craft a
server-function URL that returns attacker-controlled HTML from the app's origin.

Apply the upstream fix (first released in start-server-core 1.169.39) as a pnpm
patch on the current pin: restrict client-supplied server-function input to the
public {data, context, method} fields, and stop returning a non-Response result
as the raw HTTP response on the non-server-function path.

SCOPE: the pnpm patch rewrites only the copy resolved inside this repository, so
it protects the monorepo's own apps (website, examples) and CI. It does NOT ship
in the published @octanejs/tanstack-start tarball, so external consumers who
install from npm still resolve the unpatched dependency. The consumer-facing fix
requires adopting start-server-core >= 1.169.39 (which forces the router-core
1.171.34 store-model re-port) or republishing a patched core, tracked in #1478.
No changeset: there is no change to the published package's behaviour.

Add a regression guard (server-function-xss.test.ts) that fails if the patch
stops applying.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@trueadm
trueadm force-pushed the fix/tanstack-start-cve-2026-102989 branch from 8e03fcb to 920010c Compare September 30, 2026 21:26
@trueadm

trueadm commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

Bugbot was correct — thank you. The pnpm patch only rewrites the copy resolved inside this repo (protecting the monorepo's own apps + CI), and does not ship in the published @octanejs/tanstack-start tarball, so npm consumers still resolved the unpatched @tanstack/start-server-core.

I dug into the two ways to actually fix it for consumers (bump to [email protected], which forces the [email protected] store-model re-port; or republish a patched core under @octanejs) and both are multi-step projects — vendoring the runtime chain into src was attempted and fails against vite's build model. Rather than ship a misleading "fix", this PR is now explicitly scoped as repo-only hardening (changeset removed, PR + patchedDependencies comment say so plainly), and the consumer-facing fix is tracked in #1478.

@trueadm
trueadm merged commit 874ca5f into main Sep 30, 2026
29 checks passed
@trueadm
trueadm deleted the fix/tanstack-start-cve-2026-102989 branch September 30, 2026 21:52
trueadm added a commit that referenced this pull request Sep 30, 2026
Keep main's @tanstack/start-server-core CVE-2026-102989 patch (#1476) and
leave out the @tsrx/prettier-plugin 0.4.10 patch this branch drops for
0.5.2, in both pnpm-workspace.yaml and the lockfile. Regenerate lockfile
hashes and the evals manifest with pnpm sync.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant