CVE-2026-31808
JSON

5.3medium

file-type affected by infinite loop in ASF parser on malformed input with zero-size sub-header

Severity
5.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.37% (higher than 32% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-5v7r-6r5c-r473

Description

file-type detects the file type of a file, stream, or data. Prior to 21.3.1, 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. Fixed in version 21.3.1.

Affected

Product or packageVersionsReported by
sindresorhus file-type>= 13.0.0, < 21.3.1, from 13.0.0 before 21.3.1CVE List, NVD
file-type (npm)from 13.0.0 before 21.3.1GitHub Advisory Database

All scores

GitHub_M5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
GitHub5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Classification

CWE-835

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

file-type detects the file type of a file, stream, or data. Prior to 21.3.1, 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. Fixed in version 21.3.1.

GitHub Advisory Database
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

NVD (es)

file-type detecta el tipo de archivo de un archivo, flujo o datos. Antes de 21.3.1, existe una vulnerabilidad de denegación de servicio en el analizador de detección de tipo de archivo ASF (WMV/WMA). Al analizar una entrada manipulada donde un subencabezado ASF tiene un campo de tamaño de cero, el analizador entra en un bucle infinito. El valor de la carga útil se vuelve negativo (-24), haciendo que tokenizer.ignore(payload) mueva la posición de lectura hacia atrás, por lo que el mismo subencabezado se lee repetidamente para siempre. Cualquier aplicación que utiliza file-type para detectar el tipo de entrada no confiable/controlada por el atacante se ve afectada. Un atacante puede paralizar el bucle de eventos de Node.js con una carga útil de 55 bytes. Corregido en la versión 21.3.1.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-31808 changed 2026-03-11CVE Terms of Use
GitHub Advisory DatabaseGHSA-5v7r-6r5c-r473 changed 2026-09-10CC-BY-4.0
NVDCVE-2026-31808 changed 2026-06-17Public domain