Skip to contentSkip to conversation

libxml2: security fix CVE-2015-7941

PATCH In review Armin Kuster 2 participants 12 messages Jan 8, 2016 – Jan 12, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/10 libxml2: security fix CVE-2015-7941

From: Armin Kuster <[email protected]>

includes:
CVE-2015-7941-1
CVE-2015-7941-2

---
 meta/recipes-core/libxml/libxml2.inc               |  2 +
 ...top-parsing-on-entities-boundaries-errors.patch | 39 +++++++++++++++
 ...leanup-conditional-section-error-handling.patch | 56 ++++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch
meta/recipes-core/libxml/libxml2.inc +2 -0
index 1c3c37d..24b98a6 100644
@@ -21,6 +21,8 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://libxml-m4-use-pkgconfig.patch \
            file://configure.ac-fix-cross-compiling-warning.patch \
            file://0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch \
+           file://CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch \
+           file://CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch new file +39 -0
new file mode 100644
index 0000000..11da9f9
@@ -0,0 +1,39 @@
+From a7dfab7411cbf545f359dd3157e5df1eb0e7ce31 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Mon, 23 Feb 2015 11:17:35 +0800
+Subject: [PATCH] Stop parsing on entities boundaries errors
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=744980
+
+There are times, like on unterminated entities that it's preferable to
+stop parsing, even if that means less error reporting. Entities are
+feeding the parser on further processing, and if they are ill defined
+then it's possible to get the parser to bug. Also do the same on
+Conditional Sections if the input is broken, as the structure of
+the document can't be guessed.
+
+Upstream-Status: Backport
+
+CVE-2015-7941-1
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/parser.c b/parser.c
+index a8d1b67..bbe97eb 100644
+--- a/parser.c
++++ b/parser.c
+@@ -5658,6 +5658,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
+ 	if (RAW != '>') {
+ 	    xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
+ 	            "xmlParseEntityDecl: entity %s not terminated\n", name);
++	    xmlStopParser(ctxt);
+ 	} else {
+ 	    if (input != ctxt->input) {
+ 		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+-- 
+2.3.5
+
meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.3.5
#1 lore raw

PATCH v2 2/10 libxml2: security fix CVE-2015-8317

From: Armin Kuster <[email protected]>

---
 meta/recipes-core/libxml/libxml2.inc               |  1 +
 ...ng-early-on-if-encoding-conversion-failed.patch | 42 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-8317-Fail-parsing-early-on-if-encoding-conversion-failed.patch
meta/recipes-core/libxml/libxml2.inc +1 -0
index 24b98a6..84217bf 100644
@@ -23,6 +23,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch \
            file://CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch \
            file://CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch \
+           file://CVE-2015-8317-Fail-parsing-early-on-if-encoding-conversion-failed.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/CVE-2015-8317-Fail-parsing-early-on-if-encoding-conversion-failed.patch new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.3.5
#2 lore raw

PATCH v2 3/10 libxml2: security fix CVE-2015-7942

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

includes:
CVE-2015-7942
CVE-2015-7942-2

---
 meta/recipes-core/libxml/libxml2.inc               |  2 ++
 ...ror-in-previous-Conditional-section-patch.patch | 35 +++++++++++++++++++
 ...iation-of-overflow-in-Conditional-section.patch | 39 ++++++++++++++++++++++
 3 files changed, 76 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7942-2-Fix-an-error-in-previous-Conditional-section-patch.patch
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7942-Another-variation-of-overflow-in-Conditional-section.patch
meta/recipes-core/libxml/libxml2.inc +2 -0
index 84217bf..97eb417 100644
@@ -24,6 +24,8 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch \
            file://CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch \
            file://CVE-2015-8317-Fail-parsing-early-on-if-encoding-conversion-failed.patch \
+           file://CVE-2015-7942-Another-variation-of-overflow-in-Conditional-section.patch \
+           file://CVE-2015-7942-2-Fix-an-error-in-previous-Conditional-section-patch.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/CVE-2015-7942-2-Fix-an-error-in-previous-Conditional-section-patch.patch new file +35 -0
new file mode 100644
index 0000000..34b6036
@@ -0,0 +1,35 @@
+From 41ac9049a27f52e7a1f3b341f8714149fc88d450 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Tue, 27 Oct 2015 10:53:44 +0800
+Subject: [PATCH] Fix an error in previous Conditional section patch
+
+an off by one mistake in the change, led to error on correct
+document where the end of the included entity was exactly
+the end of the conditional section, leading to regtest failure
+
+Upstream-Status: Backport
+
+CVE-2015-7942-2
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index b9217ff..d67b300 100644
+--- a/parser.c
++++ b/parser.c
+@@ -6916,7 +6916,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
+ 				 NULL, NULL);
+ 	}
+ 	if ((ctxt-> instate != XML_PARSER_EOF) &&
+-	    ((ctxt->input->cur + 3) < ctxt->input->end))
++	    ((ctxt->input->cur + 3) <= ctxt->input->end))
+ 	    SKIP(3);
+     }
+ }
+-- 
+2.3.5
+
meta/recipes-core/libxml/libxml2/CVE-2015-7942-Another-variation-of-overflow-in-Conditional-section.patch new file +39 -0
new file mode 100644
index 0000000..40082ec
@@ -0,0 +1,39 @@
+From bd0526e66a56e75a18da8c15c4750db8f801c52d Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Fri, 23 Oct 2015 19:02:28 +0800
+Subject: [PATCH] Another variation of overflow in Conditional sections
+
+Which happen after the previous fix to
+https://bugzilla.gnome.org/show_bug.cgi?id=756456
+
+But stopping the parser and exiting we didn't pop the intermediary entities
+and doing the SKIP there applies on an input which may be too small
+
+Upstream-Status: Backport
+
+CVE-2015-7942
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index a65e4cc..b9217ff 100644
+--- a/parser.c
++++ b/parser.c
+@@ -6915,7 +6915,9 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
+ 	"All markup of the conditional section is not in the same entity\n",
+ 				 NULL, NULL);
+ 	}
+-        SKIP(3);
++	if ((ctxt-> instate != XML_PARSER_EOF) &&
++	    ((ctxt->input->cur + 3) < ctxt->input->end))
++	    SKIP(3);
+     }
+ }
+ 
+-- 
+2.3.5
+
Signature · 1 line
2.3.5
#3 lore raw

