Repository navigation
fix(tanstack-start): patch CVE-2026-102989 server-function XSS - #1476
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
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.
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.
@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]>
8e03fcb to
920010c
Compare
|
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 I dug into the two ways to actually fix it for consumers (bump to |
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]>


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-startre-exports@tanstack/start-server-coreand drives requests through itscreateStartHandler, 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-Responseobject as the raw HTTP response (onlyResponse/null/primitives pass through; objects fall through to safe serialization).patchedDependenciesrewrites 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-starttarball, 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 (removesmatchStores/firstId/pending*/cached*/loadedAt/hasPending/matchesId/statusCode/hasNotFoundMatch,globalNotFound→_notFound) that@octanejs/tanstack-routeris built on — so adopting it requires re-porting the router binding + SSR + HMR and bumping the parity baseline. Vendoring the runtime chain into the publishedsrcwas 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 resolvecreateStartHandler'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 withoutx-tsr-serverFn: trueor that look like document navigations, plus a restrictive CSP on server-function responses. Stopgaps, not a fix.Changes
patches/@[email protected]— backported security fix (ESMdist/esm/server-functions-handler.js; the package is ESM-only).pnpm-workspace.yaml— register the patch underpatchedDependencies, 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 byrsbuild-plugin.test.ts.packages/*/audit/react-parity.json+ the octane-evals manifest —pnpm syncoutput (lockfile-hash propagation only; verified no other field changed).No changeset: there is no change to the published
@octanejs/tanstack-startbehaviour, 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; ranpnpm typecheck:fileson the new test — clean)pnpm test(not run repo-wide)tanstack-start(58),tanstack-start-rsbuild(end-to-end server function through the patched handler), and the newserver-function-xssguard (2) — all green. Verified the guard fails against the unpatched copy.Risk / follow-ups
@tanstack/[email protected]exactly; if that pin is bumped to another still-vulnerable version the patch stops applying and the regression guard fails, forcing a revisit.Provenance
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 (onlyResponse, null, or primitives).Adds
packages/tanstack-start/tests/server-function-xss.test.ts, which inspects the resolvedserver-functions-handler.jsso CI fails if the patch stops applying or vulnerable patterns return.Generated follow-through:
lockfileSha256in manypackages/*/audit/react-parity.jsonfiles andoverlayLockfileHashinpackages/octane-evals/.../manifest.jsonlare updated to match the new lockfile afterpnpm sync.Reviewed by Cursor Bugbot for commit 920010c. Bugbot is set up for automated code reviews on this repo. Configure here.