opensearch-project / dashboards-observability

Visualize and explore your logs, traces and metrics data in OpenSearch Dashboards
https://opensearch.org/docs/latest/observability-plugin/index/
Apache License 2.0
15 stars 53 forks source link

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

Closed mend-for-github-com[bot] closed 5 months ago

mend-for-github-com[bot] commented 5 months ago

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 - :x: **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.

Swiddis commented 5 months ago

Vuln doesn't really affect us, citing https://github.com/paulmillr/chokidar/issues/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 commented 5 months ago

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. :)