GHSA-grv7-fg5c-xmjg CVE-2024-4068
Uncontrolled resource consumption in braces
- Severity
- 7.5 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 1.47%
- Chance of exploitation in the next 30 days. Higher than 73.77% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-1050 Excessive Platform Resource Consumption within a Loop
- CWE-400 Uncontrolled Resource Consumption
- Fix
3.0.3- Upgrade braces to this version or later
Description
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.
Affected versions
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| braces | < 3.0.3 |
3.0.3 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
braces npm → 3.0.3
- npm
npm install braces@3.0.3- yarn
yarn add braces@3.0.3- pnpm
pnpm add braces@3.0.3
Severity breakdown
CVSS 3.1 7.5
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Weakness
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.
CWE-400: Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource.
How to prevent it
- Architecture and Design: Design throttling mechanisms into the system architecture. The best protection is to limit the amount of resources that an unauthorized user can cause to be expended. A strong authentication and access control model will help prevent such attacks from occurring in the first place. The login application should be protected against DoS attacks as much as possible. Limiting the database access, perhaps by caching result sets, can help minimize the resources expended. To further limit the potential for a DoS attack, consider tracking the rate of requests received from users and blocking requests that exceed a defined rate threshold.
- Architecture and Design: Mitigation of resource exhaustion attacks requires that the target system either: recognizes the attack and denies that user further access for a given amount of time, or uniformly throttles all requests in order to make it more difficult to consume resources more quickly than they can again be freed. The first of these solutions is an issue in itself though, since it may allow attackers to prevent the use of the system by a particular valid user. If the attacker impersonates the valid user, they may be able to prevent the user from accessing the server in question. The second solution is simply difficult to effectively institute -- and even when properly done, it does not provide a full solution. It simply makes the attack require more resources on the part of the attacker.
- Architecture and Design: Ensure that protocols have specific limits of scale placed on them.
- Implementation: Ensure that all failures in resource allocation place the system into a safe posture.
References
Advisories
Packages
Other links
- github.com/micromatch/braces/issues/35
- github.com/micromatch/braces/pull/37
- github.com/micromatch/braces/pull/40
- github.com/micromatch/braces/commit/415d660c3002d1ab7e63dbf490c9851da80596ff
- devhub.checkmarx.com/cve-details/CVE-2024-4068
- github.com/micromatch/braces/blob/98414f9f1fabe021736e26836d8306d5de747e0d/lib/…
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-cwfw-4gq5-mrqx Regular Expression Denial of Service (ReDoS) in braces | Medium | Also affects braces |
| GHSA-96hv-2xvq-fx4p ws: Memory exhaustion DoS from tiny fragments and data chunks | High | Same weakness, CWE-1050 |
| GHSA-h4wv-g838-66g3 Keycloak: Application-Level DoS via Scope Processing | High | Same weakness, CWE-1050 |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor