Blame SOURCES/libxslt-1.1.32-CVE-2019-11068.patch

7e273a
From e03553605b45c88f0b4b2980adfbbb8f6fca2fd6 Mon Sep 17 00:00:00 2001
7e273a
From: Nick Wellnhofer <wellnhofer@aevum.de>
7e273a
Date: Sun, 24 Mar 2019 09:51:39 +0100
7e273a
Subject: [PATCH] Fix security framework bypass
7e273a
7e273a
xsltCheckRead and xsltCheckWrite return -1 in case of error but callers
7e273a
don't check for this condition and allow access. With a specially
7e273a
crafted URL, xsltCheckRead could be tricked into returning an error
7e273a
because of a supposedly invalid URL that would still be loaded
7e273a
succesfully later on.
7e273a
7e273a
Fixes #12.
7e273a
7e273a
Thanks to Felix Wilhelm for the report.
7e273a
---
7e273a
 libxslt/documents.c | 18 ++++++++++--------
7e273a
 libxslt/imports.c   |  9 +++++----
7e273a
 libxslt/transform.c |  9 +++++----
7e273a
 libxslt/xslt.c      |  9 +++++----
7e273a
 4 files changed, 25 insertions(+), 20 deletions(-)
7e273a
7e273a
diff --git a/libxslt/documents.c b/libxslt/documents.c
7e273a
index 3f3a7312..4aad11bb 100644
7e273a
--- a/libxslt/documents.c
7e273a
+++ b/libxslt/documents.c
7e273a
@@ -296,10 +296,11 @@ xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
7e273a
 	int res;
7e273a
 
7e273a
 	res = xsltCheckRead(ctxt->sec, ctxt, URI);
7e273a
-	if (res == 0) {
7e273a
-	    xsltTransformError(ctxt, NULL, NULL,
7e273a
-		 "xsltLoadDocument: read rights for %s denied\n",
7e273a
-			     URI);
7e273a
+	if (res <= 0) {
7e273a
+            if (res == 0)
7e273a
+                xsltTransformError(ctxt, NULL, NULL,
7e273a
+                     "xsltLoadDocument: read rights for %s denied\n",
7e273a
+                                 URI);
7e273a
 	    return(NULL);
7e273a
 	}
7e273a
     }
7e273a
@@ -372,10 +373,11 @@ xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
7e273a
 	int res;
7e273a
 
7e273a
 	res = xsltCheckRead(sec, NULL, URI);
7e273a
-	if (res == 0) {
7e273a
-	    xsltTransformError(NULL, NULL, NULL,
7e273a
-		 "xsltLoadStyleDocument: read rights for %s denied\n",
7e273a
-			     URI);
7e273a
+	if (res <= 0) {
7e273a
+            if (res == 0)
7e273a
+                xsltTransformError(NULL, NULL, NULL,
7e273a
+                     "xsltLoadStyleDocument: read rights for %s denied\n",
7e273a
+                                 URI);
7e273a
 	    return(NULL);
7e273a
 	}
7e273a
     }
7e273a
diff --git a/libxslt/imports.c b/libxslt/imports.c
7e273a
index 874870cc..3783b247 100644
7e273a
--- a/libxslt/imports.c
7e273a
+++ b/libxslt/imports.c
7e273a
@@ -130,10 +130,11 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
7e273a
 	int secres;
7e273a
 
7e273a
 	secres = xsltCheckRead(sec, NULL, URI);
7e273a
-	if (secres == 0) {
7e273a
-	    xsltTransformError(NULL, NULL, NULL,
7e273a
-		 "xsl:import: read rights for %s denied\n",
7e273a
-			     URI);
7e273a
+	if (secres <= 0) {
7e273a
+            if (secres == 0)
7e273a
+                xsltTransformError(NULL, NULL, NULL,
7e273a
+                     "xsl:import: read rights for %s denied\n",
7e273a
+                                 URI);
7e273a
 	    goto error;
7e273a
 	}
7e273a
     }
7e273a
diff --git a/libxslt/transform.c b/libxslt/transform.c
7e273a
index 13793914..0636dbd0 100644
7e273a
--- a/libxslt/transform.c
7e273a
+++ b/libxslt/transform.c
7e273a
@@ -3493,10 +3493,11 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
7e273a
      */
7e273a
     if (ctxt->sec != NULL) {
7e273a
 	ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
7e273a
-	if (ret == 0) {
7e273a
-	    xsltTransformError(ctxt, NULL, inst,
7e273a
-		 "xsltDocumentElem: write rights for %s denied\n",
7e273a
-			     filename);
7e273a
+	if (ret <= 0) {
7e273a
+            if (ret == 0)
7e273a
+                xsltTransformError(ctxt, NULL, inst,
7e273a
+                     "xsltDocumentElem: write rights for %s denied\n",
7e273a
+                                 filename);
7e273a
 	    xmlFree(URL);
7e273a
 	    xmlFree(filename);
7e273a
 	    return;
7e273a
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
7e273a
index 780a5ad7..a234eb79 100644
7e273a
--- a/libxslt/xslt.c
7e273a
+++ b/libxslt/xslt.c
7e273a
@@ -6763,10 +6763,11 @@ xsltParseStylesheetFile(const xmlChar* filename) {
7e273a
 	int res;
7e273a
 
7e273a
 	res = xsltCheckRead(sec, NULL, filename);
7e273a
-	if (res == 0) {
7e273a
-	    xsltTransformError(NULL, NULL, NULL,
7e273a
-		 "xsltParseStylesheetFile: read rights for %s denied\n",
7e273a
-			     filename);
7e273a
+	if (res <= 0) {
7e273a
+            if (res == 0)
7e273a
+                xsltTransformError(NULL, NULL, NULL,
7e273a
+                     "xsltParseStylesheetFile: read rights for %s denied\n",
7e273a
+                                 filename);
7e273a
 	    return(NULL);
7e273a
 	}
7e273a
     }
7e273a
-- 
7e273a
2.24.1
7e273a