CVE-2025-7783 PoC and fix: the form-data boundary flaw behind the critical npm audit alert

CVE-2025-7783 is a critical-rated (CVSS 9.4) flaw in the npm package form-data before 2.5.4, 3.0.4 and 4.0.4: it picked multipart boundaries with Math.random(), which can be predicted. An attacker who can observe other random values from your server and control one field of a multipart request your server sends can inject extra fields into it. A proof of concept is public. Update to 4.0.6, 3.0.5 or 2.5.6.

The team behind Keybrum's attacksUpdated 8 min read
CVE-2025-7783critical · CVSS 9.4
Component
form-data (multipart boundary generation) (form-data)
Affected
form-data before 2.5.4, 3.0.0 to 3.0.3 and 4.0.0 to 4.0.3, in Node.js code that sends multipart requests
Fixed in
2.5.4, 3.0.4, 4.0.4. Current releases: 4.0.6, 3.0.5, 2.5.6
Published
July 18, 2025
Does it reach a version you install? Drop your lockfile in the dependency checker: it reads every package, this one included.

In short

  • form-data builds the multipart requests your Node.js server sends to other systems. Before 2.5.4, 3.0.4 and 4.0.4 it chose the separator between fields with Math.random(), and those values can be predicted.
  • The attack needs two things at once: a way to see other Math.random() values from your server, and control over one field of a multipart request your server sends. Many apps flagged by npm audit meet neither. Update anyway: it is one command.
  • Most projects get form-data through axios. axios 1.11.0 and later require the fixed version, but an older lockfile can still hold 4.0.0 to 4.0.3.
  • The deprecated request package pins form-data to 2.3.x, which no update can fix. Replace request, or force the version with an override.
  • The current releases, 4.0.6, 3.0.5 and 2.5.6, also fix a second flaw from June 2026, CVE-2026-12143. Aim for those, not for the first fixed versions.
On this page

What CVE-2025-7783 is, in plain words

When a server uploads a file or posts a form to another system, it often uses the multipart format: every field travels in its own part, and the parts are separated by a line of text called the boundary. The receiving system splits the request wherever it sees the boundary. So the boundary must be a string that cannot appear inside the data, and that nobody outside can guess.

The npm package form-data builds these requests in Node.js. It created the boundary with Math.random(). That function is fine for shuffling a list and wrong for anything an attacker must not predict: the advisory recalls that someone who observes a few consecutive values can work out the generator's internal state and compute the next ones.

An attacker who knows the next boundary can write it inside a value they control, followed by a field of their own. Your server sends one request; the system on the other end reads an extra field that your code never added. The advisory compares it to any missing-escaping bug, and the CVE record names the result HTTP parameter pollution.

What a stranger can do, and what they need first

The advisory sets two conditions, and both must hold.

ConditionWhat it looks like in a real app
The attacker can observe other values produced by Math.random() in your serverA request id in a response header, a file name, an invite code or any other value built with Math.random(). Or a feature that sends multipart requests to an address the user chooses, such as a webhook: the attacker then reads the boundaries directly
The attacker controls one field of a multipart request your server sends with form-dataA name, a comment or an uploaded file that your server forwards to a storage service, an email or payment API, or an internal service
From GitHub advisory GHSA-fjxv-7rqg-78g4.

When both hold, the attacker adds fields to a request that the receiving system trusts because it comes from your server: a different recipient, a different destination folder, a flag your code would never set. What that is worth depends on the system on the other end.

Severity, proof of concept and exploitation status

The CVE record scores it 9.4, critical, in CVSS 4.0, with the vector AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:H/VA:N/SC:H/SI:H/SA:N. Read the second term: attack complexity is high. The score describes the worst case, an app that meets both conditions and forwards data to a system that matters. It does not say every project with form-data in its lockfile can be attacked.

Who is affected

