CVE-2022-1537: Grunt Race Condition Vulnerability

HIGH
Advisory Identifier: GHSA-rm36-94g8-835r
CVSS 7.0
CWE-367
Published
Advisory Summary

CVE-2022-1537 is a HIGH (CVSS 7.0) race condition vulnerability (CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition) affecting Grunt libraries in the npm ecosystem. The issue involves race condition in grunt. Remediation is available by upgrading affected packages to version 1.5.3.

CVE-2022-1537 at a Glance

CVE Identifier CVE-2022-1537
GHSA Identifier GHSA-rm36-94g8-835r
Severity HIGH
CVSS v3.1 Base Score 7.0
CWE Classification CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition
Affected Product Grunt
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.0

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

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

How to Fix CVE-2022-1537

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

grunt fixed: 1.5.3
npm install grunt@1.5.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 grunt

How to Check if You Are Affected

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

npm ls grunt

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

Note: The npm ls grunt 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-367: Time-of-check Time-of-use (TOCTOU) Race Condition, where the product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check. In Grunt, 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

file.copy operations in GruntJS are vulnerable to a TOCTOU race condition leading to arbitrary file write in GitHub repository gruntjs/grunt prior to 1.5.3. This vulnerability is capable of arbitrary file writes which can lead to local privilege escalation to the GruntJS user if a lower-privileged user has write access to both source and destination directories as the lower-privileged user can create a symlink to the GruntJS user's .bashrc file or replace /etc/shadow file if the GruntJS user is root.

CVE-2022-1537 Affected Grunt Versions

1 component(s)
Fixed Versions:
1.5.3
Product / Package Ecosystem Affected Versions Fixed Version
grunt
npm
< 1.5.3
1.5.3

References

Frequently Asked Questions

What is CVE-2022-1537?
CVE-2022-1537 is a security vulnerability in Grunt involving Race Condition in Grunt under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition.
Which Grunt versions are affected?
Affected versions include releases prior to 1.5.3 across affected packages: grunt.
What version fixes CVE-2022-1537?
Upgrading to 1.5.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is grunt affected?
Yes, grunt is affected in releases prior to 1.5.3. Upgrade your dependency to 1.5.3 or later.
What is the CVSS score of CVE-2022-1537?
CVE-2022-1537 has a CVSS v3.1 base score of 7.0 (HIGH) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-1537?
CVE-2022-1537 is classified under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition (The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.).
How can I check npm dependencies for CVE-2022-1537?
Run the dependency tree command: 'npm ls grunt'. 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-rm36-94g8-835r",
  "modified" : "2022-05-25T19:30:09Z",
  "published" : "2022-05-11T00:01:37Z",
  "aliases" : [ "CVE-2022-1537" ],
  "summary" : "Race Condition in Grunt",
  "details" : "file.copy operations in GruntJS are vulnerable to a TOCTOU race condition leading to arbitrary file write in GitHub repository gruntjs/grunt prior to 1.5.3. This vulnerability is capable of arbitrary file writes which can lead to local privilege escalation to the GruntJS user if a lower-privileged user has write access to both source and destination directories as the lower-privileged user can create a symlink to the GruntJS user's .bashrc file or replace /etc/shadow file if the GruntJS user is root.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "grunt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-1537"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gruntjs/grunt/commit/58016ffac5ed9338b63ecc2a63710f5027362bae"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gruntjs/grunt"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/0179c3e5-bc02-4fc9-8491-a1a319b51b4d"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/04/msg00006.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-367" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-05-25T19:30:09Z",
    "nvd_published_at" : "2022-05-10T14:15:00Z"
  }
}