CVE-2026-31808: File type File-type Affected By Infinite Loop Vulnerability

MODERATE
Advisory Identifier: GHSA-5v7r-6r5c-r473
CVSS 5.3
CWE-835
Published
Advisory Summary

CVE-2026-31808 is a MODERATE (CVSS 5.3) file-type affected by infinite loop vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting File type libraries in the npm ecosystem. The issue involves file-type affected by infinite loop in asf parser on malformed input with zero-size sub-header. Remediation is available by upgrading affected packages to version 21.3.1.

CVE-2026-31808 at a Glance

CVE Identifier CVE-2026-31808
GHSA Identifier GHSA-5v7r-6r5c-r473
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product File type
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2026-31808

To remediate this vulnerability, upgrade all affected File type dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

file-type fixed: 21.3.1
npm install file-type@21.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls file-type

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-31808, inspect your project dependencies using npm:

npm ls file-type

Analyze the terminal output to locate any version of File type in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 21.3.1), your application is affected.

Note: The npm ls file-type command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop'), where the product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. In File type, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact A denial of service vulnerability exists in the ASF (WMV/WMA) file type detection parser. When parsing a crafted input where an ASF sub-header has a `size` field of zero, the parser enters an infinite loop. The `payload` value becomes negative (-24), causing `tokenizer.ignore(payload)` to move the read position backwards, so the same sub-header is read repeatedly forever. Any application that uses `file-type` to detect the type of untrusted/attacker-controlled input is affected. An attacker can stall the Node.js event loop with a 55-byte payload. ### Patches Fixed in version 21.3.1. Users should upgrade to >= 21.3.1. ### Workarounds Validate or limit the size of input buffers before passing them to `file-type`, or run file type detection in a worker thread with a timeout. ### References - Fix commit: 319abf871b50ba2fa221b4a7050059f1ae096f4f ### Reporter crnkovic@lokvica.com

CVE-2026-31808 Affected File type Versions

1 component(s)
Fixed Versions:
21.3.1
Product / Package Ecosystem Affected Versions Fixed Version
file-type
npm
≥ 13.0.0
< 21.3.1
21.3.1

References

Frequently Asked Questions

What is CVE-2026-31808?
CVE-2026-31808 is a security vulnerability in File type involving file-type affected by infinite loop in ASF parser on malformed input with zero-size sub-header under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which File type versions are affected?
Affected versions include releases prior to 21.3.1 across affected packages: file-type.
What version fixes CVE-2026-31808?
Upgrading to 21.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is file-type affected?
Yes, file-type is affected in releases prior to 21.3.1. Upgrade your dependency to 21.3.1 or later.
What is the CVSS score of CVE-2026-31808?
CVE-2026-31808 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2026-31808?
CVE-2026-31808 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check npm dependencies for CVE-2026-31808?
Run the dependency tree command: 'npm ls file-type'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5v7r-6r5c-r473",
  "modified" : "2026-03-10T23:57:09Z",
  "published" : "2026-03-10T23:57:09Z",
  "aliases" : [ "CVE-2026-31808" ],
  "summary" : "file-type affected by infinite loop in ASF parser on malformed input with zero-size sub-header",
  "details" : "### Impact\nA denial of service vulnerability exists in the ASF (WMV/WMA) file type detection parser. When parsing a crafted input where an ASF sub-header has a `size` field of zero, the parser enters an infinite loop. The `payload` value becomes negative (-24), causing `tokenizer.ignore(payload)` to move the read position backwards, so the same sub-header is read repeatedly forever.\n\nAny application that uses `file-type` to detect the type of untrusted/attacker-controlled input is affected. An attacker can stall the Node.js event loop with a 55-byte payload.\n\n### Patches\nFixed in version 21.3.1. Users should upgrade to >= 21.3.1.\n\n### Workarounds\nValidate or limit the size of input buffers before passing them to `file-type`, or run file type detection in a worker thread with a timeout.\n\n### References\n- Fix commit: 319abf871b50ba2fa221b4a7050059f1ae096f4f\n\n### Reporter\n\ncrnkovic@lokvica.com",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "file-type"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "13.0.0"
      }, {
        "fixed" : "21.3.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/security/advisories/GHSA-5v7r-6r5c-r473"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-31808"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/commit/319abf871b50ba2fa221b4a7050059f1ae096f4f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sindresorhus/file-type"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-835" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-10T23:57:09Z",
    "nvd_published_at" : "2026-03-10T21:16:50Z"
  }
}