Your projectExposedWhy
Node.js server code with form-data before 2.5.4, 3.0.0 to 3.0.3 or 4.0.0 to 4.0.3, meeting both conditions aboveYesThis is the case the advisory describes
The same versions, but no user-controlled value ever goes into a multipart requestNot in practiceThere is nothing to inject into. Update anyway: code changes
The same versions, used only through axios for JSON requestsNot in practiceNo multipart request is built, so no boundary is generated
Code that runs only in the browserNoIn a browser build the package hands over to the browser's own FormData
form-data 2.5.4, 3.0.4, 4.0.4 or laterNoThe boundary comes from Node's crypto module

Most projects never installed form-data on purpose. It arrives as a dependency of axios, and through older tools such as the deprecated request package. That is why the alert shows up in apps whose authors have never heard of it.

GitHub first published a separate advisory against axios itself (CVE-2025-54371), then withdrew it on 24 July 2025, because axios users can move to a patched form-data without upgrading axios. axios 1.10.0 accepts any form-data 4.x from 4.0.0; axios 1.11.0 and later require 4.0.4 or more.

Apps built with AI tools

Two things in generated code meet this advisory. If your coding agent added axios, form-data is in the lockfile. If it also wrote Math.random().toString(36) for quick ids, check where those ids go. An id of that kind that ends up in a response header, a URL or a file name is exactly the observable value the advisory talks about. It is also a bug of its own when the id is supposed to be secret, such as a reset token or an invite code. Our guide on auditing AI-generated code shows how to make your agent look for both.

How to check your own project

bash
# Every copy of form-data in the project, and who brings it in
npm ls form-data
pnpm why form-data
yarn why form-data

# Known advisories in production dependencies
npm audit --omit=dev

# Places where your server code uses Math.random()
grep -rn "Math.random()" --include=*.ts --include=*.js --exclude-dir=node_modules .
A project can hold several copies at different versions. Every copy below 2.5.4, from 3.0.0 to 3.0.3 or from 4.0.0 to 4.0.3 is affected.

Then answer the two conditions for your own code. Does any route forward user input or an uploaded file to another system as multipart? Does anything built with Math.random() leave the server? If both answers are yes, treat this as urgent.

Keybrum does not test CVE-2025-7783. The flaw lives in a server-side dependency that cannot be seen from outside, and proving it would mean forging requests to a third system. For this kind of flaw a dependency scanner such as npm audit or Dependabot is the right tool. A live attack is the right tool for what scanners cannot see: SAST and DAST compared explains where each one stops.

How to fix CVE-2025-7783

Update form-data. The fix replaces Math.random() with random bytes from Node's crypto module. The first fixed versions are 4.0.4, 3.0.4 and 2.5.4, published on 17 July 2025. The current ones are 4.0.6, 3.0.5 and 2.5.6, published on 12 June 2026, which also fix CVE-2026-12143, a CRLF injection through unescaped field names and file names.

bash
# Move every 4.x copy to the latest 4.0.x its parent allows
npm update form-data

# axios 1.11.0 and later require a fixed form-data
npm install axios@latest

# Confirm: no copy below 4.0.6, 3.0.5 or 2.5.6 should remain
npm ls form-data
Commit the lockfile and redeploy. The fix only counts once production runs it.

When a copy will not update

npm update stays inside the range each parent package asks for. The deprecated request package asks for form-data 2.3.x, and no 2.3 release has the fix. Replace request if it is your own dependency: it has been deprecated for years. If it comes from a package you cannot change yet, force the version and test the code paths that upload files.

json
{
  "overrides": {
    "request": {
      "form-data": "2.5.6"
    }
  }
}
npm reads overrides from package.json. pnpm uses pnpm.overrides, Yarn uses resolutions. Run the install again, then npm ls form-data.

