Junglewise Threat Intelligence

Swagger UI cross-site scripting via URL parameter

Severity: info · Published 2020-09-01

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

Executive brief

Swagger UI is an API documentation tool used by developers to explore and test web service endpoints. A flaw in how it processes the URL query string allows attackers to inject malicious JavaScript code that executes in the browsers of anyone viewing the documentation, potentially stealing credentials, session tokens, or sensitive API data.

Technical details

This is a cross-site scripting (XSS) vulnerability (CWE-79) in Swagger UI's handling of the URL query string parameter. The vulnerability exists in all versions prior to 2.2.1. An attacker can craft a malicious URL containing JavaScript payload in the url parameter, which is rendered unsanitized in the page. When a user visits this crafted URL, the malicious script executes in their browser with the same privileges as the legitimate Swagger UI application. No user interaction beyond visiting the link is required. The vulnerability was fixed in version 2.2.1 with proper input sanitization of URL parameters.

Affected products

  • Swagger API swagger-ui all versions before 2.2.1

Timeline

  • 2020-09-01: disclosed
  • 2016-08-23: patched: Fix committed in v2.2.1

References

Related threats