GitHub Advisoryadvisory · npm

GHSA-5v7r-6r5c-r473 file-type affected by infinite loop in ASF parser on malformed input with zero-size sub-header

MEDIUM Published 2026-03-10 Modified 2026-03-10 Official page ↗
Aliases
CVE-2026-31808
Ecosystem
npm
Packages
file-type
Severity
Moderate
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Weaknesses
CWE-835
Reviewed
2026-03-10

Affected packages

• npm file-type: >= 13.0.0, < 21.3.1 → fixed in 21.3.1

Description

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 [email protected]

Related

Alias · CVE (1)

  • CVE-2026-31808 file-type detects the file type of a file, stream, or data. vulnerability

Weakness · CWE (1)

  • CWE-835 Loop with Unreachable Exit Condition weakness

References