Skip to content

Commit 1a4f0a0

Browse files
[AUTO-CHERRYPICK] [Medium] Fix CVE-2023-3978 for kubevirt - branch main (#12388)
Co-authored-by: Sudipta Pandit <sudpandit@microsoft.com>
1 parent 36cdfa1 commit 1a4f0a0

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

SPECS/kubevirt/CVE-2023-3978.patch

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From 5abbff46d6a70d0e31b41ce98cddaa08cc911e3f Mon Sep 17 00:00:00 2001
2+
From: Sudipta Pandit <sudpandit@microsoft.com>
3+
Date: Wed, 5 Feb 2025 20:58:22 +0530
4+
Subject: [PATCH] Backport fix for CVE-2023-3978
5+
6+
Reference: https://go-review.googlesource.com/c/net/+/514896
7+
---
8+
vendor/golang.org/x/net/html/render.go | 28 ++++++++++++++++++++++----
9+
1 file changed, 24 insertions(+), 4 deletions(-)
10+
11+
diff --git a/vendor/golang.org/x/net/html/render.go b/vendor/golang.org/x/net/html/render.go
12+
index 497e132..1da09c8 100644
13+
--- a/vendor/golang.org/x/net/html/render.go
14+
+++ b/vendor/golang.org/x/net/html/render.go
15+
@@ -194,9 +194,8 @@ func render1(w writer, n *Node) error {
16+
}
17+
}
18+
19+
- // Render any child nodes.
20+
- switch n.Data {
21+
- case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "xmp":
22+
+ // Render any child nodes
23+
+ if childTextNodesAreLiteral(n) {
24+
for c := n.FirstChild; c != nil; c = c.NextSibling {
25+
if c.Type == TextNode {
26+
if _, err := w.WriteString(c.Data); err != nil {
27+
@@ -213,7 +212,7 @@ func render1(w writer, n *Node) error {
28+
// last element in the file, with no closing tag.
29+
return plaintextAbort
30+
}
31+
- default:
32+
+ } else {
33+
for c := n.FirstChild; c != nil; c = c.NextSibling {
34+
if err := render1(w, c); err != nil {
35+
return err
36+
@@ -231,6 +230,27 @@ func render1(w writer, n *Node) error {
37+
return w.WriteByte('>')
38+
}
39+
40+
+func childTextNodesAreLiteral(n *Node) bool {
41+
+ // Per WHATWG HTML 13.3, if the parent of the current node is a style,
42+
+ // script, xmp, iframe, noembed, noframes, or plaintext element, and the
43+
+ // current node is a text node, append the value of the node's data
44+
+ // literally. The specification is not explicit about it, but we only
45+
+ // enforce this if we are in the HTML namespace (i.e. when the namespace is
46+
+ // "").
47+
+ // NOTE: we also always include noscript elements, although the
48+
+ // specification states that they should only be rendered as such if
49+
+ // scripting is enabled for the node (which is not something we track).
50+
+ if n.Namespace != "" {
51+
+ return false
52+
+ }
53+
+ switch n.Data {
54+
+ case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "xmp":
55+
+ return true
56+
+ default:
57+
+ return false
58+
+ }
59+
+}
60+
+
61+
// writeQuoted writes s to w surrounded by quotes. Normally it will use double
62+
// quotes, but if s contains a double quote, it will use single quotes.
63+
// It is used for writing the identifiers in a doctype declaration.
64+
--
65+
2.34.1
66+

SPECS/kubevirt/kubevirt.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Summary: Container native virtualization
2020
Name: kubevirt
2121
Version: 0.59.0
22-
Release: 23%{?dist}
22+
Release: 24%{?dist}
2323
License: ASL 2.0
2424
Vendor: Microsoft Corporation
2525
Distribution: Mariner
@@ -40,6 +40,7 @@ Patch07: CVE-2023-45288.patch
4040
Patch08: CVE-2022-32149.patch
4141
Patch09: CVE-2023-26484.patch
4242
Patch10: CVE-2024-45338.patch
43+
Patch11: CVE-2023-3978.patch
4344
%global debug_package %{nil}
4445
BuildRequires: glibc-devel
4546
BuildRequires: glibc-static >= 2.35-7%{?dist}
@@ -219,6 +220,9 @@ install -p -m 0644 cmd/virt-handler/nsswitch.conf %{buildroot}%{_datadir}/kube-v
219220
%{_bindir}/virt-tests
220221

221222
%changelog
223+
* Wed Feb 05 2025 Sudipta Pandit <sudpandit@microsoft.com> - 0.59.0-24
224+
- Backport patch for CVE-2023-3978
225+
222226
* Fri Jan 03 2025 Sumedh Sharma <sumsharma@microsoft.com> - 0.59.0-23
223227
- Add patch to fix CVE-2024-45338
224228

0 commit comments

Comments
 (0)