HTML injection in swagger UI
The Swagger UI accepted a user-supplied configuration URL and rendered its content without sanitisation, allowing an attacker to inject HTML. An attacker could use this to run scripts in a victim's browser and steal session data or perform actions as the user.
- Fixed in 38 days
- Disclosed after 3 months
Hi team, I hope you're doing well. An HTML Injection vulnerability was discovered in the Swagger UI, which could potentially allow attackers to inject malicious HTML content. This vulnerability could be exploited to execute arbitrary scripts in the context of the user's browser, leading to cross-site scripting (XSS) attacks and other malicious activities.
- Swagger UI is a tool for visualizing and interacting with API documentation. During a security assessment, it was found that the Swagger UI is vulnerable to HTML Injection, which could lead to XSS attacks. This vulnerability exists because the application fails to properly sanitize user-supplied input before rendering it in the HTML context.
Steps to Reproduce:
- Nevigate to the
https://35.156.81.191/swagger? - Add this payload
config=https://gist.githubusercontent.com/zenelite123/af28f9b61759b800cb65f93ae7227fb5/raw/04003a9372ac6a5077ad76aa3d20f2e76635765b/test.json - After putting payload you will see the fake log in page created successfully.

Impact
An attacker exploiting this vulnerability could perform the following actions:
- Execute arbitrary JavaScript code in the context of the user's browser.
- Steal sensitive information such as session tokens, cookies, and other data accessible through JavaScript.
- Perform actions on behalf of the user, such as API requests with the user's privileges.
- Redirect the user to a malicious website.
Please feel free to contact me if you need any further information or assistance in addressing this issue. Kind regards @ehaftab
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary JavaScript in the victim's browser, steal session tokens and cookies, act as the user, or redirect them to a malicious site.
What the attacker needed
Victim visits a crafted Swagger UI URL; attacker hosts a malicious config file
How it was found
- Open the Swagger UI page on the target host.
- Add a config parameter pointing to an externally hosted JSON file.
- Observe that a fake login page is rendered from the supplied content.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Swagger UI is a page that helps developers read and test an API. This report says the page let someone point it at a file they controlled, and the page displayed that file's content as if it were part of the site. Because the content was not cleaned, a malicious file could include code that runs in the visitor's browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.