/

CVE-2026-24486

Severity:

HIGH RISK

(8.6)

Path Traversal in Python-Multipart File Handling

CVE-2026-24486

Modified

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write on Server Filesystem

Severity:

HIGH RISK

(8.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Python-Multipart, a streaming multipart parser for Python, contains a path traversal vulnerability when applications are configured with a non-default UPLOAD_DIR and UPLOAD_KEEP_FILENAME=True.

In this configuration, an attacker can craft malicious upload filenames that cause files to be written to unintended locations on the server's filesystem.

Affected context

This vulnerability arises in Python applications that:

  • Use Python-Multipart for handling file uploads, and
  • Override the default upload directory (UPLOAD_DIR), and
  • Enable UPLOAD_KEEP_FILENAME=True, allowing client-supplied filenames to be used directly on disk.

In such environments, uploaded files are stored using the user-provided filename with insufficient normalization or restriction, making the effective file path dependent on untrusted input.

Exploit preconditions

  • Attack surface: HTTP endpoints that accept multipart/form-data file uploads and are backed by Python-Multipart.
  • Required access: Ability to send file upload requests to the vulnerable endpoint (typically unauthenticated or authenticated web clients, depending on the application).
  • Trigger point: Submission of a file with a crafted filename containing path traversal sequences (e.g., nested directories, parent directory references) while the server is configured with a custom UPLOAD_DIR and UPLOAD_KEEP_FILENAME=True.
  • Why exploitation is possible: The upload handling logic trusts and preserves the client-supplied filename when constructing the final filesystem path, without consistently enforcing directory boundaries or sanitizing path traversal elements.

Why this happens

The root cause is the use of untrusted input (the uploaded file's filename) in filesystem path construction without robust validation or canonicalization.

When UPLOAD_KEEP_FILENAME=True is enabled, Python-Multipart uses the incoming filename to derive the destination path within UPLOAD_DIR. If directory separators or traversal sequences (such as ../) are not strictly rejected or normalized, the resulting path may escape the intended upload directory.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where user-controlled path components are insufficiently constrained, allowing access to or modification of files outside the designated storage area.

Potential impact

  • An attacker may write files to arbitrary locations within the server's accessible filesystem tree.
  • Uploaded content could overwrite existing files that the application user has permission to modify (e.g., logs, configuration fragments, or other application data).
  • An attacker could potentially plant executable scripts or code in web-accessible directories, enabling further code execution depending on the stack and deployment.
  • Application integrity and availability can be affected by corrupting or replacing critical data files.
  • Security controls based on assumed upload directory isolation may be bypassed.

General mitigation guidance

Effective mitigation focuses on decoupling file paths from untrusted filenames and strictly enforcing directory boundaries:

  • Prefer server-generated filenames (e.g., UUIDs or hashes) for all uploads, treating the client-supplied filename as metadata only, not as a path component.
  • Normalize and validate any path derived from user input, rejecting filenames that contain directory separators, parent directory references, or other filesystem control characters.
  • Enforce a strict, non-bypassable upload root directory and ensure path joins are performed on canonicalized components while verifying the resulting path remains within that directory.
  • Apply least-privilege filesystem permissions for the upload directory so that the application account cannot modify sensitive system or application files.
  • Use separate, non-executable storage locations for uploaded files so that even if traversal occurs, execution of uploaded content is less likely.

These patterns remain effective regardless of library or framework versions and help minimize risk from future path-handling issues.

How teams detect issues like this

Organizations can detect and monitor for path traversal in upload flows through:

  • Static analysis: Rules that flag code paths where user-controlled filenames are concatenated with directory paths or passed directly to filesystem APIs without normalization or validation.
  • Code review: Check upload handlers and middleware for use of client filenames in open, os.path.join, or similar calls; verify that filenames are treated as data, not as path components.
  • Runtime monitoring: Log full canonical paths of newly created upload files and alert when writes occur outside expected upload directories.
  • Security testing: Include automated tests that attempt uploads with traversal patterns in filenames and verify that files are constrained to the intended directory.
  • Policy enforcement: Use CI/CD checks or pre-commit hooks to prevent introduction of patterns that directly trust filename from a multipart request when building filesystem paths.

Automated code scanning tools can help identify unsafe path usage, but should be complemented with manual review of upload logic.

Sources

SourceLink
github.comgithub.com/Kludex/python-multipart/commit/9433f4bbc9652bdde82bbe380984e32f8cfc89c4
github.comgithub.com/Kludex/python-multipart/releases/tag/0.0.22
github.comgithub.com/Kludex/python-multipart/security/advisories/GHSA-wp53-j4wj-2cfg
access.redhat.comaccess.redhat.com/errata/RHSA-2026:10184
access.redhat.comaccess.redhat.com/errata/RHSA-2026:1504
access.redhat.comaccess.redhat.com/errata/RHSA-2026:19712
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3461
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3462
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3713
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3782
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3960
access.redhat.comaccess.redhat.com/errata/RHSA-2026:42644
access.redhat.comaccess.redhat.com/errata/RHSA-2026:44696
access.redhat.comaccess.redhat.com/errata/RHSA-2026:51357
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-24486
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2433132
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-24486.json

Frequently asked

questions

Yes. If an application exposes an HTTP endpoint that accepts file uploads via Python-Multipart with the vulnerable configuration, a remote client can exploit the issue by sending specially crafted filenames in multipart/form-data requests.

The attacker needs the ability to submit file uploads to the affected endpoint. Whether authentication is required depends on the application's access controls, but no local filesystem access is needed beyond the upload interface.

The most robust fix is to stop using client-supplied filenames when constructing filesystem paths. Generate server-side filenames, store user-visible names as metadata only, and enforce that the computed storage path is always within a dedicated upload directory with restricted permissions.

Adopt a consistent design rule that untrusted input must never directly influence filesystem paths, enforce strict validation and canonicalization for any path components, and include upload and file-handling code in regular security reviews and automated testing. Additionally, maintain secure defaults in configuration and avoid enabling options that rely on trusting client-provided filenames.

Find out what's already
exploitable in your codebase.