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

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