Cross-Site Scripting Vulnerability in swagger-ui
Summary
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 ↓
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.
No signup required · Results in about 60 seconds
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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for swagger-ui.