PATCH v2 4/10 libxml2: security fix CVE-2015-8035

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

---
 meta/recipes-core/libxml/libxml2.inc               |  1 +
 ...2015-8035-Fix-XZ-compression-support-loop.patch | 38 ++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/0001-CVE-2015-8035-Fix-XZ-compression-support-loop.patch
meta/recipes-core/libxml/libxml2.inc +1 -0
index 97eb417..bc84656 100644
@@ -26,6 +26,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://CVE-2015-8317-Fail-parsing-early-on-if-encoding-conversion-failed.patch \
            file://CVE-2015-7942-Another-variation-of-overflow-in-Conditional-section.patch \
            file://CVE-2015-7942-2-Fix-an-error-in-previous-Conditional-section-patch.patch \
+           file://0001-CVE-2015-8035-Fix-XZ-compression-support-loop.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/0001-CVE-2015-8035-Fix-XZ-compression-support-loop.patch new file +38 -0
new file mode 100644
index 0000000..7107355
@@ -0,0 +1,38 @@
+From f0709e3ca8f8947f2d91ed34e92e38a4c23eae63 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Tue, 3 Nov 2015 15:31:25 +0800
+Subject: [PATCH] CVE-2015-8035 Fix XZ compression support loop
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=757466
+DoS when parsing specially crafted XML document if XZ support
+is compiled in (which wasn't the case for 2.9.2 and master since
+Nov 2013, fixed in next commit !)
+
+Upstream-Status: Backport
+
+CVE-2015-8035
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ xzlib.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/xzlib.c b/xzlib.c
+index 0dcb9f4..1fab546 100644
+--- a/xzlib.c
++++ b/xzlib.c
+@@ -581,6 +581,10 @@ xz_decomp(xz_statep state)
+             xz_error(state, LZMA_DATA_ERROR, "compressed data error");
+             return -1;
+         }
++        if (ret == LZMA_PROG_ERROR) {
++            xz_error(state, LZMA_PROG_ERROR, "compression error");
++            return -1;
++        }
+     } while (strm->avail_out && ret != LZMA_STREAM_END);
+ 
+     /* update available output and crc check value */
+-- 
+2.3.5
+
Signature · 1 line
2.3.5
#4 lore raw

