CVE-2024-4068: Braces Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-grv7-fg5c-xmjg
CVSS 7.5
CWE-1050 CWE-400
Published
Advisory Summary

CVE-2024-4068 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-1050: Excessive Platform Resource Consumption within a Loop) affecting Braces libraries in the npm ecosystem. The issue involves uncontrolled resource consumption in braces. Remediation is available by upgrading affected packages to version 3.0.3.

CVE-2024-4068 at a Glance

CVE Identifier CVE-2024-4068
GHSA Identifier GHSA-grv7-fg5c-xmjg
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-1050: Excessive Platform Resource Consumption within a Loop
Affected Product Braces
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-2024-4068

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

braces fixed: 3.0.3
npm install braces@3.0.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 braces

How to Check if You Are Affected

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

npm ls braces

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

Note: The npm ls braces 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-1050: Excessive Platform Resource Consumption within a Loop, where the product has a loop body or loop condition that contains a control element that directly or indirectly consumes platform resources, e.g. messaging, sessions, locks, or file descriptors. In Braces, 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

The NPM package `braces` fails to limit the number of characters it can handle, which could lead to Memory Exhaustion. In `lib/parse.js,` if a malicious user sends "imbalanced braces" as input, the parsing will enter a loop, which will cause the program to start allocating heap memory without freeing it at any moment of the loop. Eventually, the JavaScript heap limit is reached, and the program will crash.

CVE-2024-4068 Affected Braces Versions

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

References

Frequently Asked Questions

What is CVE-2024-4068?
CVE-2024-4068 is a security vulnerability in Braces involving Uncontrolled resource consumption in braces under CWE-1050: Excessive Platform Resource Consumption within a Loop.
Which Braces versions are affected?
Affected versions include releases prior to 3.0.3 across affected packages: braces.
What version fixes CVE-2024-4068?
Upgrading to 3.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is braces affected?
Yes, braces is affected in releases prior to 3.0.3. Upgrade your dependency to 3.0.3 or later.
What is the CVSS score of CVE-2024-4068?
CVE-2024-4068 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-2024-4068?
CVE-2024-4068 is classified under CWE-1050: Excessive Platform Resource Consumption within a Loop (The product has a loop body or loop condition that contains a control element that directly or indirectly consumes platform resources, e.g. messaging, sessions, locks, or file descriptors.).
How can I check npm dependencies for CVE-2024-4068?
Run the dependency tree command: 'npm ls braces'. 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-grv7-fg5c-xmjg",
  "modified" : "2024-06-10T20:17:26Z",
  "published" : "2024-05-14T18:30:54Z",
  "aliases" : [ "CVE-2024-4068" ],
  "summary" : "Uncontrolled resource consumption in braces",
  "details" : "The NPM package `braces` fails to limit the number of characters it can handle, which could lead to Memory Exhaustion. In `lib/parse.js,` if a malicious user sends \"imbalanced braces\" as input, the parsing will enter a loop, which will cause the program to start allocating heap memory without freeing it at any moment of the loop. Eventually, the JavaScript heap limit is reached, and the program will crash.\n",
  "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" : "braces"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-4068"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/braces/issues/35"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/braces/pull/37"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/braces/pull/40"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/braces/commit/415d660c3002d1ab7e63dbf490c9851da80596ff"
  }, {
    "type" : "WEB",
    "url" : "https://devhub.checkmarx.com/cve-details/CVE-2024-4068"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/micromatch/braces"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/micromatch/braces/blob/98414f9f1fabe021736e26836d8306d5de747e0d/lib/parse.js#L308"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1050", "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-10T20:17:26Z",
    "nvd_published_at" : "2024-05-14T15:42:48Z"
  }
}