VAITP Dataset

← Back to the dataset

CVE-2010-2480

Mako before 0.3.4: XSS via cgi.escape

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

Mako before 0.3.4 relies on the cgi.escape function in the Python standard library for cross-site scripting (XSS) protection, which makes it easier for remote attackers to conduct XSS attacks via vectors involving single-quote characters and a JavaScript onLoad event handler for a BODY element.

CVSS base score
4.3
Published
2010-07-02
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
Fixed by upgrading
Yes

Solution

Update Mako to version 0.3.4 or higher.

Vulnerable code sample

from mako.template import Template
import cgi

user_input = "<script>alert('XSS');</script>"
escaped_input = cgi.escape(user_input)

template = Template("""
<html>
<head>
    <title>Vulnerable Page</title>
</head>
<body onload="alert('${escaped_input}')">
    <h1>Welcome!</h1>
    <p>Your input: ${escaped_input}</p>
</body>
</html>
""")

print(template.render(escaped_input=escaped_input))

Patched code sample

from mako.template import Template

user_input = "<script>alert('XSS');</script>"

template = Template("""
<html>
<head>
    <title>Safe Page</title>
</head>
<body onload="alert('${user_input|h}')">
    <h1>Welcome!</h1>
    <p>Your input: ${user_input|h}</p>
</body>
</html>
""")

print(template.render(user_input=user_input))

Cite this entry

@misc{vaitp:cve20102480,
  title        = {{Mako before 0.3.4: XSS via cgi.escape}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2010},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2010-2480},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2010-2480/}}
}
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 ::