# Swagger UI cross-site scripting via URL parameter

Source: https://junglewise.ai/threats/swagger-ui-cross-site-scripting-via-url-parameter-39b99c98  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2020-09-01. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: info · Published 2020-09-01

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.

Technologies: [swagger-ui (npm)](https://junglewise.ai/threats/technologies/swagger-ui). Vendors: [npm](https://junglewise.ai/threats/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?** Informational severity, published 1 September 2020.

**Which products and versions are affected?** swagger-ui (npm) SEMVER:introduced=0,fixed=2.2.1.

**Is there a fix for This vulnerability?** Yes. swagger-ui (npm): upgrade to 2.2.1 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.

**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 2.2.1 or later

  ```sh
  npm install swagger-ui@2.2.1
  ```


## 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

- [https://github.com/swagger-api/swagger-ui/issues/1617](https://github.com/swagger-api/swagger-ui/issues/1617)
- [https://github.com/swagger-api/swagger-ui/commit/a1aea70f2c64533bf053a41d4da5a8accd0117b7](https://github.com/swagger-api/swagger-ui/commit/a1aea70f2c64533bf053a41d4da5a8accd0117b7)

## Related threats

- [swagger-ui cross-site scripting in key names](https://junglewise.ai/threats/cve-2016-1000229-swagger-ui-cross-site-scripting-in-key-names)
- [Swagger UI spoofing attack via URL parameter](https://junglewise.ai/threats/cve-2018-25031-swagger-ui-spoofing-attack-via-url-parameter)
- [Swagger UI phishing vector via URL parameter](https://junglewise.ai/threats/swagger-ui-phishing-vector-via-url-parameter-8eeaa776)
- [Swagger UI Cross-Site Scripting in apiInfo.description](https://junglewise.ai/threats/swagger-ui-cross-site-scripting-in-apiinfo-description-6b3f2dbe)
- [Swagger Swagger UI Cross-Site Scripting in API response rendering](https://junglewise.ai/threats/swagger-swagger-ui-cross-site-scripting-in-api-response-rendering-be1bf724)