PATCH v2 5/10 libxml2: security fix CVE-2015-7498

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

---
 meta/recipes-core/libxml/libxml2.inc               |  1 +
 ...ssing-entities-after-encoding-conversion-.patch | 89 ++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7498-Avoid-processing-entities-after-encoding-conversion-.patch
meta/recipes-core/libxml/libxml2.inc +1 -0
index bc84656..389f5cd 100644
@@ -27,6 +27,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://CVE-2015-7942-Another-variation-of-overflow-in-Conditional-section.patch \
            file://CVE-2015-7942-2-Fix-an-error-in-previous-Conditional-section-patch.patch \
            file://0001-CVE-2015-8035-Fix-XZ-compression-support-loop.patch \
+           file://CVE-2015-7498-Avoid-processing-entities-after-encoding-conversion-.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/CVE-2015-7498-Avoid-processing-entities-after-encoding-conversion-.patch new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.3.5
#5 lore raw

PATCH v2 6/10 libxml2: security fix CVE-2015-7497

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

---
 meta/recipes-core/libxml/libxml2.inc               |  1 +
 ...97-Avoid-an-heap-buffer-overflow-in-xmlDi.patch | 40 ++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/0001-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch
meta/recipes-core/libxml/libxml2.inc +1 -0
index 389f5cd..65b2625 100644
@@ -28,6 +28,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://CVE-2015-7942-2-Fix-an-error-in-previous-Conditional-section-patch.patch \
            file://0001-CVE-2015-8035-Fix-XZ-compression-support-loop.patch \
            file://CVE-2015-7498-Avoid-processing-entities-after-encoding-conversion-.patch \
