CVE-2026-31808: Sindresorhus file-type infinite loop in ASF parser

CVE-2026-31808 · Severity: low · CVSS 3.1 · Published 2026-03-10

The file-type npm package, which detects file types by analyzing file signatures, contains a denial-of-service vulnerability in its ASF (WMV/WMA) file format parser. When processing specially crafted malformed files, an attacker can trigger an infinite loop that freezes the entire Node.js application with just a 55-byte payload. This impacts any application using file-type to process untrusted user-supplied files.

Technologies: file-type (npm). Vendors: npm.

Quick answers

Is CVE-2026-31808 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-31808 being exploited in the wild.
How severe is CVE-2026-31808?
Low severity, with a CVSS score of 3.1, published 10 March 2026.
Which products and versions are affected?
file-type (npm) SEMVER:introduced=13.0.0,fixed=21.3.1.
Is there a fix for CVE-2026-31808?
Yes. file-type (npm): upgrade to 21.3.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-31808 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-31808?
Check whether you run file-type (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • file-type (npm): upgrade to 21.3.1 or later
    npm install file-type@21.3.1

Technical details

The vulnerability is a CWE-835 infinite loop condition in the ASF parser component of file-type. When parsing an ASF sub-header with a size field of zero, the payload calculation results in a negative value (-24), causing tokenizer.ignore(payload) to move the read position backwards instead of forwards. This causes the parser to re-read the same malformed sub-header indefinitely, starving the Node.js event loop. The vulnerability affects versions 13.0.0 through 21.3.0 of the npm file-type package. No authentication or privileges are required; an attacker only needs to provide a crafted 55-byte input file to a vulnerable application. The issue is fixed in version 21.3.1 via commit 319abf8. Workarounds include validating input buffer sizes or running file-type detection in a separate worker thread with a timeout.

Affected products

  • Sindresorhus file-type >=13.0.0, <21.3.1

Identifiers

  • CVE-2026-31808
  • GHSA-5v7r-6r5c-r473

Timeline

  • 2026-03-10: disclosed: Vulnerability published on GitHub Advisory Database and OSV
  • 2026-03-10: patched: Fixed in version 21.3.1 with commit 319abf8

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.