# CVE-2024-4068: Memory Exhaustion in braces

> An attacker can cause a denial of service by sending imbalanced braces to the braces library, triggering infinite memory allocation and crashing the application.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 13 May 2024
- **Updated:** 6 Nov 2024
- **Also known as:** AZL-42034, AZL-44020, AZL-44562, CLEANSTART-2026-LF83973, CLEANSTART-2026-LX13962, CLSA-2026-1771546208, CLSA-2026-1771805413, CLSA-2026-1776731778, CLSA-2026-1777509592, CLSA-2026-1780879899, DEBIAN-CVE-2024-4068, GHSA-grv7-fg5c-xmjg, MINI-3wvg-p8qj-r3xw, MINI-mccj-2jhv-rpr2, MINI-p7g2-vj97-xhwq, ROOT-APP-NPM-CVE-2024-4068, UBUNTU-CVE-2024-4068

## What is CVE-2024-4068?

CVE-2024-4068 is a high-severity denial of service vulnerability in micromatch braces, published on 13 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

The NPM package `braces`, versions prior to 3.0.3, 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.

Weakness: CWE-400 (Uncontrolled Resource Consumption), CWE-1050 (Excessive Platform Resource Consumption within a Loop)

## Which versions are affected by CVE-2024-4068?

2 open source packages ship an affected version, including braces. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `braces` | npm | All versions | 3.0.3 |
| `braces` | npm | All versions | 3.0.3 |

Products: Jonschlinkert Braces.

## How do I fix CVE-2024-4068?

Upgrade braces to 3.0.3 or later.

## Is CVE-2024-4068 being exploited?

There is no known exploitation of CVE-2024-4068 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-4068 and fix it if it is affected.

What it is: CVE-2024-4068 is a high-severity denial of service vulnerability in micromatch braces, published on 13 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-4068 in the wild and no public exploit code.

Affected packages and fixed versions:
- braces (npm): affected all versions; fixed in 3.0.3
- braces (npm): affected all versions; fixed in 3.0.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-4068/ (Markdown: https://insights.sbomify.com/CVE-2024-4068/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-4068
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-4068
- OSV: https://osv.dev/vulnerability/CVE-2024-4068

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-4068/
Summaries are generated and may contain mistakes; the official description above is the record.
