Introduction
A type confusion bug in @fastify/multipart lets an unauthenticated client hand the saveRequestFiles helper a forged object that it processes as a genuine upload, skipping upload hooks, file limits, and filename sanitization along the way. For applications that use the returned filename as a write destination, as the project README example does, a single JSON request can become an arbitrary relative-path file write.
Fastify is a low-overhead web framework for Node.js, maintained by a global team and hosted as an OpenJS Foundation At Large project, and @fastify/multipart is its official plugin for handling multipart uploads. Around the Fastify 5 release, the OpenJS Foundation reported 22 maintainers, 400 active contributors, 296 officially recognized plugins, and 7.8 million downloads in August 2024. That footprint makes a flaw in the official upload plugin relevant to a broad set of Node.js API services that accept file uploads.
Technical information
Root cause
The issue sits in the interaction between the attachFieldsToBody option and the saveRequestFiles() helper. When attachFieldsToBody is set to true or 'keyValues', parsed multipart fields and file wrappers are attached to request.body. Before the fix, saveRequestFiles() passed whatever was in request.body to the internal filesFromFields() function, without checking how the request had actually arrived:
parts = this.body ? filesFromFields.call(this, this.body) : []
filesFromFields() then decided whether each entry was a file using duck typing. Any object with a truthy file property (and _buf) was accepted as an uploaded file:
if (!field.file) { continue }
The problem is that request.body is attacker controlled and is not guaranteed to come from the multipart parser. It can be:
- A parsed
application/jsonpayload, sent to a route that callssaveRequestFiles(). - A field inside a real multipart request whose content type is
application/json. In'keyValues'mode, that field is parsed into an object, so it can carryfileand_bufproperties.
The CVE description refers to a buffer property, while the published advisory and the patch name the property _buf. We follow the advisory and patch here.
Consequences of the confusion
When a forged object passes the duck typing check, the advisory describes the following behavior:
- The attacker-chosen bytes in
_bufare written to the plugin's temporary directory. - The
onFilehook is skipped. - The configured
files(count) andfileSizelimits are skipped. - The saved entry keeps the attacker's
filenameverbatim. Genuine multipart filenames are reduced to their basename, but forged ones are not.
Because the filename can contain parent directory segments, any application that uses the returned filename as a write destination will write to a relative path the attacker selects. The advisory notes that the project README example follows this pattern.
The issue is mapped to CWE 22 (improper limitation of a pathname to a restricted directory) and CWE 843 (access of a resource using an incompatible type). The CNA vector is CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N, giving 7.5 High: network reachable, low complexity, no privileges or user interaction, and high integrity impact with no confidentiality or availability impact in the scored vector. NVD has not yet published its own assessment.
Attack flow
Based on the advisory and the regression tests shipped with the fix, the attack proceeds as follows:
- Target selection. The application registers
@fastify/multipartwithattachFieldsToBody: trueorattachFieldsToBody: 'keyValues'and callssaveRequestFiles()on a route. - Forged body. Without authentication, the attacker sends either a plain JSON request or a multipart request containing a JSON-typed field. The payload contains an object with a truthy
fileproperty, a_bufholding chosen bytes, and afilenamewith parent directory segments. The regression tests use../../../../package.jsonas the forged filename. - Type confusion.
saveRequestFiles()hands the body tofilesFromFields(), which accepts the object as an uploaded file. - Unchecked write. The bytes are written to the temporary directory without passing through
onFileor the count and size limits. - Path traversal in application code. The returned entry carries the traversal filename unchanged. If the application uses it as a destination, the write lands at the attacker-chosen relative path.
The file write outside the temporary directory depends on application behavior. The advisory does not claim code execution and does not identify specific files an attacker could alter. Those outcomes should not be assumed without evidence from a particular application.
Threat context
The sources we reviewed do not establish exploitation in the wild or attribute activity to any threat actor. The CISA Known Exploited Vulnerabilities catalog returned no match for this CVE, and we found no confirmed public proof of concept or incident telemetry. That is an absence of reporting rather than evidence that exploitation has not occurred.
Patch information
The fix shipped in @fastify/multipart 10.1.9, tagged and released on 16 November 2026. Advisory GHSA-gmhr-r4mc-w935 lists 10.1.9 as the patched version for the vulnerable range >= 7.4.0, < 10.1.9. The code change is commit 3df4ba29, a "Merge commit from fork" written by Matteo Collina with Ulises Gascon as coauthor. It adds 22 lines and removes 2 in index.js, and adds a new 163-line regression test file.
The patch closes the issue with two independent layers.
Layer 1: a private brand on real file wrappers
The plugin now creates a Symbol that only its own module can reference:
const kFileField = Symbol('fileField')
When the plugin builds a file wrapper from an actual multipart part, it attaches that Symbol as a property:
Object.defineProperty(value, kFileField, { value: true, enumerable: true })
The brand has three properties:
- It cannot be forged. JSON has no way to express a Symbol key, and outside code has no reference to this Symbol, so no request body can carry the brand.
- It is enumerable on purpose. A shallow copy such as
{ ...wrapper }keeps the brand, so applications that clone or normalize wrappers before saving continue to work. A follow-up inside the same merge preserved the brand on shallow-cloned wrappers. - It does not leak.
JSON.stringifyandObject.keysignore Symbol keys, so the brand never appears in API responses.
The check in filesFromFields() changes from the property test shown earlier to a brand test:
if (!field || typeof field !== 'object' || field[kFileField] !== true) { continue }
Layer 2: only genuine multipart requests are inspected
saveRequestFiles() now checks how the request arrived before reading the body at all:
parts = (this.isMultipart() && this.body) ? filesFromFields.call(this, this.body) : []
A request sent as application/json now returns an empty file list without reaching filesFromFields().
Why both layers matter
The isMultipart() check stops the plain JSON body variant, but not the second variant: a real multipart request containing a field whose content type is application/json. In 'keyValues' mode that field is parsed into an object with file and _buf, and isMultipart() correctly returns true. The brand check is what blocks this case, and the commit's tests call this out explicitly.
Regression tests
The new tests send a forged object whose filename is ../../../../package.json and whose _buf holds attacker-chosen bytes, and verify that:
- a JSON request returns
files.length === 0with bothattachFieldsToBody: trueand'keyValues'; - a JSON-typed multipart field returns no files and leaves
req.tmpUploads.length === 0, meaning no temporary file was written; - a real multipart upload named
../../../../real-upload.txtstill saves, with its name reduced toreal-upload.txt; - a shallow-cloned real wrapper is still saved.
After the patch, saveRequestFiles() only processes files the plugin parsed itself. Those files pass through the onFile hook, the files and fileSize limits, and basename handling.
If you cannot upgrade immediately
The advisory offers a workaround: call saveRequestFiles() only after confirming the request is multipart with request.isMultipart(), and reduce each returned filename to its basename with path.basename() or validate it against an allowlist before using it as a destination. Given the analysis above, the isMultipart() check on its own does not address the JSON-typed multipart field variant, so filename validation is the part of the workaround that protects the write destination.
Affected systems and versions
- Package:
@fastify/multipart - Affected versions: 7.4.0 through 10.1.8 (
>= 7.4.0, < 10.1.9) - Fixed version: 10.1.9 and later
- Vulnerable configuration: the plugin is registered with
attachFieldsToBody: trueorattachFieldsToBody: 'keyValues', and the application callssaveRequestFiles(). - File write exposure: applications that additionally use the returned filename as a write destination, as in the project README example, are exposed to the arbitrary relative-path file write. Deployments that meet the configuration conditions but never use the filename as a path are still affected by the temporary file write and the bypass of
onFileand the count and size limits.
When scoping, search for the combination of attachFieldsToBody and saveRequestFiles in your codebase and check whether the returned filename flows into any filesystem write.
Vendor security history
The Fastify security policy treats network input, including HTTP bodies, as untrusted, routes potential vulnerabilities through a dedicated security process, has the security team handle CVE assignment, and sets an initial response target of four business days.
In 2024, OSTIF reported an Ada Logics audit of Fastify core and 26 other modules maintained by Fastify. The engagement combined manual review with targeted fuzz testing, reported five issues (one high-severity and four informational), and integrated eight fuzzers with OSS Fuzz.
This is also not the only recent multipart disclosure. On 2 November 2026 the project published a separate @fastify/multipart denial-of-service advisory, in which a malformed upload can leave delayed file consumers hanging. It affects versions from 5.3.0 to below 10.1.7 and is fixed in 10.1.7. Another advisory covers a denial of service via a temporary file leak on aborted uploads. These records show several distinct multipart disclosures, but the available sources are not sufficient to infer an overall vulnerability rate for the project.
References
- NVD entry for CVE-2026-124289
- CVE record for CVE-2026-124289
- Fastify multipart security advisory GHSA gmhr r4mc w935 (GitHub)
- Advisory data via GitHub API
- Fix commit 3df4ba29
- Fix commit data via GitHub API
- Fastify multipart releases via GitHub API
- OpenJS Foundation CNA security advisories
- EUVD entry
- CISA Known Exploited Vulnerabilities catalog
- Fastify security policy
- Fastify project site
- Fastify repository on GitHub
- OpenJS Foundation: Fastify v5 release and project growth
- OpenJS Foundation projects
- OSTIF: Fastify audit complete
- Fastify multipart advisory: denial of service via malformed upload hanging delayed file consumers
- Fastify multipart advisory: denial of service via temporary file leak on aborted upload



