CVE-2026-12143: form-data: CRLF injection in form-data via unescaped multipart field names and filenames

Published Jun 12, 2026
·
Updated

Summary

form-data builds multipart/form-data request bodies. Through v4.0.5, the field name passed to FormData#append and the filename option are concatenated directly into the Content-Disposition header with no escaping of CR (\r), LF (\n), or ". An application that uses untrusted input as a field name or filename therefore lets an attacker terminate the header line and either inject additional headers or smuggle whole additional multipart parts into the request the application forwards to a backend.

This is CWE-93 (CRLF injection). It is a divergence from how browsers and the WHATWG HTML spec serialize form-data (they escape these characters), so the fix is to match that behavior. Severity is conditional: it depends on the consuming application passing attacker-controlled data as a field name or filename. Applications that only use fixed/trusted field names are not affected.

Details

In lib/formdata.js, multiPartHeader builds the part header as:

javascript 'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || [])

and getContentDisposition builds filename="' + filename + '"'. Neither escapes control characters, so a \r\n in field/filename ends the header line. The same applies to ", which can break out of the quoted parameter.

Proof of concept

javascript const FormData = require('form-data'); const form = new FormData(); form.append('email"\r\nX-Injected: true\r\nfake="', 'user@example.com'); console.log(form.getBuffer().toString());

Before the fix this emits an injected X-Injected: true header line. A field name that also includes --<boundary> sequences can introduce additional parts (e.g. an extra name="isadmin" field), which a downstream parser accepts as legitimate.

Impact

For an application that uses untrusted field names/filenames:

- Field injection / override (integrity). Inject or override fields the backend trusts (e.g. isadmin, role) — the primary demonstrated impact. - Header injection into the generated multipart part.

Claims of guaranteed privilege escalation, authentication bypass, high confidentiality impact, and availability impact are application-dependent downstream consequences, not properties of form-data itself, and are not demonstrated by the PoC.

Severity

The demonstrated, library-attributable impact is integrity (field/header injection); there is no demonstrated confidentiality disclosure or availability impact in form-data itself, and exploitation requires the consuming app to feed untrusted data into field names/filenames. A Moderate (≈5.3, I:L) rating is also defensible given that precondition.

Patch

Fixed in 4.0.6, 3.0.5, and 2.5.6. Users on older 0.x/1.x/2.x releases should upgrade to 2.5.6 or later.

The fix escapes \r, \n, and " as %0D, %0A, and %22 in field names and filenames, matching the WHATWG HTML multipart/form-data encoding algorithm that browsers implement. This neutralizes the injection while leaving ordinary field names (including name[0], dotted, and unicode names) unchanged.

Workaround

Until upgrading, validate or reject field names/filenames that contain control characters before calling append:

javascript if (/[\r\n]/.test(field)) { throw new Error('invalid field name'); }

Credit

Reported by yueyueL.

Other sources

form-data does not escape CR/LF/quote in multipart field names and filenames (CRLF injection)

— Microsoft

form-data is a library for creating readable multipart/form-data streams. In versions through 4.0.5, the field argument to FormData#append and the filename option are concatenated verbatim into the Content-Disposition header without escaping carriage return (CR), line feed (LF), or double-quote (") characters. An application that passes attacker-controlled data as a field name or filename (for example, an API gateway that turns JSON object keys into multipart field names) allows the attacker to terminate the header line and inject additional headers, or to smuggle entire additional multipart parts, into the request the application forwards to a backend. This can let the attacker add or override form fields (e.g. set isadmin=true) seen by the downstream parser. This is an instance of CWE-93 (CRLF injection). The fix escapes CR, LF, and " as %0D, %0A, and %22 in field names and filenames, matching the serialization browsers use per the WHATWG HTML multipart/form-data encoding algorithm. Exploitation requires the consuming application to use untrusted input as a field name or filename; applications that use only fixed/trusted field names are not affected. Fixed in 2.5.6, 3.0.5, and 4.0.6.

— Red Hat

form-data through 4.0.6 contains a CRLF injection vulnerability in multiPartHeader that allows attackers to inject multipart part headers via unescaped options.contentType and options.header values. Attackers who influence these values can embed CRLF sequences and the boundary to smuggle extra form fields into multipart requests sent to receiving servers.

— OSV

Affected Software

14 affected componentsFixes available
npm/form-data<2.5.6, <3.0.5, <4.0.6
npm/form-data>=4.0.0<4.0.6
4.0.6
npm/form-data>=3.0.0<3.0.5
3.0.5
npm/form-data<2.5.6
2.5.6
IBM SevOne Network Performance Management<=7.0.0 - 8.2.2
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*
ubuntu/node-form-data*

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/form-data to a version that resolves this vulnerability.

    Fixed in 4.0.6
  2. Upgrade

    Upgrade npm/form-data to a version that resolves this vulnerability.

    Fixed in 3.0.5
  3. Upgrade

    Upgrade npm/form-data to a version that resolves this vulnerability.

    Fixed in 2.5.6
  4. Compensating control

    Until upgrading, validate or reject field names and filenames containing control characters before calling FormData#append; the material shows rejecting field names containing CR or LF.

Event History

Jun 12, 2026
CVE Published
via MITRE·06:01 PM
Data Sourced
via MITRE·06:01 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·07:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·07:16 PM
DescriptionSeverityWeakness
Event
via NVD·07:16 PM
Jun 15, 2026
Advisory Published
via GitHub·05:26 PM
Data Sourced
via GitHub·05:26 PM
DescriptionSeverityWeaknessAffected Software
Jun 17, 2026
Data Sourced
via Microsoft·08:02 AM
DescriptionSeverityWeakness
Jun 30, 2026
Updated
via NVD·03:17 AM
SeverityWeakness
Aug 5, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software
Aug 24, 2026
News Published
via The Hacker News·02:32 PM
Sep 1, 2026
Updated
via IBM·12:00 AM
Affected Software
Sep 8, 2026
Updated
via IBM·12:00 AM
Affected Software
Sep 11, 2026
Updated
via NVD·01:17 PM
SeverityWeakness
Sep 26, 2026
Updated
via IBM·12:00 AM
Affected Software
Sep 28, 2026
Updated
via IBM·12:00 AM
Affected Software
Nov 24, 2026
Data Sourced
via OSV·02:55 PM
Affected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is the severity of CVE-2026-12143?

The severity of CVE-2026-12143 is high with a score of 8.7.

2

How do I fix CVE-2026-12143?

To fix CVE-2026-12143, ensure you update to a version of the `form-data` package that escapes CR, LF, and quote characters in multipart field names and filenames.

3

What type of injection does CVE-2026-12143 involve?

CVE-2026-12143 involves CRLF injection, which can allow an attacker to manipulate HTTP headers.

4

Which software is affected by CVE-2026-12143?

CVE-2026-12143 affects the npm package `form-data` versions through 4.0.5.

5

What are the potential impacts of CVE-2026-12143?

The potential impacts of CVE-2026-12143 include denial of service and header injection attacks due to improper handling of input.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203