CVE-2022-36313: File type File-type Vulnerable To Infinite Loop Vulnerability

HIGH
Advisory Identifier: GHSA-mhxj-85r3-2x55
CVSS 7.5
CWE-835
Published
Advisory Summary

CVE-2022-36313 is a HIGH (CVSS 7.5) file-type vulnerable to infinite loop vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting File type libraries in the npm ecosystem. The issue involves file-type vulnerable to infinite loop via malformed mkv file. Remediation is available by upgrading affected packages to version 16.5.4, 17.1.3.

CVE-2022-36313 at a Glance

CVE Identifier CVE-2022-36313
GHSA Identifier GHSA-mhxj-85r3-2x55
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product File type
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2022-36313

To remediate this vulnerability, upgrade all affected File type dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

file-type fixed: 16.5.4
npm install file-type@16.5.4
file-type fixed: 17.1.3
npm install file-type@17.1.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls file-type

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-36313, inspect your project dependencies using npm:

npm ls file-type

Analyze the terminal output to locate any version of File type in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 16.5.4), your application is affected.

Note: The npm ls file-type command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop'), where the product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. In File type, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

An issue was discovered in the file-type package from 13.0.0 until 16.5.4 and 17.x before 17.1.3 for Node.js. A malformed MKV file could cause the file type detector to get caught in an infinite loop. This would make the application become unresponsive and could be used to cause a DoS attack when used on a web server.

CVE-2022-36313 Affected File type Versions

2 component(s)
Fixed Versions:
16.5.417.1.3
Product / Package Ecosystem Affected Versions Fixed Version
file-type
npm
≥ 13.0.0
< 16.5.4
16.5.4
file-type
npm
≥ 17.0.0
< 17.1.3
17.1.3

References

Frequently Asked Questions

What is CVE-2022-36313?
CVE-2022-36313 is a security vulnerability in File type involving file-type vulnerable to Infinite Loop via malformed MKV file under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which File type versions are affected?
Affected versions include releases prior to 16.5.4, 17.1.3 across affected packages: file-type.
What version fixes CVE-2022-36313?
Upgrading to 16.5.4, 17.1.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is file-type affected?
Yes, file-type is affected in releases prior to 16.5.4, 17.1.3. Upgrade your dependency to 16.5.4, 17.1.3 or later.
What is the CVSS score of CVE-2022-36313?
CVE-2022-36313 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-36313?
CVE-2022-36313 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check npm dependencies for CVE-2022-36313?
Run the dependency tree command: 'npm ls file-type'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mhxj-85r3-2x55",
  "modified" : "2022-08-16T15:42:27Z",
  "published" : "2022-07-22T00:00:38Z",
  "aliases" : [ "CVE-2022-36313" ],
  "summary" : "file-type vulnerable to Infinite Loop via malformed MKV file",
  "details" : "An issue was discovered in the file-type package from 13.0.0 until 16.5.4 and 17.x before 17.1.3 for Node.js. A malformed MKV file could cause the file type detector to get caught in an infinite loop. This would make the application become unresponsive and could be used to cause a DoS attack when used on a web server.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "file-type"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "13.0.0"
      }, {
        "fixed" : "16.5.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "file-type"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "17.0.0"
      }, {
        "fixed" : "17.1.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-36313"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/commit/2c4d1200c99dffb7d515b9b9951ef43c22bf7e47"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/commit/8f981c32e2750d2516457e305e502ee2ad715759#diff-c853b2249e99790d8725774cf63c90c5ab17112067df6e267f3701d7bf591d12"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/commit/d86835680f4cccbee1a60628783c36700ec9e254"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sindresorhus/file-type"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/compare/v12.4.2...v13.0.0#diff-c853b2249e99790d8725774cf63c90c5ab17112067df6e267f3701d7bf591d12R611-R613"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/releases/tag/v16.5.4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sindresorhus/file-type/releases/tag/v17.1.3"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220909-0005"
  }, {
    "type" : "WEB",
    "url" : "https://security.snyk.io/vuln/SNYK-JS-FILETYPE-2958042"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/file-type"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-835" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-07-22T20:26:05Z",
    "nvd_published_at" : "2022-07-21T16:15:00Z"
  }
}