VAITP Dataset

← Back to the dataset

CVE-2016-10561

Directory traversal vulnerability in Bitty 0.2.10 via URL path in GET requests

  • CVSS 5.3
  • CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
  • Input Validation and Sanitization
  • Remote

Bitty is a development web server tool that functions similar to `python -m SimpleHTTPServer`. Version 0.2.10 has a directory traversal vulnerability that is exploitable via the URL path in GET requests.

CVSS base score
5.3
Published
2018-05-31
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Remote
Impact
Unauthorized Access
Affected component
Python
Fixed by upgrading
Yes

Solution

Update Bitty to version 0.2.11 or higher.

Vulnerable code sample

import os
import http.server

class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        path = self.translate_path(self.path)
        if os.path.exists(path):
            self.send_response(200)
            self.send_header("Content-type", "text/plain")
            self.end_headers()
            with open(path, 'rb') as f:
                self.copyfile(f, self.wfile)
        else:
            self.send_response(404)
            self.end_headers()


if __name__ == '__main__':
    server_address = ('', 8000)
    httpd = http.server.HTTPServer(server_address, MyHTTPRequestHandler)
    httpd.serve_forever()

Patched code sample

import os
import http.server

class MyHandler(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        #Sanitize the path to prevent directory traversal
        safe_path = os.path.normpath(self.translate_path(self.path))
        #Check if the path is within the server's root directory
        if not safe_path.startswith(os.getcwd()):
            self.send_error(403, "Forbidden")
            return

        if os.path.isdir(safe_path):
            safe_path = os.path.join(safe_path, "index.html") # Serve index.html if it's a directory

        try:
            with open(safe_path, 'rb') as f:
                self.send_response(200)
                self.send_header("Content-type", "text/html")
                self.end_headers()
                self.wfile.write(f.read())
        except FileNotFoundError:
            self.send_error(404, "File not found")
        except Exception as e:
            self.send_error(500, f"Internal Server Error: {e}")

Cite this entry

@misc{vaitp:cve201610561,
  title        = {{Directory traversal vulnerability in Bitty 0.2.10 via URL path in GET requests}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2018},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2016-10561},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2016-10561/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.