Skip to content

Update dependency form-data to v4 [SECURITY]#11456

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

Update dependency form-data to v4 [SECURITY]#11456
renovate[bot] wants to merge 1 commit intomasterfrom
renovate/npm-form-data-vulnerability

Conversation

@renovate
Copy link
Copy Markdown
Contributor

@renovate renovate Bot commented Jul 22, 2025

This PR contains the following updates:

Package Change Age Confidence
form-data ^3.0.0^4.0.0 age confidence

form-data uses unsafe random function in form-data for choosing boundary

CVE-2025-7783 / GHSA-fjxv-7rqg-78g4

More information

Details

Summary

form-data uses Math.random() to select a boundary value for multipart form-encoded data. This can lead to a security issue if an attacker:

  1. can observe other values produced by Math.random in the target application, and
  2. can control one field of a request made using form-data

Because the values of Math.random() are pseudo-random and predictable (see: https://blog.securityevaluators.com/hacking-the-javascript-lottery-80cc437e3b7f), an attacker who can observe a few sequential values can determine the state of the PRNG and predict future values, includes those used to generate form-data's boundary value. The allows the attacker to craft a value that contains a boundary value, allowing them to inject additional parameters into the request.

This is largely the same vulnerability as was recently found in undici by parrot409 -- I'm not affiliated with that researcher but want to give credit where credit is due! My PoC is largely based on their work.

Details

The culprit is this line here: https://github.com/form-data/form-data/blob/426ba9ac440f95d1998dac9a5cd8d738043b048f/lib/form_data.js#L347

An attacker who is able to predict the output of Math.random() can predict this boundary value, and craft a payload that contains the boundary value, followed by another, fully attacker-controlled field. This is roughly equivalent to any sort of improper escaping vulnerability, with the caveat that the attacker must find a way to observe other Math.random() values generated by the application to solve for the state of the PRNG. However, Math.random() is used in all sorts of places that might be visible to an attacker (including by form-data itself, if the attacker can arrange for the vulnerable application to make a request to an attacker-controlled server using form-data, such as a user-controlled webhook -- the attacker could observe the boundary values from those requests to observe the Math.random() outputs). A common example would be a x-request-id header added by the server. These sorts of headers are often used for distributed tracing, to correlate errors across the frontend and backend. Math.random() is a fine place to get these sorts of IDs (in fact, opentelemetry uses Math.random for this purpose)

PoC

PoC here: https://github.com/benweissmann/CVE-2025-7783-poc

Instructions are in that repo. It's based on the PoC from https://hackerone.com/reports/2913312 but simplified somewhat; the vulnerable application has a more direct side-channel from which to observe Math.random() values (a separate endpoint that happens to include a randomly-generated request ID).

Impact

For an application to be vulnerable, it must:

  • Use form-data to send data including user-controlled data to some other system. The attacker must be able to do something malicious by adding extra parameters (that were not intended to be user-controlled) to this request. Depending on the target system's handling of repeated parameters, the attacker might be able to overwrite values in addition to appending values (some multipart form handlers deal with repeats by overwriting values instead of representing them as an array)
  • Reveal values of Math.random(). It's easiest if the attacker can observe multiple sequential values, but more complex math could recover the PRNG state to some degree of confidence with non-sequential values.

If an application is vulnerable, this allows an attacker to make arbitrary requests to internal systems.

Severity

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

References

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


form-data uses unsafe random function in form-data for choosing boundary

CVE-2025-7783 / GHSA-fjxv-7rqg-78g4

More information

Details

Summary

form-data uses Math.random() to select a boundary value for multipart form-encoded data. This can lead to a security issue if an attacker:

  1. can observe other values produced by Math.random in the target application, and
  2. can control one field of a request made using form-data

Because the values of Math.random() are pseudo-random and predictable (see: https://blog.securityevaluators.com/hacking-the-javascript-lottery-80cc437e3b7f), an attacker who can observe a few sequential values can determine the state of the PRNG and predict future values, includes those used to generate form-data's boundary value. The allows the attacker to craft a value that contains a boundary value, allowing them to inject additional parameters into the request.

This is largely the same vulnerability as was recently found in undici by parrot409 -- I'm not affiliated with that researcher but want to give credit where credit is due! My PoC is largely based on their work.

Details

The culprit is this line here: https://github.com/form-data/form-data/blob/426ba9ac440f95d1998dac9a5cd8d738043b048f/lib/form_data.js#L347

An attacker who is able to predict the output of Math.random() can predict this boundary value, and craft a payload that contains the boundary value, followed by another, fully attacker-controlled field. This is roughly equivalent to any sort of improper escaping vulnerability, with the caveat that the attacker must find a way to observe other Math.random() values generated by the application to solve for the state of the PRNG. However, Math.random() is used in all sorts of places that might be visible to an attacker (including by form-data itself, if the attacker can arrange for the vulnerable application to make a request to an attacker-controlled server using form-data, such as a user-controlled webhook -- the attacker could observe the boundary values from those requests to observe the Math.random() outputs). A common example would be a x-request-id header added by the server. These sorts of headers are often used for distributed tracing, to correlate errors across the frontend and backend. Math.random() is a fine place to get these sorts of IDs (in fact, opentelemetry uses Math.random for this purpose)

PoC

PoC here: https://github.com/benweissmann/CVE-2025-7783-poc

Instructions are in that repo. It's based on the PoC from https://hackerone.com/reports/2913312 but simplified somewhat; the vulnerable application has a more direct side-channel from which to observe Math.random() values (a separate endpoint that happens to include a randomly-generated request ID).

Impact

For an application to be vulnerable, it must:

  • Use form-data to send data including user-controlled data to some other system. The attacker must be able to do something malicious by adding extra parameters (that were not intended to be user-controlled) to this request. Depending on the target system's handling of repeated parameters, the attacker might be able to overwrite values in addition to appending values (some multipart form handlers deal with repeats by overwriting values instead of representing them as an array)
  • Reveal values of Math.random(). It's easiest if the attacker can observe multiple sequential values, but more complex math could recover the PRNG state to some degree of confidence with non-sequential values.

If an application is vulnerable, this allows an attacker to make arbitrary requests to internal systems.

Severity

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

References

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


Release Notes

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

v4.0.4

Compare Source

Commits
  • [meta] add auto-changelog 811f682
  • [Tests] handle predict-v8-randomness failures in node < 17 and node > 23 1d11a76
  • [Fix] Switch to using crypto random for boundary values 3d17230
  • [Tests] fix linting errors 5e34080
  • [meta] actually ensure the readme backup isn’t published 316c82b
  • [Dev Deps] update @ljharb/eslint-config 58c25d7
  • [meta] fix readme capitalization 2300ca1

v4.0.3

Compare Source

Fixed
  • [Fix] append: avoid a crash on nullish values #577
Commits
  • [eslint] use a shared config 426ba9a
  • [eslint] fix some spacing issues 2094191
  • [Refactor] use hasown 81ab41b
  • [Fix] validate boundary type in setBoundary() method 8d8e469
  • [Tests] add tests to check the behavior of getBoundary with non-strings 837b8a1
  • [Dev Deps] remove unused deps 870e4e6
  • [meta] remove local commit hooks e6e83cc
  • [Dev Deps] update eslint 4066fd6
  • [meta] fix scripts to use prepublishOnly c4bbb13

v4.0.2

Compare Source

Merged
  • [Fix] set Symbol.toStringTag when available #573
  • [Fix] set Symbol.toStringTag when available #573
  • fix (npmignore): ignore temporary build files #532
  • fix (npmignore): ignore temporary build files #532
Fixed
  • [Fix] set Symbol.toStringTag when available (#​573) #396
  • [Fix] set Symbol.toStringTag when available (#​573) #396
  • [Fix] set Symbol.toStringTag when available #396
Commits
  • Merge tags v2.5.3 and v3.0.3 92613b9
  • [Tests] migrate from travis to GHA 806eda7
  • [Tests] migrate from travis to GHA 8fdb3bc
  • [Refactor] use Object.prototype.hasOwnProperty.call 7fecefe
  • [Refactor] use Object.prototype.hasOwnProperty.call 6e682d4
  • [Refactor] use Object.prototype.hasOwnProperty.call df3c1e6
  • [Dev Deps] update @types/node, browserify, coveralls, cross-spawn, eslint, formidable, in-publish, pkgfiles, pre-commit, puppeteer, request, tape, typescript 8261fcb
  • [Dev Deps] update @types/node, browserify, coveralls, cross-spawn, eslint, formidable, in-publish, pkgfiles, pre-commit, puppeteer, request, tape, typescript fb66cb7
  • [Dev Deps] update @types/node, browserify, coveralls, eslint, formidable, in-publish, phantomjs-prebuilt, pkgfiles, pre-commit, request, tape, typescript 819f6b7
  • [eslint] clean up ignores 3217b3d
  • [eslint] clean up ignores 3a9d480
  • [Fix] Buffer.from and Buffer.alloc require node 4+ c499f76
  • Only apps should have lockfiles b82f590
  • Only apps should have lockfiles b170ee2
  • [Deps] update combined-stream, mime-types 6b1ca1d
  • [Dev Deps] pin request which via tough-cookie ^2.4 depends on psl e5df7f2
  • [Deps] update mime-types 5a5bafe
  • Bumped version 2.5.3 9457283
  • [Dev Deps] pin request which via tough-cookie ^2.4 depends on psl 9dbe192
  • Merge tags v2.5.2 and v3.0.2 d53265d
  • Bumped version 2.5.2 7020dd4
  • [Dev Deps] downgrade cross-spawn 3fc1a9b
  • fix: move util.isArray to Array.isArray (#​564) edb555a
  • fix: move util.isArray to Array.isArray (#​564) 10418d1

v4.0.1

Compare Source

Commits
  • [Tests] migrate from travis to GHA 757b4e3
  • [eslint] clean up ignores e8f0d80
  • fix (npmignore): ignore temporary build files 335ad19
  • fix: move util.isArray to Array.isArray 440d3be

v4.0.0

Compare Source

  • Merge pull request #​382 from wxt2005/custom-stream 8968e01
  • Fix typo e705c0a
  • Merge branch 'master' of github.com:form-data/form-data into custom-stream b7b7dee
  • Update README for custom stream behavior 6dd8624
  • Handle custom stream a3e191d

v3.0.4

Compare Source

Fixed
  • [Fix] append: avoid a crash on nullish values #577
Commits
  • [eslint] update linting config f5e7eb0
  • [meta] add auto-changelog d2eb290
  • [Tests] handle predict-v8-randomness failures in node < 17 and node > 23 e8c574c
  • [Fix] Switch to using crypto random for boundary values c6ced61
  • [Refactor] use hasown 1a78b5d
  • [Fix] validate boundary type in setBoundary() method 70bbaa0
  • [Tests] add tests to check the behavior of getBoundary with non-strings b22a64e
  • [meta] actually ensure the readme backup isn’t published 0150851
  • [meta] remove local commit hooks fc42bb9
  • [Dev Deps] remove unused deps a14d09e
  • [meta] fix scripts to use prepublishOnly 11d9f73
  • [meta] fix readme capitalization fc38b48

v3.0.3

Compare Source

v3.0.2

Compare Source

Fixes
  • npmignore temporary build files (#​532)
  • move util.isArray to Array.isArray (#​564)
Tests
  • migrate from travis to GHA

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • ""
  • 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 03:15
@renovate renovate Bot added the type:security Impacts security label Jul 22, 2025
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 7ac9da2 to 1d5ffac Compare August 4, 2025 10:32
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Aug 4, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 1d5ffac to 1019294 Compare August 5, 2025 08:45
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 1019294 to 68b779d Compare August 12, 2025 10:00
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 2 times, most recently from ac0e2a2 to aac4f56 Compare August 21, 2025 12:47
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 4b43047 to a81eb80 Compare August 28, 2025 14:41
@Mc01 Mc01 added deps Is about dependencies stale Is left alone for very long time labels Sep 10, 2025
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from a81eb80 to 8a3b668 Compare September 15, 2025 10:25
@github-actions github-actions Bot removed the stale Is left alone for very long time label Sep 15, 2025
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 5 times, most recently from 679f6dd to dcb0805 Compare September 18, 2025 11:53
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 537213b to a166c11 Compare September 25, 2025 11:13
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 2b0c93e to 9a0d965 Compare October 2, 2025 15:24
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch 3 times, most recently from 0103709 to 12243a1 Compare October 20, 2025 14:00
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 12243a1 to df4a51a Compare October 27, 2025 13:47
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from df4a51a to 22047dd Compare December 9, 2025 19:20
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 22047dd to 541c499 Compare December 9, 2025 19:40
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 541c499 to 336ee5b Compare December 9, 2025 20:17
@renovate renovate Bot changed the title fix(deps): update dependency form-data to v4 [security] Update dependency form-data to v4 [SECURITY] Dec 9, 2025
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 336ee5b to e2973a1 Compare December 16, 2025 12:56
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from e2973a1 to 747f869 Compare January 5, 2026 11:01
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@renovate renovate Bot force-pushed the renovate/npm-form-data-vulnerability branch from 747f869 to f1bb797 Compare April 7, 2026 13:21
@renovate renovate Bot changed the title Update dependency form-data to v4 [SECURITY] fix(deps): update dependency form-data to v4 [security] Apr 7, 2026
@renovate renovate Bot changed the title fix(deps): update dependency form-data to v4 [security] Update dependency form-data to v4 [SECURITY] Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Is about dependencies type:security Impacts security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant