VAITP Dataset

← Back to the dataset

CVE-2023-25577

Unlimited multipart form data parsing in Werkzeug prior to 2.2.3 can lead to denial of service

  • CVSS 7.5
  • CWE-770 Allocation of Resources Without Limits or Throttling
  • Resource Management
  • Remote

Werkzeug is a comprehensive WSGI web application library. Prior to version 2.2.3, Werkzeug's multipart form data parser will parse an unlimited number of parts, including file parts. Parts can be a small amount of bytes, but each requires CPU time to parse and may use more memory as Python data. If a request can be made to an endpoint that accesses `request.data`, `request.form`, `request.files`, or `request.get_data(parse_form_data=False)`, it can cause unexpectedly high resource usage. This allows an attacker to cause a denial of service by sending crafted multipart data to an endpoint that will parse it. The amount of CPU time required can block worker processes from handling legitimate requests. The amount of RAM required can trigger an out of memory kill of the process. Unlimited file parts can use up memory and file handles. If many concurrent requests are sent continuously, this can exhaust or kill all available workers. Version 2.2.3 contains a patch for this issue.

CVSS base score
7.5
Published
2023-02-14
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Fixed by upgrading
Yes

Solution

Update Werkzeug to version 2.2.3 or higher.

Vulnerable code sample

from flask import Flask, request

app = Flask(__name__)

@app.route('/upload', methods=['POST'])
def upload_file():
    for file in request.files.getlist('files'):
        pass

    return 'Files uploaded successfully', 200

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

Patched code sample

from flask import Flask, request, abort

app = Flask(__name__)

MAX_FILE_PARTS = 10

@app.route('/upload', methods=['POST'])
def upload_file():
    if len(request.files) > MAX_FILE_PARTS:
        abort(413)

    for file in request.files.getlist('files'):
        pass

    return 'Files uploaded successfully', 200

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

Cite this entry

@misc{vaitp:cve202325577,
  title        = {{Unlimited multipart form data parsing in Werkzeug prior to 2.2.3 can lead to denial of service}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-25577},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-25577/}}
}
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 ::