0022-fix-cve-2019-11068.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From e03553605b45c88f0b4b2980adfbbb8f6fca2fd6 Mon Sep 17 00:00:00 2001
  2. From: Nick Wellnhofer <wellnhofer@aevum.de>
  3. Date: Sun, 24 Mar 2019 09:51:39 +0100
  4. Subject: [PATCH] Fix security framework bypass
  5. xsltCheckRead and xsltCheckWrite return -1 in case of error but callers
  6. don't check for this condition and allow access. With a specially
  7. crafted URL, xsltCheckRead could be tricked into returning an error
  8. because of a supposedly invalid URL that would still be loaded
  9. succesfully later on.
  10. Fixes #12.
  11. Thanks to Felix Wilhelm for the report.
  12. ---
  13. libxslt/documents.c | 18 ++++++++++--------
  14. libxslt/imports.c | 9 +++++----
  15. libxslt/transform.c | 9 +++++----
  16. libxslt/xslt.c | 9 +++++----
  17. 4 files changed, 25 insertions(+), 20 deletions(-)
  18. --- a/libxslt/documents.c
  19. +++ b/libxslt/documents.c
  20. @@ -296,10 +296,11 @@ xsltLoadDocument(xsltTransformContextPtr
  21. int res;
  22. res = xsltCheckRead(ctxt->sec, ctxt, URI);
  23. - if (res == 0) {
  24. - xsltTransformError(ctxt, NULL, NULL,
  25. - "xsltLoadDocument: read rights for %s denied\n",
  26. - URI);
  27. + if (res <= 0) {
  28. + if (res == 0)
  29. + xsltTransformError(ctxt, NULL, NULL,
  30. + "xsltLoadDocument: read rights for %s denied\n",
  31. + URI);
  32. return(NULL);
  33. }
  34. }
  35. @@ -372,10 +373,11 @@ xsltLoadStyleDocument(xsltStylesheetPtr
  36. int res;
  37. res = xsltCheckRead(sec, NULL, URI);
  38. - if (res == 0) {
  39. - xsltTransformError(NULL, NULL, NULL,
  40. - "xsltLoadStyleDocument: read rights for %s denied\n",
  41. - URI);
  42. + if (res <= 0) {
  43. + if (res == 0)
  44. + xsltTransformError(NULL, NULL, NULL,
  45. + "xsltLoadStyleDocument: read rights for %s denied\n",
  46. + URI);
  47. return(NULL);
  48. }
  49. }
  50. --- a/libxslt/imports.c
  51. +++ b/libxslt/imports.c
  52. @@ -131,10 +131,11 @@ xsltParseStylesheetImport(xsltStylesheet
  53. int secres;
  54. secres = xsltCheckRead(sec, NULL, URI);
  55. - if (secres == 0) {
  56. - xsltTransformError(NULL, NULL, NULL,
  57. - "xsl:import: read rights for %s denied\n",
  58. - URI);
  59. + if (secres <= 0) {
  60. + if (secres == 0)
  61. + xsltTransformError(NULL, NULL, NULL,
  62. + "xsl:import: read rights for %s denied\n",
  63. + URI);
  64. goto error;
  65. }
  66. }
  67. --- a/libxslt/transform.c
  68. +++ b/libxslt/transform.c
  69. @@ -3416,10 +3416,11 @@ xsltDocumentElem(xsltTransformContextPtr
  70. */
  71. if (ctxt->sec != NULL) {
  72. ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
  73. - if (ret == 0) {
  74. - xsltTransformError(ctxt, NULL, inst,
  75. - "xsltDocumentElem: write rights for %s denied\n",
  76. - filename);
  77. + if (ret <= 0) {
  78. + if (ret == 0)
  79. + xsltTransformError(ctxt, NULL, inst,
  80. + "xsltDocumentElem: write rights for %s denied\n",
  81. + filename);
  82. xmlFree(URL);
  83. xmlFree(filename);
  84. return;
  85. --- a/libxslt/xslt.c
  86. +++ b/libxslt/xslt.c
  87. @@ -6729,10 +6729,11 @@ xsltParseStylesheetFile(const xmlChar* f
  88. int res;
  89. res = xsltCheckRead(sec, NULL, filename);
  90. - if (res == 0) {
  91. - xsltTransformError(NULL, NULL, NULL,
  92. - "xsltParseStylesheetFile: read rights for %s denied\n",
  93. - filename);
  94. + if (res <= 0) {
  95. + if (res == 0)
  96. + xsltTransformError(NULL, NULL, NULL,
  97. + "xsltParseStylesheetFile: read rights for %s denied\n",
  98. + filename);
  99. return(NULL);
  100. }
  101. }