Cross-Site Scripting Vulnerability in swagger-ui

swagger-ui Updated 02 Oct 2025

Summary

11/09/2020
MODERATE
Yes i
Moderate
6.5

GHSA-4f9m-pxwh-68hg: Cross-Site Scripting in swagger-ui. Affects swagger-ui versions < 3.20.9. Fixed in 3.20.9. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

swagger-ui is an npm package that provides a user interface for visualizing and interacting with Swagger API documentation. It allows developers to view and test API endpoints, request/response payloads, and authentication mechanisms. However, versions prior to 3.20.9 of swagger-ui are vulnerable to Cross-Site Scripting (XSS) attacks. This vulnerability arises from the package's failure to properly sanitize URLs used in the OAuth authentication flow. As a result, attackers may be able to execute arbitrary JavaScript code on affected systems.

Vulnerability Detail

The Cross-Site Scripting (XSS) vulnerability in swagger-ui allows attackers to inject and execute malicious JavaScript code in the context of a user's browser. This can lead to various security risks, including unauthorized access to sensitive information, session hijacking, and the potential for further exploitation of the affected system. The vulnerability is rated as moderate severity with a CVSS score of 6.5. The Common Weakness Enumeration (CWE) identifier for this vulnerability is CWE-79.

How To Fix

Latest published version: 5.34.0 as of 22 Oct 2026

npm install swagger-ui@5.34.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.20.9

This is the first release that contains the fix.

npm install swagger-ui@3.20.9

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is essential to upgrade to the fixed version of the swagger-ui package to ensure the security of the application.

Conclusion

In conclusion, the swagger-ui package prior to version 3.20.9 is vulnerable to Cross-Site Scripting (XSS) attacks. This can allow attackers to execute arbitrary JavaScript code in the context of a user's browser, leading to potential security risks. To mitigate this vulnerability, it is crucial to upgrade to version 3.20.9 or later of the swagger-ui package. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for swagger-ui →

Share this vulnerability

FAQ

Swagger UI is an npm package that provides a user interface for visualizing and interacting with Swagger API documentation. It helps developers to explore and test API endpoints, request/response payloads, and authentication mechanisms.

Cross-Site Scripting (XSS) is a type of security vulnerability that allows attackers to inject and execute malicious scripts in the context of a user's browser. This can lead to various security risks, such as unauthorized access to sensitive information or the manipulation of user sessions.

The vulnerability in swagger-ui can allow attackers to execute arbitrary JavaScript code in the context of a user's browser. This can lead to unauthorized access to sensitive information, session hijacking, and potential further exploitation of the affected system.

To fix this vulnerability, it is recommended to upgrade to version 3.20.9 or later of the swagger-ui package. This version includes the necessary fixes to properly sanitize URLs used in the OAuth auth flow, mitigating the XSS vulnerability.

There is no known workaround for this vulnerability. It is essential to upgrade to the fixed version of the swagger-ui package to ensure the security of the application.

Related vulnerabilities

Recent vulnerabilities recorded for swagger-ui.

How To Fix

Latest published version: 5.34.0 as of 22 Oct 2026

npm install swagger-ui@5.34.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.20.9

This is the first release that contains the fix.

npm install swagger-ui@3.20.9

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback