Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVE-2024-4068 (High) detected in braces-3.0.2.tgz #1838

Closed
mend-for-github-com bot opened this issue May 20, 2024 · 2 comments · Fixed by #1844
Closed

CVE-2024-4068 (High) detected in braces-3.0.2.tgz #1838

mend-for-github-com bot opened this issue May 20, 2024 · 2 comments · Fixed by #1844
Labels
Mend: dependency security vulnerability Security vulnerability detected by Mend

Comments

@mend-for-github-com
Copy link

CVE-2024-4068 - High Severity Vulnerability

Vulnerable Library - braces-3.0.2.tgz

Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.

Library home page: https://registry.npmjs.org/braces/-/braces-3.0.2.tgz

Path to dependency file: /package.json

Path to vulnerable library: /package.json

Dependency Hierarchy:

  • mocha-10.1.0.tgz (Root Library)
    • chokidar-3.5.3.tgz
      • braces-3.0.2.tgz (Vulnerable Library)

Found in HEAD commit: 7a517c9fb93418ac1502fd437a58e6294370125c

Found in base branch: main

Vulnerability 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.

Publish Date: 2024-05-14

URL: CVE-2024-4068

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

@mend-for-github-com mend-for-github-com bot added the Mend: dependency security vulnerability Security vulnerability detected by Mend label May 20, 2024
@Swiddis
Copy link
Collaborator

Swiddis commented May 20, 2024

Vuln doesn't really affect us, citing paulmillr/chokidar#1314 -- theoretically, the call chain is via mocha.watchRun if we decide to pass a file path of 100 million+ unbalanced braces to the Mocha CLI during local development, which... Would be impressive, given the 4096-byte path length limit on Unix.

@Swiddis Swiddis removed the untriaged label May 20, 2024
@Swiddis
Copy link
Collaborator

Swiddis commented May 20, 2024

For fun I tried to do it anyways:

import subprocess

subprocess.run(["yarn", "run", "mocha", "--watch_files", "{"*200_000_000])

But got

Traceback (most recent call last):
  File "/Users/sawiddis/Documents/code/dashboards/plugins/dashboards-observability/temp.py", line 3, in <module>
    subprocess.run(["yarn", "run", "mocha", "--watch_files", "{"*200_000_000])
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 7] Argument list too long: 'yarn'

Turns out there's an OS limit on the maximum length of CLI arguments, which you can find with getconf. This limit cannot be changed.

> getconf ARG_MAX
1048576

So, doesn't affect us, but educational nonetheless. :)

@Swiddis Swiddis closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mend: dependency security vulnerability Security vulnerability detected by Mend
Projects
None yet
1 participant