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