+           file://0001-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/0001-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch new file +40 -0
new file mode 100644
index 0000000..955c9619
@@ -0,0 +1,40 @@
+From 6360a31a84efe69d155ed96306b9a931a40beab9 Mon Sep 17 00:00:00 2001
+From: David Drysdale <[email protected]>
+Date: Fri, 20 Nov 2015 10:47:12 +0800
+Subject: [PATCH] CVE-2015-7497 Avoid an heap buffer overflow in
+ xmlDictComputeFastQKey
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=756528
+It was possible to hit a negative offset in the name indexing
+used to randomize the dictionary key generation
+Reported and fix provided by David Drysdale @ Google
+
+Upstream-Status: Backport
+
+CVE-2015-7497
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ dict.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/dict.c b/dict.c
+index 5f71d55..8c8f931 100644
+--- a/dict.c
++++ b/dict.c
+@@ -486,7 +486,10 @@ xmlDictComputeFastQKey(const xmlChar *prefix, int plen,
+ 	value += 30 * (*prefix);
+ 
+     if (len > 10) {
+-        value += name[len - (plen + 1 + 1)];
++        int offset = len - (plen + 1 + 1);
++	if (offset < 0)
++	    offset = len - (10 + 1);
++	value += name[offset];
+         len = 10;
+ 	if (plen > 10)
+ 	    plen = 10;
+-- 
+2.3.5
+
Signature · 1 line
2.3.5
#6 lore raw

PATCH v2 7/10 libxml2: security fix CVE-2015-7499

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

includes:
CVE-2015-7499-1
CVE-2015-7499-2

---
 meta/recipes-core/libxml/libxml2.inc               |  2 +
 ...99-1-Add-xmlHaltParser-to-stop-the-parser.patch | 88 ++++++++++++++++++++++
 ...VE-2015-7499-2-Detect-incoherency-on-GROW.patch | 43 +++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7499-1-Add-xmlHaltParser-to-stop-the-parser.patch
 create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7499-2-Detect-incoherency-on-GROW.patch
meta/recipes-core/libxml/libxml2.inc +2 -0
index 65b2625..3073851 100644
@@ -29,6 +29,8 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://0001-CVE-2015-8035-Fix-XZ-compression-support-loop.patch \
            file://CVE-2015-7498-Avoid-processing-entities-after-encoding-conversion-.patch \
            file://0001-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch \
+           file://CVE-2015-7499-1-Add-xmlHaltParser-to-stop-the-parser.patch \
+           file://CVE-2015-7499-2-Detect-incoherency-on-GROW.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/CVE-2015-7499-1-Add-xmlHaltParser-to-stop-the-parser.patch new file +88 -0

88 lines not on this page · raw message

meta/recipes-core/libxml/libxml2/CVE-2015-7499-2-Detect-incoherency-on-GROW.patch new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.3.5
#7 lore raw

PATCH v2 8/10 libxml2: security fix CVE-2015-7500

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

includes a depend fix security issue CVE-2015-7500

---
 meta/recipes-core/libxml/libxml2.inc               |   2 +
 ...00-Fix-memory-access-error-due-to-incorre.patch | 131 +++++++++++++++++++
 ...n-name-parsing-at-the-end-of-current-inpu.patch | 138 +++++++++++++++++++++
 3 files changed, 271 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/0001-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch
 create mode 100644 meta/recipes-core/libxml/libxml2/0001-Fix-a-bug-on-name-parsing-at-the-end-of-current-inpu.patch
meta/recipes-core/libxml/libxml2.inc +2 -0
index 3073851..7fd7693 100644
@@ -31,6 +31,8 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://0001-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch \
            file://CVE-2015-7499-1-Add-xmlHaltParser-to-stop-the-parser.patch \
            file://CVE-2015-7499-2-Detect-incoherency-on-GROW.patch \
+           file://0001-Fix-a-bug-on-name-parsing-at-the-end-of-current-inpu.patch \
+           file://0001-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/0001-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch new file +131 -0

131 lines not on this page · raw message

meta/recipes-core/libxml/libxml2/0001-Fix-a-bug-on-name-parsing-at-the-end-of-current-inpu.patch new file +134 -0

134 lines not on this page · raw message

SYSTEM "A<lbbbbbbbbbbbbbbbbbbb_"

Quoted 1 line

%SYSTEM;<![

+\ No newline at end of file
+--
+2.3.5
+

Signature · 1 line
2.3.5
#8 lore raw

PATCH v2 9/10 libxml2: security fix CVE-2015-8242

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

---
 meta/recipes-core/libxml/libxml2.inc               |  1 +
 ...42-Buffer-overead-with-HTML-parser-in-pus.patch | 49 ++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/0001-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch
meta/recipes-core/libxml/libxml2.inc +1 -0
index 7fd7693..a30f0b6 100644
@@ -33,6 +33,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://CVE-2015-7499-2-Detect-incoherency-on-GROW.patch \
            file://0001-Fix-a-bug-on-name-parsing-at-the-end-of-current-inpu.patch \
            file://0001-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch \
+           file://0001-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/0001-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.3.5
#9 lore raw

PATCH v2 10/10 libxml2: security fix CVE-2015-5312

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

---
 meta/recipes-core/libxml/libxml2.inc               |  1 +
 ...-2015-5312-Another-entity-expansion-issue.patch | 39 ++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 meta/recipes-core/libxml/libxml2/0001-CVE-2015-5312-Another-entity-expansion-issue.patch
meta/recipes-core/libxml/libxml2.inc +1 -0
index a30f0b6..b9ce0f0 100644
@@ -34,6 +34,7 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
            file://0001-Fix-a-bug-on-name-parsing-at-the-end-of-current-inpu.patch \
            file://0001-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch \
            file://0001-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch \
+           file://0001-CVE-2015-5312-Another-entity-expansion-issue.patch \
           "
 
 BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/0001-CVE-2015-5312-Another-entity-expansion-issue.patch new file +39 -0
new file mode 100644
index 0000000..979618d
@@ -0,0 +1,39 @@
+From 69030714cde66d525a8884bda01b9e8f0abf8e1e Mon Sep 17 00:00:00 2001
+From: David Drysdale <[email protected]>
+Date: Fri, 20 Nov 2015 11:13:45 +0800
+Subject: [PATCH] CVE-2015-5312 Another entity expansion issue
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=756733
+It is one case where the code in place to detect entities expansions
+failed to exit when the situation was detected, leading to DoS
+Problem reported by Kostya Serebryany @ Google
+Patch provided by David Drysdale @ Google
+
+Upstream-Status: Backport
+
+CVE-2015-5312
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/parser.c b/parser.c
+index b7b6668..da6e729 100644
+--- a/parser.c
++++ b/parser.c
+@@ -2806,6 +2806,10 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
+ 			                      0, 0, 0);
+ 		ctxt->depth--;
+ 
++		if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
++		    (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
++		    goto int_error;
++
+ 		if (rep != NULL) {
+ 		    current = rep;
+ 		    while (*current != 0) { /* non input consuming loop */
+-- 
+2.3.5
+
Signature · 1 line
2.3.5
#10 lore raw
In reply to Armin Kuster

Hi Armin,

I got strange errors when apply the patches:

$ git am /tmp/jethro/*libxml2*
[snip]
Applying: libxml2: security fix CVE-2015-7500
/buildarea/lyang1/poky/.git/rebase-apply/patch:80: trailing whitespace.

/buildarea/lyang1/poky/.git/rebase-apply/patch:82: space before tab in indent.

           ((RAW != '/') || (NXT(1) != '>')) &&

/buildarea/lyang1/poky/.git/rebase-apply/patch:84: trailing whitespace.

/buildarea/lyang1/poky/.git/rebase-apply/patch:85: space before tab in indent.
attname = xmlParseAttribute2(ctxt, prefix, localname,
/buildarea/lyang1/poky/.git/rebase-apply/patch:86: space before tab in indent.

                                     &aprefix, &attvalue, &len, &alloc);

fatal: corrupt patch at line 300
Patch failed at 0008 libxml2: security fix CVE-2015-7500

Would you please put the patches to a repo ? so that I can fetch them ?

// Robert

Quoted 136 lines · Armin Kuster

From: Armin Kuster <[email protected]>

includes:
CVE-2015-7941-1
CVE-2015-7941-2

---
  meta/recipes-core/libxml/libxml2.inc               |  2 +
  ...top-parsing-on-entities-boundaries-errors.patch | 39 +++++++++++++++
  ...leanup-conditional-section-error-handling.patch | 56 ++++++++++++++++++++++
  3 files changed, 97 insertions(+)

create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch create mode 100644 meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch

meta/recipes-core/libxml/libxml2.inc +2 -0
index 1c3c37d..24b98a6 100644
@@ -21,6 +21,8 @@ SRC_URI = "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
             file://libxml-m4-use-pkgconfig.patch \
             file://configure.ac-fix-cross-compiling-warning.patch \
             file://0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch \
+           file://CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch \
+           file://CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch \
            "
 
  BINCONFIG = "${bindir}/xml2-config"
meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch new file +39 -0
new file mode 100644
index 0000000..11da9f9
@@ -0,0 +1,39 @@
+From a7dfab7411cbf545f359dd3157e5df1eb0e7ce31 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Mon, 23 Feb 2015 11:17:35 +0800
+Subject: [PATCH] Stop parsing on entities boundaries errors
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=744980
+
+There are times, like on unterminated entities that it's preferable to
+stop parsing, even if that means less error reporting. Entities are
+feeding the parser on further processing, and if they are ill defined
+then it's possible to get the parser to bug. Also do the same on
+Conditional Sections if the input is broken, as the structure of
+the document can't be guessed.
+
+Upstream-Status: Backport
+
+CVE-2015-7941-1
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/parser.c b/parser.c
+index a8d1b67..bbe97eb 100644
+--- a/parser.c
++++ b/parser.c
+@@ -5658,6 +5658,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
+ 	if (RAW != '>') {
+ 	    xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
+ 	            "xmlParseEntityDecl: entity %s not terminated\n", name);
++	    xmlStopParser(ctxt);
+ 	} else {
+ 	    if (input != ctxt->input) {
+ 		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+--
+2.3.5
+
meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch new file +56 -0
new file mode 100644
index 0000000..b7bd960
@@ -0,0 +1,56 @@
+From 9b8512337d14c8ddf662fcb98b0135f225a1c489 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Mon, 23 Feb 2015 11:29:20 +0800
+Subject: [PATCH] Cleanup conditional section error handling
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=744980
+
+The error handling of Conditional Section also need to be
+straightened as the structure of the document can't be
+guessed on a failure there and it's better to stop parsing
+as further errors are likely to be irrelevant.
+
+Upstream-Status: Backport
+
+CVE-2015-7941-2
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/parser.c b/parser.c
+index bbe97eb..fe603ac 100644
+--- a/parser.c
++++ b/parser.c
+@@ -6770,6 +6770,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
+ 	SKIP_BLANKS;
+ 	if (RAW != '[') {
+ 	    xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
++	    xmlStopParser(ctxt);
++	    return;
+ 	} else {
+ 	    if (ctxt->input->id != id) {
+ 		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+@@ -6830,6 +6832,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
+ 	SKIP_BLANKS;
+ 	if (RAW != '[') {
+ 	    xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
++	    xmlStopParser(ctxt);
++	    return;
+ 	} else {
+ 	    if (ctxt->input->id != id) {
+ 		xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+@@ -6885,6 +6889,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
+
+     } else {
+ 	xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
++	xmlStopParser(ctxt);
++	return;
+     }
+
+     if (RAW == 0)
+--
+2.3.5
+
author
#11 lore raw
Quoted 21 lines · Robert Yang

Hi Armin,

I got strange errors when apply the patches:

$ git am /tmp/jethro/*libxml2*
[snip]
Applying: libxml2: security fix CVE-2015-7500
/buildarea/lyang1/poky/.git/rebase-apply/patch:80: trailing whitespace.

/buildarea/lyang1/poky/.git/rebase-apply/patch:82: space before tab in indent.

           ((RAW != '/') || (NXT(1) != '>')) &&

/buildarea/lyang1/poky/.git/rebase-apply/patch:84: trailing whitespace.

/buildarea/lyang1/poky/.git/rebase-apply/patch:85: space before tab in indent.
attname = xmlParseAttribute2(ctxt, prefix, localname,
/buildarea/lyang1/poky/.git/rebase-apply/patch:86: space before tab in indent.

Quoted 5 lines
                                     &aprefix, &attvalue, &len, &alloc);

fatal: corrupt patch at line 300
Patch failed at 0008 libxml2: security fix CVE-2015-7500

Would you please put the patches to a repo ? so that I can fetch them ?

sure thing.

armin

Quoted 164 lines

// Robert

Quoted 160 lines · Armin Kuster

From: Armin Kuster <[email protected]>

includes:
CVE-2015-7941-1
CVE-2015-7941-2

---
  meta/recipes-core/libxml/libxml2.inc               |  2 +
  ...top-parsing-on-entities-boundaries-errors.patch | 39 +++++++++++++++
  ...leanup-conditional-section-error-handling.patch | 56
++++++++++++++++++++++
  3 files changed, 97 insertions(+)

create mode 100644
meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch

create mode 100644
meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch

meta/recipes-core/libxml/libxml2.inc +2 -0
index 1c3c37d..24b98a6 100644
@@ -21,6 +21,8 @@ SRC_URI =
 "ftp://xmlsoft.org/libxml2/libxml2-${PV}.tar.gz;name=libtar \
             file://libxml-m4-use-pkgconfig.patch \
             file://configure.ac-fix-cross-compiling-warning.patch \
 
 file://0001-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch \
+          
 file://CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch \
+          
file://CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch \
            "

BINCONFIG = "${bindir}/xml2-config"
diff --git a/meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch b/meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch

new file mode 100644
index 0000000..11da9f9
--- /dev/null
+++
b/meta/recipes-core/libxml/libxml2/CVE-2015-7941-1-Stop-parsing-on-entities-boundaries-errors.patch

meta/recipes-core/libxml/libxml2.inc +32 -0
@@ -0,0 +1,39 @@
+From a7dfab7411cbf545f359dd3157e5df1eb0e7ce31 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Mon, 23 Feb 2015 11:17:35 +0800
+Subject: [PATCH] Stop parsing on entities boundaries errors
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=744980
+
+There are times, like on unterminated entities that it's preferable to
+stop parsing, even if that means less error reporting. Entities are
+feeding the parser on further processing, and if they are ill defined
+then it's possible to get the parser to bug. Also do the same on
+Conditional Sections if the input is broken, as the structure of
+the document can't be guessed.
+
+Upstream-Status: Backport
+
+CVE-2015-7941-1
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/parser.c b/parser.c
+index a8d1b67..bbe97eb 100644
+--- a/parser.c
++++ b/parser.c
+@@ -5658,6 +5658,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
+     if (RAW != '>') {
+         xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
+                 "xmlParseEntityDecl: entity %s not terminated\n",

name);
++ xmlStopParser(ctxt);

meta/recipes-core/libxml/libxml2.inc +6 -0
+     } else {
+         if (input != ctxt->input) {
+         xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+--
+2.3.5
+

diff --git a/meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch b/meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch

new file mode 100644
index 0000000..b7bd960
--- /dev/null
+++
b/meta/recipes-core/libxml/libxml2/CVE-2015-7941-2-Cleanup-conditional-section-error-handling.patch

meta/recipes-core/libxml/libxml2.inc +27 -0
@@ -0,0 +1,56 @@
+From 9b8512337d14c8ddf662fcb98b0135f225a1c489 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <[email protected]>
+Date: Mon, 23 Feb 2015 11:29:20 +0800
+Subject: [PATCH] Cleanup conditional section error handling
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=744980
+
+The error handling of Conditional Section also need to be
+straightened as the structure of the document can't be
+guessed on a failure there and it's better to stop parsing
+as further errors are likely to be irrelevant.
+
+Upstream-Status: Backport
+
+CVE-2015-7941-2
+
+Signed-off-by: Armin Kuster <[email protected]>
+
+---
+ parser.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/parser.c b/parser.c
+index bbe97eb..fe603ac 100644
+--- a/parser.c
++++ b/parser.c
+@@ -6770,6 +6770,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr

ctxt) {

meta/recipes-core/libxml/libxml2.inc +9 -0
+     SKIP_BLANKS;
+     if (RAW != '[') {
+         xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
++        xmlStopParser(ctxt);
++        return;
+     } else {
+         if (ctxt->input->id != id) {
+         xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+@@ -6830,6 +6832,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr

ctxt) {

meta/recipes-core/libxml/libxml2.inc +9 -0
+     SKIP_BLANKS;
+     if (RAW != '[') {
+         xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
++        xmlStopParser(ctxt);
++        return;
+     } else {
+         if (ctxt->input->id != id) {
+         xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+@@ -6885,6 +6889,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr

ctxt) {

meta/recipes-core/libxml/libxml2.inc +11 -0
+
+     } else {
+     xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
++    xmlStopParser(ctxt);
++    return;
+     }
+
+     if (RAW == 0)
+--
+2.3.5
+