Directory Traversal Vulnerability in Python 2.7: CGIHTTPServer Module Exploit

python2.7 Updated 02 Oct 2025

Summary

20/02/2020
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2014-4650: The CGIHTTPServer module in Python 2.7.5 and 3.3.4 does not properly handle URLs in which URL encoding is used for path separators, which allows remote attackers to read script source code or conduct directory traversal... Affects python2.7 versions < 2.7.8-1. Fixed in 2.7.8-1. 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Python 2.7 is a widely used programming language known for its simplicity and versatility. The CGIHTTPServer module allows for the creation of web servers that can handle Common Gateway Interface (CGI) requests. However, versions 2.7.5 and earlier are susceptible to a critical vulnerability that can be exploited by attackers to access sensitive files and execute unauthorized code.

Vulnerability Detail

The vulnerability arises from improper handling of URL encoding in the CGIHTTPServer module. Specifically, when path separators are encoded (e.g., using %2f), the server fails to correctly interpret these as directory separators. This flaw can lead to directory traversal attacks, allowing remote attackers to read sensitive script source code or execute unintended commands on the server. The vulnerability is present in Python versions 2.7.5 and 3.3.4, making it a significant risk for applications relying on these versions.

How To Fix

Minimum fixed version

2.7.8-1

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, you can restrict access to the CGIHTTPServer module or disable it entirely until the package is updated. Additionally, ensure that your web server is configured to prevent access to sensitive directories and files.

Conclusion

The directory traversal vulnerability in the CGIHTTPServer module of Python 2.7 poses a significant risk to applications using affected versions. It is crucial to update to the patched version to mitigate the risk of unauthorized access and code execution. Implementing workarounds and monitoring tools like Vulert can further enhance security.

See every vulnerability recorded for python2.7 →

Share this vulnerability

FAQ

The vulnerability allows attackers to perform directory traversal, potentially exposing sensitive files and executing unauthorized code.

Python versions 2.7.5 and 3.3.4 are affected by this vulnerability.

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

If immediate updates are not possible, consider implementing access restrictions to the CGIHTTPServer module and reviewing your server's security configurations.

Yes, Vulert can monitor and alert you in real-time for open-source vulnerabilities using just a manifest file like package-lock.json.

Related vulnerabilities

Recent vulnerabilities recorded for python2.7.

How To Fix

Minimum fixed version

2.7.8-1

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