What to do after updating

  1. 1

    Stop using Math.random() for anything that must not be guessed

    Request ids, tokens, invite codes, file names for private uploads: use crypto.randomUUID() or crypto.randomBytes(). This removes the first condition of the advisory for every library, not only this one. The same kind of flaw was found in undici before form-data.

  2. 2

    Validate what you forward

    A value from a user should not travel untouched into a request your server signs with its own credentials. Check its type and length, and send only the fields the other system needs.

  3. 3

    Turn on automatic alerts

    Dependabot, Renovate or a scheduled npm audit in CI catch the next one without anyone remembering to look. Review what your agent installs too: slopsquatting is the supply chain risk specific to AI-written code.

  4. 4

    Check the rest of the app

    A clean npm audit says your dependencies have no known advisory. It says nothing about who can read your database. The vibe coding security checklist covers that side.

Timeline

DateEvent
17 July 2025form-data 4.0.4, 3.0.4 and 2.5.4 published with the fix
18 July 2025CVE-2025-7783 reserved and published
21 July 2025Advisory GHSA-fjxv-7rqg-78g4 added to the GitHub Advisory Database, rated critical
22 July 2025CISA's assessment: proof of concept available, not automatable, total technical impact
24 July 2025GitHub withdraws the separate advisory against axios (CVE-2025-54371)
12 June 2026form-data 4.0.6, 3.0.5 and 2.5.6 published, fixing CVE-2026-12143
13 November 2026Still absent from CISA's Known Exploited Vulnerabilities catalog

Questions

Is there a public PoC for CVE-2025-7783?

Yes. The researcher who reported the flaw published a proof of concept, and the GitHub advisory links to it. CISA's assessment of 22 July 2025 recorded it. This page does not reproduce it: check which form-data versions your project holds with npm ls form-data.

Is axios affected by CVE-2025-7783?

axios depends on form-data, so a project with axios can hold a vulnerable copy. GitHub's separate advisory against axios (CVE-2025-54371) was withdrawn on 24 July 2025, because you can update form-data without upgrading axios. axios 1.11.0 and later require form-data 4.0.4 or more.

npm audit shows CVE-2025-7783 as critical. Is my app really at risk?

Only if two conditions hold: an attacker can observe Math.random() values from your server, and can control one field of a multipart request your server sends with form-data. Many flagged projects meet neither. The update is still worth doing, because it takes one command and code changes over time.

Which form-data version fixes it?

4.0.4, 3.0.4 and 2.5.4 are the first fixed versions. Install 4.0.6, 3.0.5 or 2.5.6 instead: they also fix CVE-2026-12143, a second flaw published in June 2026.

Is form-data in the browser affected?

No. In a browser build, the package hands over to the browser's built-in FormData, which creates its own boundaries. The flaw concerns Node.js code that builds multipart requests on the server.

Why does npm audit fix not remove the alert?

A parent package probably asks for a version range with no fixed release. The deprecated request package asks for form-data 2.3.x, for example. Replace the parent package, or force a fixed version with overrides in package.json and test your uploads.

Sources

  1. 1.GHSA-fjxv-7rqg-78g4: form-data uses unsafe random function for choosing boundary, form-data on GitHub
  2. 2.CVE-2025-7783, NIST National Vulnerability Database
  3. 3.CVE-2025-7783, CVE Program
  4. 4.GitHub advisory database: GHSA-fjxv-7rqg-78g4, GitHub
  5. 5.Switch to using crypto random for boundary values (fix commit), form-data on GitHub
  6. 6.GHSA-rm8p-cx58-hcvx: withdrawn advisory, Axios has transitive critical vulnerability via form-data, GitHub
  7. 7.GHSA-hmw2-7cc7-3qxx (CVE-2026-12143): CRLF injection via unescaped multipart field names and filenames, GitHub
  8. 8.form-data versions, npm
  9. 9.request (deprecated): dependencies, npm
  10. 10.package.json: overrides, npm Docs
  11. 11.Known Exploited Vulnerabilities Catalog, CISA
  12. 12.EPSS score for CVE-2025-7783, FIRST

Your app is public. So are its mistakes.

Check what any attacker can already see in it, free, in ten seconds. The full attack, with proof and fixes: €49 once, or €29 a month on a plan.

or continue with Google or GitHub