Skip to content

Commit ce9f875

Browse files
[AUTO-CHERRYPICK] Fix CVE-2024-21538 in nodejs - branch main (#11189)
Co-authored-by: Bala <kumaran.4353@gmail.com>
1 parent 7571f1b commit ce9f875

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

SPECS/nodejs/CVE-2024-21538.patch

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From ea1368b332cebba727436bf4dddebb0c5d7a9d5b Mon Sep 17 00:00:00 2001
2+
From: bala <balakumaran.kannan@microsoft.com>
3+
Date: Tue, 19 Nov 2024 12:03:43 +0000
4+
Subject: [PATCH] Vendor patch applied to fix CVE-2024-21538
5+
6+
---
7+
deps/npm/node_modules/cross-spawn/lib/util/escape.js | 6 ++++--
8+
1 file changed, 4 insertions(+), 2 deletions(-)
9+
10+
diff --git a/deps/npm/node_modules/cross-spawn/lib/util/escape.js b/deps/npm/node_modules/cross-spawn/lib/util/escape.js
11+
index b0bb84c..e4804b9 100644
12+
--- a/deps/npm/node_modules/cross-spawn/lib/util/escape.js
13+
+++ b/deps/npm/node_modules/cross-spawn/lib/util/escape.js
14+
@@ -15,15 +15,17 @@ function escapeArgument(arg, doubleEscapeMetaChars) {
15+
arg = `${arg}`;
16+
17+
// Algorithm below is based on https://qntm.org/cmd
18+
+ // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
19+
+ // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
20+
21+
// Sequence of backslashes followed by a double quote:
22+
// double up all the backslashes and escape the double quote
23+
- arg = arg.replace(/(\\*)"/g, '$1$1\\"');
24+
+ arg = arg.replace(/(?=\\*?)"/g, '$1$1\\"');
25+
26+
// Sequence of backslashes followed by the end of the string
27+
// (which will become a double quote later):
28+
// double up all the backslashes
29+
- arg = arg.replace(/(\\*)$/, '$1$1');
30+
+ arg = arg.replace(/(?=\\*?)$/, '$1$1');
31+
32+
// All other backslashes occur literally
33+
34+
--
35+
2.39.4
36+

SPECS/nodejs/nodejs18.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Name: nodejs18
66
# WARNINGS: MUST check and update the 'npm_version' macro for every version update of this package.
77
# The version of NPM can be found inside the sources under 'deps/npm/package.json'.
88
Version: 18.20.3
9-
Release: 1%{?dist}
9+
Release: 2%{?dist}
1010
License: BSD and MIT and Public Domain and NAIST-2003 and Artistic-2.0
1111
Group: Applications/System
1212
Vendor: Microsoft Corporation
@@ -17,6 +17,7 @@ URL: https://github.com/nodejs/node
1717
# !!! => use clean-source-tarball.sh script to create a clean and reproducible source tarball.
1818
Source0: https://nodejs.org/download/release/v%{version}/node-v%{version}.tar.xz
1919
Patch0: CVE-2023-21100.patch
20+
Patch1: CVE-2024-21538.patch
2021
BuildRequires: brotli-devel
2122
BuildRequires: coreutils >= 8.22
2223
BuildRequires: gcc
@@ -117,6 +118,9 @@ make cctest
117118
%{_datadir}/systemtap/tapset/node.stp
118119

119120
%changelog
121+
* Tue Nov 19 2024 Bala <balakumaran.kannan@microsoft.com> - 18.20.3-2
122+
- Patch CVE-2024-21538
123+
120124
* Thu Jun 13 2024 Nick Samson <nisamson@microsoft.com> - 18.20.3-1
121125
- Upgrade to 18.20.3-1 to fix CVE-2024-28863
122126

SPECS/python-tensorboard/python-tensorboard.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TensorBoard is a suite of web applications for inspecting and understanding your
77
Summary: TensorBoard is a suite of web applications for inspecting and understanding your TensorFlow runs and graphs
88
Name: python-%{pypi_name}
99
Version: 2.11.0
10-
Release: 2%{?dist}
10+
Release: 3%{?dist}
1111
License: ASL 2.0
1212
Vendor: Microsoft Corporation
1313
Distribution: Mariner
@@ -56,6 +56,7 @@ Summary: %{summary}
5656

5757
%prep
5858
%autosetup -p1 -n tensorboard-%{version}
59+
rm -rf tensorboard-%{version}/tb_tmp/b069b9e9814ff76ffa6219506d1f1e79/external/npm
5960

6061
%build
6162
tar -xf %{SOURCE1} -C /root/
@@ -102,6 +103,10 @@ mv %{pypi_name}-%{version}-*.whl pyproject-wheeldir/
102103
%{python3_sitelib}/tensorboard_data_server*
103104

104105
%changelog
106+
* Tue Nov 19 2024 Bala <balakumaran.kannan@microsoft.com> - 2.11.0-3
107+
- Remove npm directory before building to make sure no nodejs vulnerability is getting through
108+
- It is done while fixing CVE-2024-21538
109+
105110
* Tue Aug 01 2023 Riken Maharjan <rmaharjan@microsoft.com> - 2.11.0-2
106111
- Remove bazel version.
107112

0 commit comments

Comments
 (0)