Vulnerabilities in pkg:npm/swagger-ui-dist

PACKAGE
Advisory Summary

GHSA-qrmm-w75w-3wpx is a MODERATE server side request forgery vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting Swagger ui libraries in the npm ecosystem. The issue involves server side request forgery in swaggerui. Remediation is available by upgrading affected packages to version 4.1.3, 6.3.0.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/swagger-ui-dist

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/swagger-ui-dist. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-qrmm-w75w-3wpx - MODERATE Server side request forgery in SwaggerUI
GHSA-6c9x-mj3g-h47x CVE-2021-46708 MODERATE Spoofing attack in swagger-ui-dist

GHSA-qrmm-w75w-3wpx at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-qrmm-w75w-3wpx
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product Swagger ui
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-qrmm-w75w-3wpx

To remediate this vulnerability, upgrade all affected Swagger ui 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-ui fixed: 4.1.3
npm install swagger-ui@4.1.3
swagger-ui-dist fixed: 4.1.3
npm install swagger-ui-dist@4.1.3
swagger-ui-react fixed: 4.1.3
npm install swagger-ui-react@4.1.3
Swashbuckle.AspNetCore.SwaggerUI fixed: 6.3.0
Upgrade Swashbuckle.AspNetCore.SwaggerUI to 6.3.0
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-ui

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-qrmm-w75w-3wpx, inspect your project dependencies using npm:

npm ls swagger-ui

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

Note: The npm ls swagger-ui 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-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In Swagger ui, 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

SwaggerUI supports displaying remote OpenAPI definitions through the `?url` parameter. This enables robust demonstration capabilities on sites like `petstore.swagger.io`, `editor.swagger.io`, and similar sites, where users often want to see what their OpenAPI definitions would look like rendered. However, this functionality may pose a risk for users who host their own SwaggerUI instances. In particular, including remote OpenAPI definitions opens a vector for phishing attacks by abusing the trusted names/domains of self-hosted instances. An example scenario abusing this functionality could take the following form: - `https://example.com/api-docs` hosts a version of SwaggerUI with `?url=` query parameter enabled. - Users will trust the domain `https://example.com` and the contents of the OpenAPI definition. - A malicious actor may craft a similar OpenAPI definition and service that responds to the defined APIs at `https://evildomain`. - Users mistakenly click a phishing URL like `https://example.com/api-docs?url=https://evildomain/fakeapi.yaml` and enters sensitive data via the "Try-it-out" feature. We do want to stress that this attack vector is limited to scenarios that actively trick users into divulging sensitive information. The ease of this is highly contextual and, therefore, the threat model may be different for individual users and organizations. It is *not* possible to perform non-interactive attacks (e.g., cross-site scripting or code injection) through this mechanism. ### Resolution We've made the decision to [disable query parameters (#4872)](https://github.com/swagger-api/swagger-ui/issues/4872) by default starting with SwaggerUI version `4.1.3`. Please update to this version when it becomes available (**ETA: 2021 December**). Users will still be able to be re-enable the options at their discretion. We'll continue to enable query parameters on the Swagger demo sites. ### Workaround If you host a version of SwaggerUI and wish to mitigate this issue immediately, you are encouraged to add the following custom plugin code: ```js SwaggerUI({ // ...other configuration options, plugins: [function UrlParamDisablePlugin() { return { statePlugins: { spec: { wrapActions: { // Remove the ?url parameter from loading an external OpenAPI definition. updateUrl: (oriAction) => (payload) => { const url = new URL(window.location.href) if (url.searchParams.has('url')) { url.searchParams.delete('url') window.location.replace(url.toString()) } return oriAction(payload) } } } } } }], }) ``` ### Future UX work Through the exploration of this issue, it became apparent that users may not be aware to which web server the Try-it-out function will send requests. While this information is currently presented at the top of the page, understanding may improve by displaying it closer to the "Execute" button where requests are actually made. We'll be exploring these UX improvements over the coming months and welcome community input. Please create a Feature Request under the GitHub Issue tab to start a conversation with us and the community. ## Reflected XSS attack **Warning** in versions < 3.38.0, it is possible to combine the URL options (as mentioned above) with a vulnerability in DOMPurify (https://www.cvedetails.com/cve/CVE-2020-26870/) to create a reflected XSS vector. If your version of Swagger UI is older than 3.38.0, we suggest you upgrade or implement the workaround as mentioned above.

GHSA-qrmm-w75w-3wpx Affected Swagger ui Versions

4 component(s)
Fixed Versions:
4.1.36.3.0
Product / Package Ecosystem Affected Versions Fixed Version
swagger-ui
npm
< 4.1.3
4.1.3
swagger-ui-dist
npm
< 4.1.3
4.1.3
swagger-ui-react
npm
< 4.1.3
4.1.3
Swashbuckle.AspNetCore.SwaggerUI
NuGet
< 6.3.0
6.3.0

References

Frequently Asked Questions

