Skip to content

Commit 84aabf5

Browse files
CBL-Mariner-Botrealsdxjslobodzian
authored
[AUTO-CHERRYPICK] Fix CVE-2023-3978 for containerized-data-importer - branch 3.0-dev (#12581)
Co-authored-by: Sudipta Pandit <sudpandit@microsoft.com> Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent b4fcc4e commit 84aabf5

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

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/containerized-data-importer/containerized-data-importer.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Summary: Container native virtualization
1919
Name: containerized-data-importer
2020
Version: 1.57.0
21-
Release: 11%{?dist}
21+
Release: 12%{?dist}
2222
License: ASL 2.0
2323
Vendor: Microsoft Corporation
2424
Distribution: Azure Linux
@@ -33,6 +33,7 @@ Patch4: CVE-2023-39325.patch
3333
Patch5: CVE-2023-44487.patch
3434
Patch6: CVE-2024-28180.patch
3535
Patch7: CVE-2023-45288.patch
36+
Patch8: CVE-2023-3978.patch
3637
BuildRequires: golang
3738
BuildRequires: golang-packaging
3839
BuildRequires: libnbd-devel
@@ -227,6 +228,9 @@ install -m 0644 _out/manifests/release/cdi-cr.yaml %{buildroot}%{_datadir}/cdi/m
227228
%{_datadir}/cdi/manifests
228229

229230
%changelog
231+
* Sun Feb 23 2025 Sudipta Pandit <sudpandit@microsoft.com> - 1.57.0-12
232+
- Fix CVE-2023-3978 with a backported patch
233+
230234
* Fri Feb 14 2025 Kanishk Bansal <kanbansal@microsoft.com> - 1.57.0-11
231235
- Address CVE-2023-45288
232236

0 commit comments

Comments
 (0)