---
title: "GHSA-hmw2-7cc7-3qxx: form-data: CRLF injection in form-data via unescaped multipart field names and filenames"
description: "High severity. form-data: CRLF injection in form-data via unescaped multipart field names and filenames. Affects form-data; fixed in 4.0.6."
url: https://inlinr.com/advisories/GHSA-hmw2-7cc7-3qxx
lang: en
---

[Packages](https://inlinr.com/packages) / [form-data](https://inlinr.com/packages/form-data) / [Security](https://inlinr.com/packages/form-data/security)

High Vulnerability GHSA-hmw2-7cc7-3qxx CVE-2026-12143 Published 15 Jun 2026

# form-data: CRLF injection in form-data via unescaped multipart field names and filenames

Your version 

Affected releases · [form-data](https://inlinr.com/packages/form-data)

- 4.x 4.0.0 – 4.0.5 Fixed in 4.0.6
- 3.x 3.0.0 – 3.0.4 Fixed in 3.0.5
- 2.x 2.0.0 – 2.5.5 Fixed in 2.5.6
- 1.x and older 0.0.0 – 1.0.1 No fix, no longer updated

On 4.x, the newest line:

```
npm install form-data@4.0.6
```

Every release on a timeline

4.x 

1. Affected

4.0.0 – 4.0.5  
6 releases
2. Fixed

4.0.6  
1 release, latest

3.x 

1. Affected

3.0.0 – 3.0.4  
5 releases
2. Fixed

3.0.5  
1 release

2.x 

1. Affected

2.0.0 – 2.5.5  
16 releases
2. Fixed

2.5.6  
1 release

1.x 

1. Affected

1.0.0 – 1.0.1  
2 releases

0.x 

1. Affected

0.0.0 – 0.2.0  
16 releases

48 stable releases of form-data, oldest to newest, one row per major.

## What happens

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/form_data.js`, `_multiPartHeader` builds the part header as:

```
'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

```
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="is_admin"` 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. `is_admin`, `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`:

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

Credit

Reported by [yueyueL](https://github.com/yueyueL "https://github.com/yueyueL").

## How it is exploited

Exploitable over the network, with no account and no action from a user.

- **Confidentiality**: none
- **Integrity**: high
- **Availability**: none

CVSS:3.1/​AV:N/​AC:L/​PR:N/​UI:N/​S:U/​C:N/​I:H/​A:N

## References

- [Reference](https://github.com/form-data/form-data/security/advisories/GHSA-hmw2-7cc7-3qxx "https://github.com/form-data/form-data/security/advisories/GHSA-hmw2-7cc7-3qxx")  
github.com/form-data/form-data/security/advisor…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-12143 "https://nvd.nist.gov/vuln/detail/CVE-2026-12143")  
nvd.nist.gov/vuln/detail/CVE-2026-12143
- [Fix commit](https://github.com/form-data/form-data/commit/64190db548c0179e37206858e39f27cf513e9435 "https://github.com/form-data/form-data/commit/64190db548c0179e37206858e39f27cf513e9435")  
64190db
- [Fix commit](https://github.com/form-data/form-data/commit/be3f3cf553978bac15a5182f1f3c3d2d38ccf229 "https://github.com/form-data/form-data/commit/be3f3cf553978bac15a5182f1f3c3d2d38ccf229")  
be3f3cf
- [Fix commit](https://github.com/form-data/form-data/commit/c7133499c2ee1b80c678e411244f4442bf902045 "https://github.com/form-data/form-data/commit/c7133499c2ee1b80c678e411244f4442bf902045")  
c713349
- [Package](https://github.com/form-data/form-data "https://github.com/form-data/form-data")  
github.com/form-data/form-data
- [Reference](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data "https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data")  
html.spec.whatwg.org/multipage/form-control-inf…
- [Reference](https://www.npmjs.com/package/form-data "https://www.npmjs.com/package/form-data")  
npmjs.com/package/form-data

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