What is GHSA-qrmm-w75w-3wpx?
GHSA-qrmm-w75w-3wpx is a security vulnerability in Swagger ui involving Server side request forgery in SwaggerUI under CWE-918: Server-Side Request Forgery (SSRF).
Which Swagger ui versions are affected?
Affected versions include releases prior to 4.1.3, 6.3.0 across affected packages: swagger-ui, swagger-ui-dist, swagger-ui-react, Swashbuckle.AspNetCore.SwaggerUI.
What version fixes GHSA-qrmm-w75w-3wpx?
Upgrading to 4.1.3, 6.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is swagger-ui affected?
Yes, swagger-ui is affected in releases prior to 4.1.3. Upgrade your dependency to 4.1.3 or later.
Is swagger-ui-dist affected?
Yes, swagger-ui-dist is affected in releases prior to 4.1.3. Upgrade your dependency to 4.1.3 or later.
What CWE is associated with GHSA-qrmm-w75w-3wpx?
GHSA-qrmm-w75w-3wpx is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check npm dependencies for GHSA-qrmm-w75w-3wpx?
Run the dependency tree command: 'npm ls swagger-ui'. 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-qrmm-w75w-3wpx",
  "modified" : "2022-05-26T20:08:34Z",
  "published" : "2021-12-09T19:08:38Z",
  "aliases" : [ ],
  "summary" : "Server side request forgery in SwaggerUI",
  "details" : "SwaggerUI supports displaying remote OpenAPI definitions through the `?url` parameter. This enables robust demonstration capabilities on sites like `petstore.swagger.io`, `editor.swagger.io`, and similar sites, where users often want to see what their OpenAPI definitions would look like rendered.\n\nHowever, this functionality may pose a risk for users who host their own SwaggerUI instances. In particular, including remote OpenAPI definitions opens a vector for phishing attacks by abusing the trusted names/domains of self-hosted instances.\n\nAn example scenario abusing this functionality could take the following form:\n- `https://example.com/api-docs` hosts a version of SwaggerUI with `?url=` query parameter enabled.\n- Users will trust the domain `https://example.com` and the contents of the OpenAPI definition.\n- A malicious actor may craft a similar OpenAPI definition and service that responds to the defined APIs at `https://evildomain`.\n- Users mistakenly click a phishing URL like `https://example.com/api-docs?url=https://evildomain/fakeapi.yaml` and enters sensitive data via the \"Try-it-out\" feature.\n\nWe do want to stress that this attack vector is limited to scenarios that actively trick users into divulging sensitive information. The ease of this is highly contextual and, therefore, the threat model may be different for individual users and organizations. It is *not* possible to perform non-interactive attacks (e.g., cross-site scripting or code injection) through this mechanism.\n\n### Resolution \nWe've made the decision to [disable query parameters (#4872)](https://github.com/swagger-api/swagger-ui/issues/4872) by default starting with SwaggerUI version `4.1.3`. Please update to this version when it becomes available (**ETA: 2021 December**). Users will still be able to be re-enable the options at their discretion. We'll continue to enable query parameters on the Swagger demo sites.\n\n### Workaround\nIf you host a version of SwaggerUI and wish to mitigate this issue immediately, you are encouraged to add the following custom plugin code:\n\n```js\nSwaggerUI({\n  //  ...other configuration options,\n  plugins: [function UrlParamDisablePlugin() {\n    return {\n      statePlugins: {\n        spec: {\n          wrapActions: {\n            // Remove the ?url parameter from loading an external OpenAPI definition.\n            updateUrl: (oriAction) => (payload) => {\n              const url = new URL(window.location.href)\n              if (url.searchParams.has('url')) {\n                url.searchParams.delete('url')\n                window.location.replace(url.toString())\n              }\n              return oriAction(payload)\n            }\n          }\n        }\n      }\n    }\n  }],\n})\n```\n\n### Future UX work\n\nThrough the exploration of this issue, it became apparent that users may not be aware to which web server the Try-it-out function will send requests. While this information is currently presented at the top of the page, understanding may improve by displaying it closer to the \"Execute\" button where requests are actually made. We'll be exploring these UX improvements over the coming months and welcome community input. Please create a Feature Request under the GitHub Issue tab to start a conversation with us and the community.\n\n## Reflected XSS attack\n\n**Warning** in versions < 3.38.0, it is possible to combine the URL options (as mentioned above) with a vulnerability in DOMPurify (https://www.cvedetails.com/cve/CVE-2020-26870/) to create a reflected XSS vector. If your version of Swagger UI is older than 3.38.0, we suggest you upgrade or implement the workaround as mentioned above.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "swagger-ui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "swagger-ui-dist"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "swagger-ui-react"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Swashbuckle.AspNetCore.SwaggerUI"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/swagger-api/swagger-ui/security/advisories/GHSA-qrmm-w75w-3wpx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/swagger-api/swagger-ui/issues/4872"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/domaindrivendev/Swashbuckle.AspNetCore/commit/401c7cb81e5efe835ceb8aae23e82057d57c7d29"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/swagger-api/swagger-ui/commit/01a3e55960f864a0acf6a8d06e5ddaf6776a7f76"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/swagger-api/swagger-ui"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-918" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-09T17:49:08Z",
    "nvd_published_at" : null
  }
}