Skip to content

chore(deps): update dependency form-data to v4.0.6 [security]#1332

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-form-data-vulnerability
Open

chore(deps): update dependency form-data to v4.0.6 [security]#1332
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-form-data-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
form-data 4.0.54.0.6 age confidence

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

CVE-2026-12143 / GHSA-hmw2-7cc7-3qxx

More information

Details

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.

Severity

  • CVSS Score: 8.7 / 10 (High)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

form-data/form-data (form-data)

v4.0.6

Compare Source

Commits
  • [Fix] escape CR, LF, and " in field names and filenames 8dff42c
  • [Dev Deps] update @ljharb/eslint-config, auto-changelog, tape f31d21e
  • [Deps] update hasown, mime-types 92ae0eb
  • [Dev Deps] update js-randomness-predictor 67b0f65

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
renovate Bot requested a review from a team as a code owner July 22, 2025 06:23
@sonarqubecloud

Copy link
Copy Markdown

@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 207d433 to 0c8a718 Compare August 21, 2025 07:12
@ArneD
ArneD force-pushed the main branch 2 times, most recently from 0b3d073 to cd4d58d Compare August 22, 2025 11:10
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 2bcd801 to 83e2578 Compare August 25, 2025 11:49
@sonarqubecloud

Copy link
Copy Markdown

@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 9687bb2 to 43a3549 Compare November 21, 2025 09:41
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 5 times, most recently from ce5803d to e878931 Compare November 27, 2025 10:43
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from e878931 to 43bfdea Compare December 4, 2025 13:36
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2025

Copy link
Copy Markdown

@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 4 times, most recently from 2e89932 to 63d2006 Compare January 8, 2026 10:22
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 63d2006 to ec41157 Compare February 3, 2026 12:03
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 50b1560 to 23602f3 Compare February 17, 2026 14:24
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 6252edd to a6279eb Compare May 4, 2026 09:48
@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from a6279eb to 8c5ebdb Compare May 12, 2026 12:36
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 9 times, most recently from e1f9d5c to 8617442 Compare May 19, 2026 13:02
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from ad54025 to 7cf5b47 Compare May 20, 2026 12:40
@sonarqubecloud

Copy link
Copy Markdown

@renovate renovate Bot changed the title chore(deps): update dependency form-data to v4.0.4 [security] chore(deps): update dependency form-data to v4.0.4 [security] - autoclosed Jun 11, 2026
@renovate renovate Bot closed this Jun 11, 2026
@renovate renovate Bot changed the title chore(deps): update dependency form-data to v4.0.4 [security] - autoclosed chore(deps): update dependency form-data to v4.0.6 [security] Jun 16, 2026
@renovate renovate Bot reopened this Jun 16, 2026
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 9a5fcc3 to c677464 Compare June 22, 2026 12:24
@sonarqubecloud

Copy link
Copy Markdown

@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 2 times, most recently from 02bd5f2 to ccebbf2 Compare July 27, 2026 07:35
@renovate
renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from ccebbf2 to 67b3b5a Compare July 27, 2026 10:04
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants