/

CVE-2026-124289

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in Fastify Multipart Uploads

CVE-2026-124289

Awaiting Analysis

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22, CWE-843

Impact:

Arbitrary Relative-Path File Write

Severity:

HIGH RISK

(7.5)

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

In affected Fastify multipart configurations, saveRequestFiles can mistake a forged request-body object for an uploaded file and preserve its filename without reducing it to a basename. An unauthenticated client may use this behavior to write attacker-chosen bytes to a relative path if the application uses the returned filename as a destination.

Affected context

The issue concerns @fastify/multipart when it is registered with the attachFieldsToBody option and an application calls saveRequestFiles on parsed request data. A plain JSON request or a JSON-typed multipart field can provide an object with truthy file and buffer properties that the helper treats as an uploaded file. Risk is greater when the application uses the returned filename as a filesystem destination; the helper's handling can also bypass upload hooks and file count and size limits.

Exploit preconditions

  • Attack surface: A Fastify endpoint processes request data with the affected multipart plugin configuration.
  • Required access: The described request can be sent by an unauthenticated client, provided the endpoint is reachable.
  • Trigger point: The application calls saveRequestFiles on parsed request data, including data originating from a plain JSON request or a JSON-typed multipart field.
  • Why exploitation is possible: Objects with truthy file and buffer properties can be treated as files, and the returned filename is not reduced to its basename. A relative-path write requires the application to use that filename as a write destination.

Why this happens

The helper relies on attacker-controlled object properties to identify uploaded files rather than verifying that each entry is a genuine file produced through the expected multipart parsing path. This type confusion is associated with CWE-843. Preserving a filename containing parent-directory segments can then enable path traversal, mapping to CWE-22, when downstream code uses it to construct a filesystem destination.

Potential impact

  • Attacker-controlled bytes may be written to the temporary directory while upload hooks and file count or size limits are bypassed.
  • An application that uses the returned filename as a destination may write a file outside its intended directory.
  • Sensitive files or application data could be affected, depending on filesystem permissions and the destination logic.

General mitigation guidance

Defensive patterns include:

  • Call file-saving helpers only after confirming the request follows the expected multipart parsing path.
  • Treat request-body objects and filenames as untrusted; do not infer that an object is an uploaded file from properties alone.
  • Reduce filenames to their basename or validate them against a strict allowlist before using them in filesystem operations.
  • Construct destinations within a fixed, controlled directory and verify that resolved paths remain inside it.
  • Preserve upload hooks and enforce file count and size limits for every accepted upload path.
  • Run the service with least-privilege filesystem permissions to limit the consequences of unintended writes.

How teams detect issues like this

  • Review code paths that call saveRequestFiles when attachFieldsToBody is enabled, especially if they accept JSON requests or JSON-typed multipart fields.
  • Search for downstream filesystem operations that use returned upload filenames without basename reduction, allowlist validation, or resolved-path containment checks.
  • Use static analysis or code review rules to flag file classification based only on attacker-controlled properties and path construction from untrusted filenames.
  • Enforce request-type policies and upload validation checks consistently across routes and parsing paths.

Sources

SourceLink
cna.openjsf.orgcna.openjsf.org/security-advisories.html
github.comgithub.com/fastify/fastify-multipart/security/advisories/GHSA-gmhr-r4mc-w935

Frequently asked

questions

The described request can be sent by an unauthenticated client to a reachable endpoint that uses the affected configuration and helper. A path traversal write also depends on the application using the returned filename as a destination.

Not necessarily. The vulnerability description indicates that an unauthenticated client can submit the forged object; endpoint reachability and application behavior determine practical exposure.

Only process files from the expected multipart parsing path, and reduce or strictly validate filenames before using them in filesystem operations. Keep resolved destinations within a fixed upload directory.

Treat request data and filenames as untrusted, validate upload types and limits consistently, and review code for filesystem paths built from user-controlled values.

Find out what's already
exploitable in your codebase.