VAITP Dataset

← Back to the dataset

CVE-2022-25303

XSS in whoogle-search 0.7.2, unescaped "q" parameter in error message

  • CVSS 6.1
  • CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
  • Configuration Issues
  • Remote

The package whoogle-search before 0.7.2 are vulnerable to Cross-site Scripting (XSS) via the query string parameter q. In the case where it does not contain the http string, it is used to build the error_message that is then rendered in the error.html template, using the [flask.render_template](https://flask.palletsprojects.com/en/2.1.x/api/flask.render_template) function. However, the error_message is rendered using the [| safe filter](https://jinja.palletsprojects.com/en/3.1.x/templates/working-with-automatic-escaping), meaning the user input is not escaped.

CVSS base score
6.1
Published
2022-07-12
OWASP
A03 Injection
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Configuration Issues
Subcategory
Cross-Site Scripting (XSS)
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
whoogle-search
Fixed by upgrading
Yes

Solution

Update whoogle-search to version 0.7.2 or higher.

Vulnerable code sample

from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/search')
def search():
    query = request.args.get('q', '')
    
    # Check if query contains 'http'
    if 'http' not in query:
        # Vulnerable to XSS as the user input is rendered without escaping
        error_message = query  # Directly using user input
        return render_template('error.html', error_message=error_message)
    
    # Proceed with normal search logic
    # ...

if __name__ == '__main__':
    app.run(debug=True)

Patched code sample

from flask import Flask, render_template, request, escape

app = Flask(__name__)

@app.route('/search')
def search():
    query = request.args.get('q', '')
    
    # Check if query contains 'http'
    if 'http' not in query:
        # Escape the query to prevent XSS
        error_message = escape(query)
        return render_template('error.html', error_message=error_message)
    
    # Proceed with normal search logic
    # ...

if __name__ == '__main__':
    app.run(debug=True)

Cite this entry

@misc{vaitp:cve202225303,
  title        = {{XSS in whoogle-search 0.7.2, unescaped "q" parameter in error message}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2022},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2022-25303},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-25303/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.