VAITP Dataset

← Back to the dataset

CVE-2013-5654

YingZhi Python v1.9 allows arbitrary anonymous uploads to phone storage – Security vulnerability

  • CVSS 9.1
  • CWE-284 Improper Access Control
  • Input Validation and Sanitization
  • Remote

Vulnerability in YingZhi Python Programming Language v1.9 allows arbitrary anonymous uploads to the phone's storage

CVSS base score
9.1
Published
2019-02-15
OWASP
A04 Insecure Design
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Direct Object References (IDOR)
Accessibility scope
Remote
Impact
Unauthorized Access
Affected component
Python
Fixed by upgrading
Yes

Solution

Update YingZhi Python Programming Language to version 2.0.0 or higher.

Vulnerable code sample

from flask import Flask, request

app = Flask(__name__)

@app.route('/upload', methods=['POST'])
def upload_file():
    # Directly save the uploaded file without validation
    file = request.files['file']
    file.save('/path/to/storage/' + file.filename)  # Vulnerable to arbitrary file uploads
    return 'File uploaded successfully', 200

if __name__ == '__main__':
    app.run()

Patched code sample

import os
from flask import Flask, request, abort

app = Flask(__name__)

# Define a safe upload folder
UPLOAD_FOLDER = '/path/to/safe/directory'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

# Allow only specific file types
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}

def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

@app.route('/upload', methods=['POST'])
def upload_file():
    # Check if the post request has the file part
    if 'file' not in request.files:
        abort(400)  # Bad request
    file = request.files['file']

    # If user does not select file, browser also submit an empty part without filename
    if file.filename == '':
        abort(400)  # Bad request

    if file and allowed_file(file.filename):
        # Secure the filename and save the file
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        return 'File uploaded successfully', 200
    else:
        abort(400)  # Bad request

if __name__ == '__main__':
    app.run()

Cite this entry

@misc{vaitp:cve20135654,
  title        = {{YingZhi Python v1.9 allows arbitrary anonymous uploads to phone storage - Security vulnerability}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2013-5654},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2013-5654/}}
}

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.