Skip to content

Commit 2f42f76

Browse files
[AUTO-CHERRYPICK] [Medium] Patch nodejs18 for CVE-2024-34064 - branch main (#12534)
Co-authored-by: Kevin Lockwood <57274670+kevin-b-lockwood@users.noreply.github.com>
1 parent 55ed026 commit 2f42f76

2 files changed

Lines changed: 73 additions & 1 deletion

File tree

SPECS/nodejs/CVE-2024-34064.patch

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
From fd536e6a9b6653b3a0989732b1c827b14b6de60b Mon Sep 17 00:00:00 2001
2+
From: Kevin Lockwood <v-klockwood@microsoft.com>
3+
Date: Thu, 6 Feb 2025 17:00:17 -0800
4+
Subject: [PATCH] Patch nodejs for CVE-2024-34064
5+
6+
Link: https://github.com/pallets/jinja/commit/0668239dc6b44ef38e7a6c9f91f312fd4ca581cb.patch
7+
---
8+
deps/v8/third_party/jinja2/filters.py | 24 +++++++++++++++++++-----
9+
1 file changed, 19 insertions(+), 5 deletions(-)
10+
11+
diff --git a/deps/v8/third_party/jinja2/filters.py b/deps/v8/third_party/jinja2/filters.py
12+
index 46347251..1daf42bc 100644
13+
--- a/deps/v8/third_party/jinja2/filters.py
14+
+++ b/deps/v8/third_party/jinja2/filters.py
15+
@@ -204,15 +204,23 @@ def do_lower(s):
16+
"""Convert a value to lowercase."""
17+
return soft_unicode(s).lower()
18+
19+
-_space_re = re.compile(r"\s", flags=re.ASCII)
20+
+# Check for characters that would move the parser state from key to value.
21+
+# https://html.spec.whatwg.org/#attribute-name-state
22+
+_attr_key_re = re.compile(r"[\s/>=]", flags=re.ASCII)
23+
24+
25+
@evalcontextfilter
26+
def do_xmlattr(_eval_ctx, d, autospace=True):
27+
"""Create an SGML/XML attribute string based on the items in a dict.
28+
29+
- If any key contains a space, this fails with a ``ValueError``. Values that
30+
- are neither ``none`` nor ``undefined`` are automatically escaped.
31+
+ **Values** that are neither ``none`` nor ``undefined`` are automatically
32+
+ escaped, safely allowing untrusted user input.
33+
+
34+
+ User input should not be used as **keys** to this filter. If any key
35+
+ contains a space, ``/`` solidus, ``>`` greater-than sign, or ``=`` equals
36+
+ sign, this fails with a ``ValueError``. Regardless of this, user input
37+
+ should never be used as keys to this filter, or must be separately validated
38+
+ first.
39+
40+
.. sourcecode:: html+jinja
41+
42+
@@ -232,6 +240,10 @@ def do_xmlattr(_eval_ctx, d, autospace=True):
43+
As you can see it automatically prepends a space in front of the item
44+
if the filter returned something unless the second parameter is false.
45+
46+
+ .. versionchanged:: 3.1.4
47+
+ Keys with ``/`` solidus, ``>`` greater-than sign, or ``=`` equals sign
48+
+ are not allowed.
49+
+
50+
.. versionchanged:: 3.1.3
51+
Keys with spaces are not allowed.
52+
"""
53+
@@ -239,8 +251,10 @@ def do_xmlattr(_eval_ctx, d, autospace=True):
54+
for key, value in d.items():
55+
if value is None or isinstance(value, Undefined):
56+
continue
57+
- if _space_re.search(key) is not None:
58+
- raise ValueError(f"Spaces are not allowed in attributes: '{key}'")
59+
+
60+
+ if _attr_key_re.search(key) is not None:
61+
+ raise ValueError(f"Invalid character in attribute name: {key!r}")
62+
+
63+
items.append(f'{escape(key)}="{escape(value)}"')
64+
rv = " ".join(items)
65+
66+
--
67+
2.34.1
68+

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: 3%{?dist}
9+
Release: 4%{?dist}
1010
License: BSD and MIT and Public Domain and NAIST-2003 and Artistic-2.0
1111
Group: Applications/System
1212
Vendor: Microsoft Corporation
@@ -22,6 +22,7 @@ Patch2: CVE-2025-22150.patch
2222
Patch3: CVE-2025-23085.patch
2323
Patch4: CVE-2024-22020.patch
2424
Patch5: CVE-2024-22195.patch
25+
Patch6: CVE-2024-34064.patch
2526
BuildRequires: brotli-devel
2627
BuildRequires: coreutils >= 8.22
2728
BuildRequires: gcc
@@ -122,6 +123,9 @@ make cctest
122123
%{_datadir}/systemtap/tapset/node.stp
123124

124125
%changelog
126+
* Tue Feb 18 2025 Kevin Lockwood <v-klockwood@microsoft.com> - 18.20.3-4
127+
- Patch CVE-2024-34064
128+
125129
* Tue Feb 11 2025 Kanishk Bansal <kanbansal@microsoft.com> - 18.20.3-3
126130
- Patch CVE-2025-22150, CVE-2025-23085, CVE-2024-22020, CVE-2024-22195
127131

0 commit comments

Comments
 (0)