Cross-Site Scripting Vulnerability in Python 2.7's SimpleHTTPServer Package

python2.7 Updated 02 Oct 2025

Summary

27/06/2012
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2011-4940: The list_directory function in Lib/SimpleHTTPServer.py in SimpleHTTPServer in Python before 2.5.6c1, 2.6.x before 2.6.7 rc2, and 2.7.x before 2.7.2 does not place a charset parameter in the Content-Type HTTP header, whic... Affects python2.7 versions < 2.7.2-8. Fixed in 2.7.2-8. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Python 2.7 is a widely-used programming language known for its simplicity and readability. The SimpleHTTPServer module allows users to quickly set up a basic web server to serve files over HTTP. However, a vulnerability in the list_directory function can expose users to cross-site scripting (XSS) attacks, particularly affecting Internet Explorer 7.

Vulnerability Detail

The vulnerability arises from the lack of a charset parameter in the Content-Type HTTP header in the list_directory function of SimpleHTTPServer. This omission makes it easier for remote attackers to exploit the server through crafted UTF-7 encoded requests, leading to potential XSS attacks. This issue affects versions of Python prior to 2.7.2, making it critical for users to be aware of the risks associated with running outdated versions.

How To Fix

Minimum fixed version

2.7.2-8

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python2.7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can implement additional input validation and sanitization on the server-side to mitigate the risk of XSS attacks until the package is updated.

Conclusion

The vulnerability in Python 2.7's SimpleHTTPServer poses significant risks, particularly for users running outdated versions. It is crucial to update to the patched version to safeguard against potential XSS attacks. Users are encouraged to utilize tools like Vulert for real-time monitoring of open-source vulnerabilities.

See every vulnerability recorded for python2.7 →

Share this vulnerability

FAQ

The vulnerability allows for cross-site scripting (XSS) attacks due to the absence of a charset parameter in the Content-Type HTTP header.

Versions of Python before 2.7.2 are affected by this vulnerability.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Exploitation of this vulnerability can lead to unauthorized script execution in the context of the user's browser, potentially compromising sensitive data.

Yes, implementing input validation and sanitization can help reduce the risk of XSS attacks until you can apply the necessary updates.

Related vulnerabilities

Recent vulnerabilities recorded for python2.7.

How To Fix

Minimum fixed version

2.7.2-8

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python2.7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback