Lucene search
K

Python 3.12 Documentation Cross Site Scripting

🗓️ 21 Feb 2025 00:00:00Reported by Georgi GuninskiType 
packetstorm
 packetstorm
🔗 packetstorm.news👁 391 Views

Python 3.12 documentation shows insecure code example leading to Cross Site Scripting vulnerability.

Code
Python's official documentation contains textbook example of insecure code (XSS)
    
    Date: 2025-02-18
    Author: Georgi Guninski
    
    >From the official Python 3.12 documentation on the CGI module [1]
    
    ===
    form = cgi.FieldStorage()
    if "name" not in form or "addr" not in form:
        print("<H1>Error</H1>")
        print("Please fill in the name and addr fields.")
        return
    print("<p>name:", form["name"].value)
    print("<p>addr:", form["addr"].value)
    ...further form processing here...
    ===
    
    This is a textbook example of the Cross Site Scripting (XSS) vulnerability.
    
    The insecure code from the Python developers might have large impact
    on Python web development as a whole.
    
    It possibly contributes to XSS vulnerability in first page on google,
    Chatgpt [3] and Deepseek [4] where AI writes textbook insecure code.
    Web search on Debian's source code returns many results for `import
    cgi`.
    
    
    If you don't Read The Fine Manual then you are uninformed, if you read
    it you are disinformed.
    
    I am surprised this survived so long.
    
    Mitigation:
    CGI is Deprecated since version 3.11, removed in version 3.13. [2]
    
    Counter Mitigation: CGI started in the 90's, probably significant
    amount of legacy Python CGI.
    
    [1] https://docs.python.org/3.12/library/cgi.html
    [2] https://docs.python.org/3/library/cgi.html
    [3] https://www.linkedin.com/pulse/ai-chatgpt-writes-insecure-code-georgi-guninski
    [4] https://www.linkedin.com/pulse/deepseek-writes-textbook-insecure-code-2025-01-28-georgi-guninski-uuzcf

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation