Executive brief
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.
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