CVE-2011-4940: XSS

Published Mar 14, 2012
·
Updated

A flaw was reported [1] in Python's SimpleHTTPServer's listdirectory() function. Due to a missing charset parameter, if a user were to connect to SimpleHTTPServer using IE7, which engages in encoding-sniffing and can be tricked into interpretting the output as UTF7. Because of this, an attacker could hide <script> tags in UTF7-encoded characters which do not get quoted by cgi.encode(), allowing XSS attacks.

This has been corrected upstream in version 2.6.7rc2 [2], 2.5.6c1 [3]. It may be fixed in 2.7 as well, but I was unable to find a commit to match it against.

[1] http://bugs.python.org/issue11442 [2] http://svn.python.org/view/python/branches/release26-maint/Lib/SimpleHTTPServer.py?r1=66717&r2=88831&view=patch [3] http://svn.python.org/view/python/branches/release25-maint/Lib/SimpleHTTPServer.py?r1=53148&r2=88815&view=patch

Other sources

The listdirectory function in Lib/SimpleHTTPServer.py in SimpleHTTPSe ...

Debian

Affected Software

40 affected componentsFixes available
Python Python<=2.5.6
Python Python=0.9.0
Python Python=0.9.1
Python Python=1.2
Python Python=1.3
Python Python=1.5.2
Python Python=1.6
Python Python=1.6.1
Python Python=2.0.1
Python Python=2.1.1
Python Python=2.1.2
Python Python=2.1.3
Python Python=2.2.1
Python Python=2.2.2
Python Python=2.2.3
Python Python=2.3.1
Python Python=2.3.2
Python Python=2.3.3
Python Python=2.3.4
Python Python=2.3.5
Python Python=2.3.7
Python Python=2.4.1
Python Python=2.4.2
Python Python=2.4.3
Python Python=2.4.4
Python Python=2.4.6
Python Python=2.5.1
Python Python=2.5.2
Python Python=2.5.3
Python Python=2.5.4
Python Python=2.6.1
Python Python=2.6.2
Python Python=2.6.3
Python Python=2.6.4
Python Python=2.6.5
Python Python=2.6.6
Python Python=2.7.1
Python Python=2.7.1-rc1
Python Python=2.7.2-rc1
debian/python2.7
2.7.18-8+deb11u1

Event History

Mar 14, 2012
Data Sourced
via Red Hat·08:23 PM
DescriptionSeverityAffected Software
Jun 27, 2012
CVE Published
via MITRE·10:00 AM
Data Sourced
via MITRE·10:00 AM
Description
Jan 11, 2024
Data Sourced
via Launchpad·09:58 PM
Description
Sep 20, 2024
Data Sourced
via Ubuntu·12:44 AM
RemedyDescriptionSeverityAffected Software
Feb 27, 2025
Data Sourced
via Debian·01:11 AM
DescriptionAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2011-4940?

CVE-2011-4940 has been assigned a moderate severity level due to its potential for information disclosure through improper handling of character encoding.

2

How do I fix CVE-2011-4940?

To remediate CVE-2011-4940, upgrade to the fixed versions of Python that include the charset parameter in the list_directory() function.

3

Which versions of Python are affected by CVE-2011-4940?

CVE-2011-4940 affects Python versions up to 2.5.6 and versions 2.6.x prior to patches that address this issue.

4

Can CVE-2011-4940 be exploited remotely?

Yes, CVE-2011-4940 can be exploited remotely if an attacker tricks users into connecting to a vulnerable SimpleHTTPServer.

5

What is the cause of CVE-2011-4940?

The cause of CVE-2011-4940 is a flaw in the list_directory() function of Python's SimpleHTTPServer due to a missing charset parameter.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203