Home / Vulnerability Database / Python : Reflected XSS in CGI application
Python

Python : Reflected XSS in CGI application

Classification

Overview

The reflected XSS or client type XSS attack is possible, if application uses CGI.

Common Gateway Interface (CGI) offers a standard protocol for web servers to execute programs that execute like console applications. In brief, the HTML form data from HTTP POST request will be send by a web server to the CGI program via standard input. Other data, such as URL paths and HTTP header data are presented as process environment variables.

Cross-site scripting is one of the most common types of attacks on web applications. XSS attacks take seventh place in the “OWASP Top 10 2017” list of ten most significant vulnerabilities in web applications.

The main phase of any XSS attack is an imperceptible for the victim execution of a malicious code in the context of the vulnerable application. For this purpose, the functionality of the client application (browser) is used that allows to automatically execute scripts embedded in web page code. In most cases, these malicious scripts are implemented in JavaScript.

Consequences of an XSS attack vary from violations of application functionality to complete loss of user data confidentiality. The malicious code during the XSS attack can steal user HTTP-cookie, which gives an attacker the ability to make requests to the server on behalf of the user.

OWASP suggests the following classification of XSS attacks:

  • Server type XSS occurs when data from an untrusted source is included in the response returned by the server. The source of such data can be both user input and server database (where it had been previously injected by an attacker who exploited vulnerabilities in the server-side application).
  • Client type XSS occurs when the raw data from the user input contains code that changes the Document Object Model (DOM) of the web page received from the server. The source of such data can be both the DOM and the data received from the server (e.g., in response to an AJAX request).

Typical server type attack scenario:

  1. Unvalidated data, usually from a HTTP request, gets into the server part of the application.
  2. The server dynamically generates a web page that contains the unvalidated data.
  3. In the process of generating a web page, server does not prevent the inclusion of an executable code that can be executed in the client (browser), such as JavaScript code language, HTML-tags, HTML-attributes, Flash, ActiveX, etc., in the page code.
  4. The victim’s client application displays the web page that contains the malicious code injected via data from an untrusted source.
  5. Since malicious code is injected in the web page coming from the known server, the client part of the application (browser) executes it with the rights set for the application.
  6. This violates the same-origin policy, according to which the code from the one source must not get an access to resources from another source.

Client type attacks are executed in a similar way with the only difference that the malicious code is injected during the phase of the client application work with the document object model received from the server.

MEDIUM

DerScanner Severity Score

Do you want to fix Python : Reflected XSS in CGI application in your application?

See also

Python

Python : Debug mode on

Python

Python : Web3: Deprecated method

Python

Python : Unsafe padding