From c8bb544cf113e1231e9f1f391bd70a5c55480453 Mon Sep 17 00:00:00 2001 From: Raphaël Hertzog Date: Tue, 25 Aug 2015 23:25:29 +0200 Subject: Fix 3 security issues by adding 4 patches - CVE-2015-1819: The xmlreader in libxml allows remote attackers to cause a denial of service (memory consumption) via crafted XML data, related to an XML Entity Expansion (XEE) attack. Closes: #782782 - Out-of-bounds access when parsing unclosed HTML comment https://bugzilla.gnome.org/show_bug.cgi?id=746048 Closes: #782985 - Out-of-bounds memory access https://bugzilla.gnome.org/show_bug.cgi?id=744980 Closes: #783010 --- debian/changelog | 8 + ...-missing-entities-after-CVE-2014-3660-fix.patch | 27 ---- ...top-parsing-on-entities-boundaries-errors.patch | 28 ++++ ...leanup-conditional-section-error-handling.patch | 45 ++++++ debian/patches/0058-Fix-upstream-bug-299127.patch | 99 ++++++++++++ ...19-Enforce-the-reader-to-run-in-constant-.patch | 172 +++++++++++++++++++++ debian/patches/series | 4 + 7 files changed, 356 insertions(+), 27 deletions(-) delete mode 100644 debian/patches/0003-Fix-missing-entities-after-CVE-2014-3660-fix.patch create mode 100644 debian/patches/0056-Stop-parsing-on-entities-boundaries-errors.patch create mode 100644 debian/patches/0057-Cleanup-conditional-section-error-handling.patch create mode 100644 debian/patches/0058-Fix-upstream-bug-299127.patch create mode 100644 debian/patches/0059-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index dc762be..78e557c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,14 @@ libxml2 (2.9.2+really2.9.1+dfsg1-0.1) unstable; urgency=medium again. Closes: #766884 * Restore all patches available in 2.9.1+dfsg1-5 in stretch, ensuring CVE-2014-3660 is fixed too. + * Fix 3 security issues by adding 4 patches: + - CVE-2015-1819: The xmlreader in libxml allows remote attackers to cause + a denial of service (memory consumption) via crafted XML data, related to + an XML Entity Expansion (XEE) attack. Closes: #782782 + - Out-of-bounds access when parsing unclosed HTML comment + https://bugzilla.gnome.org/show_bug.cgi?id=746048 Closes: #782985 + - Out-of-bounds memory access + https://bugzilla.gnome.org/show_bug.cgi?id=744980 Closes: #783010 -- Raphaël Hertzog Tue, 25 Aug 2015 22:31:29 +0200 diff --git a/debian/patches/0003-Fix-missing-entities-after-CVE-2014-3660-fix.patch b/debian/patches/0003-Fix-missing-entities-after-CVE-2014-3660-fix.patch deleted file mode 100644 index 2afe1f0..0000000 --- a/debian/patches/0003-Fix-missing-entities-after-CVE-2014-3660-fix.patch +++ /dev/null @@ -1,27 +0,0 @@ -From: Daniel Veillard -Date: Thu, 23 Oct 2014 11:35:36 +0800 -Subject: Fix missing entities after CVE-2014-3660 fix - -For https://bugzilla.gnome.org/show_bug.cgi?id=738805 - -The fix for CVE-2014-3660 introduced a regression in some case -where entity substitution is required and the entity is used -first in anotther entity referenced from an attribute value ---- - parser.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/parser.c b/parser.c -index 1d93967..313ff28 100644 ---- a/parser.c -+++ b/parser.c -@@ -7235,7 +7235,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { - * far more secure as the parser will only process data coming from - * the document entity by default. - */ -- if ((ent->checked == 0) && -+ if (((ent->checked == 0) || -+ ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) && - ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) || - (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) { - unsigned long oldnbent = ctxt->nbentities; diff --git a/debian/patches/0056-Stop-parsing-on-entities-boundaries-errors.patch b/debian/patches/0056-Stop-parsing-on-entities-boundaries-errors.patch new file mode 100644 index 0000000..d0d9a79 --- /dev/null +++ b/debian/patches/0056-Stop-parsing-on-entities-boundaries-errors.patch @@ -0,0 +1,28 @@ +From: Daniel Veillard +Date: Mon, 23 Feb 2015 11:17:35 +0800 +Subject: 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. +--- + parser.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/parser.c b/parser.c +index c187327..f96cd5f 100644 +--- a/parser.c ++++ b/parser.c +@@ -5653,6 +5653,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, diff --git a/debian/patches/0057-Cleanup-conditional-section-error-handling.patch b/debian/patches/0057-Cleanup-conditional-section-error-handling.patch new file mode 100644 index 0000000..27b5e2e --- /dev/null +++ b/debian/patches/0057-Cleanup-conditional-section-error-handling.patch @@ -0,0 +1,45 @@ +From: Daniel Veillard +Date: Mon, 23 Feb 2015 11:29:20 +0800 +Subject: 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. +--- + parser.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/parser.c b/parser.c +index f96cd5f..5342cdb 100644 +--- a/parser.c ++++ b/parser.c +@@ -6765,6 +6765,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, +@@ -6825,6 +6827,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, +@@ -6880,6 +6884,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { + + } else { + xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL); ++ xmlStopParser(ctxt); ++ return; + } + + if (RAW == 0) diff --git a/debian/patches/0058-Fix-upstream-bug-299127.patch b/debian/patches/0058-Fix-upstream-bug-299127.patch new file mode 100644 index 0000000..b42b8ee --- /dev/null +++ b/debian/patches/0058-Fix-upstream-bug-299127.patch @@ -0,0 +1,99 @@ +From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= +Date: Tue, 25 Aug 2015 23:17:02 +0200 +Subject: Fix upstream bug 299127 + +Out of bound access when parsing unclosed comment + +Author: Francois Chagnon +Bug: https://bugzilla.gnome.org/show_bug.cgi?id=746048 +--- + HTMLparser.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +diff --git a/HTMLparser.c b/HTMLparser.c +index 8d34fd1..69ccfd3 100644 +--- a/HTMLparser.c ++++ b/HTMLparser.c +@@ -3245,13 +3245,20 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { + ctxt->instate = state; + return; + } ++ if ((ctxt->input->end - ctxt->input->cur) < 3) { ++ ctxt->instate = XML_PARSER_EOF; ++ htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, ++ "Comment not terminated\n", NULL, NULL); ++ xmlFree(buf); ++ return; ++ } + q = CUR_CHAR(ql); + NEXTL(ql); + r = CUR_CHAR(rl); + NEXTL(rl); + cur = CUR_CHAR(l); + len = 0; +- while (IS_CHAR(cur) && ++ while (((ctxt->input->end - ctxt->input->cur) > 0) && IS_CHAR(cur) && + ((cur != '>') || + (r != '-') || (q != '-'))) { + if (len + 5 >= size) { +@@ -3281,7 +3288,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { + } + } + buf[len] = 0; +- if (!IS_CHAR(cur)) { ++ if (!(ctxt->input->end - ctxt->input->cur) || !IS_CHAR(cur)) { + htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, + "Comment not terminated \n