Skip to content

Commit

Permalink
Fix CVE-2023-3978 for kubevirt
Browse files Browse the repository at this point in the history
  • Loading branch information
realsdx committed Feb 5, 2025
1 parent 1a65dff commit cea61bb
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
66 changes: 66 additions & 0 deletions SPECS/kubevirt/CVE-2023-3978.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
From 5abbff46d6a70d0e31b41ce98cddaa08cc911e3f Mon Sep 17 00:00:00 2001
From: Sudipta Pandit <[email protected]>
Date: Wed, 5 Feb 2025 20:58:22 +0530
Subject: [PATCH] Backport fix for CVE-2023-3978

Reference: https://go-review.googlesource.com/c/net/+/514896
---
vendor/golang.org/x/net/html/render.go | 28 ++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/vendor/golang.org/x/net/html/render.go b/vendor/golang.org/x/net/html/render.go
index 497e132..1da09c8 100644
--- a/vendor/golang.org/x/net/html/render.go
+++ b/vendor/golang.org/x/net/html/render.go
@@ -194,9 +194,8 @@ func render1(w writer, n *Node) error {
}
}

- // Render any child nodes.
- switch n.Data {
- case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "xmp":
+ // Render any child nodes
+ if childTextNodesAreLiteral(n) {
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type == TextNode {
if _, err := w.WriteString(c.Data); err != nil {
@@ -213,7 +212,7 @@ func render1(w writer, n *Node) error {
// last element in the file, with no closing tag.
return plaintextAbort
}
- default:
+ } else {
for c := n.FirstChild; c != nil; c = c.NextSibling {
if err := render1(w, c); err != nil {
return err
@@ -231,6 +230,27 @@ func render1(w writer, n *Node) error {
return w.WriteByte('>')
}

+func childTextNodesAreLiteral(n *Node) bool {
+ // Per WHATWG HTML 13.3, if the parent of the current node is a style,
+ // script, xmp, iframe, noembed, noframes, or plaintext element, and the
+ // current node is a text node, append the value of the node's data
+ // literally. The specification is not explicit about it, but we only
+ // enforce this if we are in the HTML namespace (i.e. when the namespace is
+ // "").
+ // NOTE: we also always include noscript elements, although the
+ // specification states that they should only be rendered as such if
+ // scripting is enabled for the node (which is not something we track).
+ if n.Namespace != "" {
+ return false
+ }
+ switch n.Data {
+ case "iframe", "noembed", "noframes", "noscript", "plaintext", "script", "style", "xmp":
+ return true
+ default:
+ return false
+ }
+}
+
// writeQuoted writes s to w surrounded by quotes. Normally it will use double
// quotes, but if s contains a double quote, it will use single quotes.
// It is used for writing the identifiers in a doctype declaration.
--
2.34.1

6 changes: 5 additions & 1 deletion SPECS/kubevirt/kubevirt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Summary: Container native virtualization
Name: kubevirt
Version: 0.59.0
Release: 23%{?dist}
Release: 24%{?dist}
License: ASL 2.0
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -40,6 +40,7 @@ Patch07: CVE-2023-45288.patch
Patch08: CVE-2022-32149.patch
Patch09: CVE-2023-26484.patch
Patch10: CVE-2024-45338.patch
Patch11: CVE-2023-3978.patch
%global debug_package %{nil}
BuildRequires: glibc-devel
BuildRequires: glibc-static >= 2.35-7%{?dist}
Expand Down Expand Up @@ -219,6 +220,9 @@ install -p -m 0644 cmd/virt-handler/nsswitch.conf %{buildroot}%{_datadir}/kube-v
%{_bindir}/virt-tests

%changelog
* Wed Feb 05 2025 Sudipta Pandit <[email protected]> - 0.59.0-24
- Backport patch for CVE-2023-3978

* Fri Jan 03 2025 Sumedh Sharma <[email protected]> - 0.59.0-23
- Add patch to fix CVE-2024-45338

Expand Down

0 comments on commit cea61bb

Please sign in to comment.