CVE-2013-5655
Directory traversal in YingZhi Python iOS 1.9 allows remote file access
- CVSS 6.4
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
- Input Validation and Sanitization
- Remote
Directory traversal vulnerability in the FTP server in YingZhi Python Programming Language for iOS 1.9 allows remote attackers to read and possibly write arbitrary files via a .. (dot dot) in the default URI.
- CVSS base score
- 6.4
- Published
- 2014-05-14
- 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 YingZhi Python Programming Language for iOS to version 1.10 or higher.
Vulnerable code sample
import os
def vulnerable_ftp_path(base_path, user_input_path):
# Directly join user input with base path
full_path = os.path.join(base_path, user_input_path)
# Read the file without any validation
with open(full_path, 'r') as file:
return file.read()
# Example usage
base_directory = '/secure/ftp/root'
user_input = '../etc/passwd' # Simulated user input attempting directory traversal
try:
content = vulnerable_ftp_path(base_directory, user_input)
print(content)
except Exception as e:
print(e)Patched code sample
import os
def secure_ftp_path(base_path, user_input_path):
# Normalize the paths to prevent directory traversal
normalized_path = os.path.normpath(user_input_path)
# Ensure the normalized path starts with the base path
if not normalized_path.startswith(base_path):
raise ValueError("Invalid path access attempt detected.")
# Construct the full path
full_path = os.path.join(base_path, normalized_path)
# Check if the path exists and is a file
if os.path.isfile(full_path):
with open(full_path, 'r') as file:
return file.read()
else:
raise FileNotFoundError("Requested file not found.")
# Example usage
base_directory = '/secure/ftp/root'
user_input = '../etc/passwd' # Simulated user input attempting directory traversal
try:
content = secure_ftp_path(base_directory, user_input)
print(content)
except Exception as e:
print(e)Cite this entry
@misc{vaitp:cve20135655,
title = {{Directory traversal in YingZhi Python iOS 1.9 allows remote file access}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2014},
note = {VAITP Python Vulnerability Dataset, entry CVE-2013-5655},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2013-5655/}}
}
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 ::
