]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
libxml2: Add fix for CVE-2016-3709
authorPawan Badganchi <badganchipv@gmail.com>
Sun, 28 Aug 2022 09:31:25 +0000 (15:01 +0530)
committerSteve Sakoman <steve@sakoman.com>
Mon, 29 Aug 2022 15:02:16 +0000 (05:02 -1000)
Add below patch to fix CVE-2016-3709

CVE-2016-3709.patch
Link: https://github.com/GNOME/libxml2/commit/c1ba6f54d32b707ca6d91cb3257ce9de82876b6f
Signed-off-by: Pawan Badganchi<pawan.badganchi@kpit.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/recipes-core/libxml/libxml2/CVE-2016-3709.patch [new file with mode: 0644]
meta/recipes-core/libxml/libxml2_2.9.10.bb

diff --git a/meta/recipes-core/libxml/libxml2/CVE-2016-3709.patch b/meta/recipes-core/libxml/libxml2/CVE-2016-3709.patch
new file mode 100644 (file)
index 0000000..5301d05
--- /dev/null
@@ -0,0 +1,89 @@
+From c1ba6f54d32b707ca6d91cb3257ce9de82876b6f Mon Sep 17 00:00:00 2001
+From: Nick Wellnhofer <wellnhofer@aevum.de>
+Date: Sat, 15 Aug 2020 18:32:29 +0200
+Subject: [PATCH] Revert "Do not URI escape in server side includes"
+
+This reverts commit 960f0e275616cadc29671a218d7fb9b69eb35588.
+
+This commit introduced
+
+- an infinite loop, found by OSS-Fuzz, which could be easily fixed.
+- an algorithm with quadratic runtime
+- a security issue, see
+  https://bugzilla.gnome.org/show_bug.cgi?id=769760
+
+A better approach is to add an option not to escape URLs at all
+which libxml2 should have possibly done in the first place.
+
+CVE: CVE-2016-3709
+Upstream-Status: Backport [https://github.com/GNOME/libxml2/commit/c1ba6f54d32b707ca6d91cb3257ce9de82876b6f]
+Signed-off-by: Pawan Badganchi <Pawan.Badganchi@kpit.com>
+---
+ HTMLtree.c | 49 +++++++++++--------------------------------------
+ 1 file changed, 11 insertions(+), 38 deletions(-)
+
+diff --git a/HTMLtree.c b/HTMLtree.c
+index 8d236bb35..cdb7f86a6 100644
+--- a/HTMLtree.c
++++ b/HTMLtree.c
+@@ -706,49 +706,22 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
+                (!xmlStrcasecmp(cur->name, BAD_CAST "src")) ||
+                ((!xmlStrcasecmp(cur->name, BAD_CAST "name")) &&
+                 (!xmlStrcasecmp(cur->parent->name, BAD_CAST "a"))))) {
++              xmlChar *escaped;
+               xmlChar *tmp = value;
+-              /* xmlURIEscapeStr() escapes '"' so it can be safely used. */
+-              xmlBufCCat(buf->buffer, "\"");
+
+               while (IS_BLANK_CH(*tmp)) tmp++;
+
+-              /* URI Escape everything, except server side includes. */
+-              for ( ; ; ) {
+-                  xmlChar *escaped;
+-                  xmlChar endChar;
+-                  xmlChar *end = NULL;
+-                  xmlChar *start = (xmlChar *)xmlStrstr(tmp, BAD_CAST "<!--");
+-                  if (start != NULL) {
+-                      end = (xmlChar *)xmlStrstr(tmp, BAD_CAST "-->");
+-                      if (end != NULL) {
+-                          *start = '\0';
+-                      }
+-                  }
+-
+-                  /* Escape the whole string, or until start (set to '\0'). */
+-                  escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
+-                  if (escaped != NULL) {
+-                      xmlBufCat(buf->buffer, escaped);
+-                      xmlFree(escaped);
+-                  } else {
+-                      xmlBufCat(buf->buffer, tmp);
+-                  }
+-
+-                  if (end == NULL) { /* Everything has been written. */
+-                      break;
+-                  }
+-
+-                  /* Do not escape anything within server side includes. */
+-                  *start = '<'; /* Restore the first character of "<!--". */
+-                  end += 3; /* strlen("-->") */
+-                  endChar = *end;
+-                  *end = '\0';
+-                  xmlBufCat(buf->buffer, start);
+-                  *end = endChar;
+-                  tmp = end;
++              /*
++               * the < and > have already been escaped at the entity level
++               * And doing so here breaks server side includes
++               */
++              escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+<>");
++              if (escaped != NULL) {
++                  xmlBufWriteQuotedString(buf->buffer, escaped);
++                  xmlFree(escaped);
++              } else {
++                  xmlBufWriteQuotedString(buf->buffer, value);
+               }
+-
+-              xmlBufCCat(buf->buffer, "\"");
+           } else {
+               xmlBufWriteQuotedString(buf->buffer, value);
+           }
index d1c1f0884f6d67ca507f8aa79626d4f834203aee..dc6299173924e65a217a2c62c03277a1a5014733 100644 (file)
@@ -33,6 +33,7 @@ SRC_URI += "http://www.w3.org/XML/Test/xmlts20080827.tar.gz;subdir=${BP};name=te
            file://CVE-2022-29824-dependent.patch \
            file://CVE-2022-29824.patch \
            file://0001-Port-gentest.py-to-Python-3.patch \
+           file://CVE-2016-3709.patch \
            "
 
 SRC_URI[archive.sha256sum] = "593b7b751dd18c2d6abcd0c4bcb29efc203d0b4373a6df98e3a455ea74ae2813"