Swagger swagger-ui Cross-Site Scripting in YAML description field

Severity: low · CVSS 3.1 · Published 2020-09-11

Swagger UI, a tool used to visualize and interact with API documentation, is vulnerable to a security flaw where malicious code can be embedded in API definition files. If a user views a specially crafted YAML file—either by importing it from a URL or pasting it into the editor—an attacker could execute unauthorized scripts in the user's browser. This could lead to the theft of sensitive information, such as session cookies or login credentials, potentially compromising the user's account.

Technologies: swagger-ui (npm). Vendors: npm.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Low severity, with a CVSS score of 3.1, published 11 September 2020.
Which products and versions are affected?
swagger-ui (npm) SEMVER:introduced=0,fixed=3.0.13.
Is there a fix for This vulnerability?
Yes. swagger-ui (npm): upgrade to 3.0.13 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run swagger-ui (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • swagger-ui (npm): upgrade to 3.0.13 or later
    npm install swagger-ui@3.0.13

Technical details

A Cross-Site Scripting (XSS) vulnerability exists in swagger-ui versions 3.0.0 through 3.0.12. The root cause is a failure to properly sanitize the 'description' field within YAML API definitions. An attacker can exploit this by providing a malicious YAML file containing an XSS payload (e.g., an img tag with an onerror attribute) via a URL or direct copy-paste into the Swagger editor. Successful exploitation requires user interaction and allows the attacker to execute arbitrary JavaScript in the context of the victim's browser session, potentially leading to session hijacking or data exfiltration. The issue is resolved in version 3.0.13.

Affected products

  • Swagger swagger-ui >= 3.0.0, < 3.0.13

Timeline

  • 2017-06-01: disclosed: Vulnerability reported via GitHub issue
  • 2020-09-11: advisory: GitHub Advisory published

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.