# Swagger UI cross-site scripting in OAuth URL handling

Source: https://junglewise.ai/threats/swagger-ui-cross-site-scripting-in-oauth-url-handling-47ee73bd  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2020-09-11. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

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

Swagger UI is a widely-used library that generates interactive API documentation. Versions prior to 3.20.9 contain a cross-site scripting vulnerability in the OAuth authentication flow where URLs are not properly sanitized. An attacker can craft a malicious URL that, when processed by the OAuth handler, executes arbitrary JavaScript in a user's browser, potentially stealing authentication tokens or session cookies.

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?** 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.20.9.

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

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


## Technical details

The vulnerability is a reflected cross-site scripting (XSS) flaw in the OAuth authorization code flow implementation within Swagger UI. The root cause is the failure to sanitize or properly escape URLs before they are used in the OAuth auth flow, allowing an attacker to inject arbitrary JavaScript. An attacker can craft a malicious URL containing XSS payloads (e.g., script tags or event handlers) that gets reflected back to the user's browser without sanitization. This is a network-based attack requiring no authentication or elevated privileges, though it typically requires user interaction (clicking a malicious link). Exploitation allows an attacker to steal OAuth tokens, session cookies, or credentials. The vulnerability was patched in version 3.20.9 through URL sanitization improvements.

## Affected products

- Swagger Swagger UI before 3.20.9

## Timeline

- 2019-02-23: disclosed
- 2019-02-23: patched: Version 3.20.9 released with URL sanitization fix
- 2020-09-11: advisory: GHSA-4f9m-pxwh-68hg published

## References

- [https://github.com/swagger-api/swagger-ui/pull/5190](https://github.com/swagger-api/swagger-ui/pull/5190)
- [https://github.com/swagger-api/swagger-ui/commit/1e184e8e218676278c83e60a45846c199ce3d15e](https://github.com/swagger-api/swagger-ui/commit/1e184e8e218676278c83e60a45846c199ce3d15e)
- [https://github.com/swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui)
- [https://snyk.io/vuln/SNYK-JS-SWAGGERUI-449921](https://snyk.io/vuln/SNYK-JS-SWAGGERUI-449921)

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