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 package | Versions | Reported by |
|---|---|---|
| sindresorhus file-type | >= 13.0.0, < 21.3.1, from 13.0.0 before 21.3.1 | CVE List, NVD |
| file-type (npm) | from 13.0.0 before 21.3.1 | GitHub Advisory Database |
All scores
| GitHub_M | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L |
| GitHub | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L |
Classification
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
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
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-31808 changed 2026-03-11 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5v7r-6r5c-r473 changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-31808 changed 2026-06-17 | Public domain |