Executive brief
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.
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