From a4f34c99a3c3315d71ce0e46967b70eda6395664 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 17 Jan 2018 14:36:30 -0500
Subject: [PATCH] Workarounds for CVE-2017-12629. - Thanks to Jason Cooper for
 the patch.

---
 solr.bat                                  | 2 +-
 solr.sh                                   | 2 +-
 solr/vufind/authority/conf/solrconfig.xml | 5 ++++-
 solr/vufind/biblio/conf/solrconfig.xml    | 3 +++
 solr/vufind/reserves/conf/solrconfig.xml  | 3 +++
 solr/vufind/website/conf/solrconfig.xml   | 3 +++
 6 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/solr.bat b/solr.bat
index e4a16c91749..eb6c9b4a403 100644
--- a/solr.bat
+++ b/solr.bat
@@ -80,7 +80,7 @@ if not "!%SOLR_PORT%!"=="!!" goto solrportset
 set SOLR_PORT=8080
 :solrportset
 
-call %SOLR_BIN%\solr.cmd %1 %SOLR_ADDITIONAL_START_OPTIONS% -p %SOLR_PORT% -s %SOLR_HOME% -m %SOLR_HEAP% -a "-Dsolr.log=%SOLR_LOGS_DIR% %SOLR_ADDITIONAL_JVM_OPTIONS%"
+call %SOLR_BIN%\solr.cmd %1 %SOLR_ADDITIONAL_START_OPTIONS% -p %SOLR_PORT% -s %SOLR_HOME% -m %SOLR_HEAP% -a "-Ddisable.configEdit=true -Dsolr.log=%SOLR_LOGS_DIR% %SOLR_ADDITIONAL_JVM_OPTIONS%"
 goto end
 
 :usage
diff --git a/solr.sh b/solr.sh
index 49fe26e9a28..c26ca45dd86 100755
--- a/solr.sh
+++ b/solr.sh
@@ -81,4 +81,4 @@ then
 fi
 
 export SOLR_LOGS_DIR=$SOLR_LOGS_DIR
-"$SOLR_BIN/solr" "$1" ${SOLR_ADDITIONAL_START_OPTIONS} -p "$SOLR_PORT" -s "$SOLR_HOME" -m "$SOLR_HEAP" -a "-Dsolr.log=$SOLR_LOGS_DIR $SOLR_ADDITIONAL_JVM_OPTIONS"
+"$SOLR_BIN/solr" "$1" ${SOLR_ADDITIONAL_START_OPTIONS} -p "$SOLR_PORT" -s "$SOLR_HOME" -m "$SOLR_HEAP" -a "-Ddisable.configEdit=true -Dsolr.log=$SOLR_LOGS_DIR $SOLR_ADDITIONAL_JVM_OPTIONS"
diff --git a/solr/vufind/authority/conf/solrconfig.xml b/solr/vufind/authority/conf/solrconfig.xml
index 30cbc48edb9..7adca00eec4 100644
--- a/solr/vufind/authority/conf/solrconfig.xml
+++ b/solr/vufind/authority/conf/solrconfig.xml
@@ -550,7 +550,10 @@
   <queryResponseWriter name="xslt" class="org.apache.solr.response.XSLTResponseWriter">
     <int name="xsltCacheLifetimeSeconds">5</int>
   </queryResponseWriter> 
-    
+
+  <!-- Mitigate CVE-2017-12629 -->
+  <queryParser name="xmlparser" class="solr.ExtendedDismaxQParserPlugin"/>
+
   <!-- config for the admin interface --> 
   <admin>
     <defaultQuery>shakespeare</defaultQuery>
diff --git a/solr/vufind/biblio/conf/solrconfig.xml b/solr/vufind/biblio/conf/solrconfig.xml
index c02fc03eec3..4bfbd631875 100644
--- a/solr/vufind/biblio/conf/solrconfig.xml
+++ b/solr/vufind/biblio/conf/solrconfig.xml
@@ -707,6 +707,9 @@
     <int name="xsltCacheLifetimeSeconds">5</int>
   </queryResponseWriter>
 
+  <!-- Mitigate CVE-2017-12629 -->
+  <queryParser name="xmlparser" class="solr.ExtendedDismaxQParserPlugin"/>
+
   <!-- config for the admin interface -->
   <admin>
     <defaultQuery>shakespeare</defaultQuery>
diff --git a/solr/vufind/reserves/conf/solrconfig.xml b/solr/vufind/reserves/conf/solrconfig.xml
index 0522458b0fd..a6f1642d8e7 100644
--- a/solr/vufind/reserves/conf/solrconfig.xml
+++ b/solr/vufind/reserves/conf/solrconfig.xml
@@ -555,6 +555,9 @@
     <int name="xsltCacheLifetimeSeconds">5</int>
   </queryResponseWriter> 
     
+  <!-- Mitigate CVE-2017-12629 -->
+  <queryParser name="xmlparser" class="solr.ExtendedDismaxQParserPlugin"/>
+
   <!-- config for the admin interface --> 
   <admin>
     <defaultQuery>shakespeare</defaultQuery>
diff --git a/solr/vufind/website/conf/solrconfig.xml b/solr/vufind/website/conf/solrconfig.xml
index 57c5bbe09e8..e8d5bf9efa9 100644
--- a/solr/vufind/website/conf/solrconfig.xml
+++ b/solr/vufind/website/conf/solrconfig.xml
@@ -644,6 +644,9 @@
     <int name="xsltCacheLifetimeSeconds">5</int>
   </queryResponseWriter>
 
+  <!-- Mitigate CVE-2017-12629 -->
+  <queryParser name="xmlparser" class="solr.ExtendedDismaxQParserPlugin"/>
+
   <!-- config for the admin interface -->
   <admin>
     <defaultQuery>shakespeare</defaultQuery>
-- 
GitLab