Skip to content

Commit c792706

Browse files
authored
Merge pull request #163 from eXist-db/DP-production-practices
add info on hardening production systems
2 parents 42b8d0e + 5b30f70 commit c792706

File tree

1 file changed

+58
-18
lines changed

1 file changed

+58
-18
lines changed

src/main/xar-resources/data/production_good_practice.xml

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<productname>eXist-db – Open Source Native XML Database</productname>
55
<title>Production Good Practice</title>
66
<orgname>The eXist-db Project</orgname>
7-
<date>September 2009</date>
7+
<date>2017-12-20</date>
88
<author>
99
<firstname>Adam</firstname>
1010
<surname>Retter</surname>
@@ -22,13 +22,13 @@
2222
<section>
2323
<title>The Server</title>
2424
<para>Ensure that your server is up-to-date and patched with any necessary security fixes.</para>
25-
<para>eXist-db is written in Java - so for performance and security reasons, please ensure that you have the latest and greatest Java JDK release installed. At present this is the 1.6 <!--1.7--> branch, details of the latest version can always be found here - <ulink url="http://java.sun.com">http://java.sun.com</ulink>
25+
<para>eXist-db is written in Java - so for performance and security reasons, please ensure that you have the latest and greatest Java JDK release that is compatible with your version of eXist. The latest version can always be found here at: <ulink url="http://java.sun.com">http://java.sun.com</ulink> and the recommended major version for a given eXist release can be found at: <ulink url="https://bintray.com/existdb/releases/exist#read">https://bintray.com/existdb/releases/exist#read</ulink>
2626
</para>
2727
</section>
2828
<section>
2929
<title>Install from Source or Release?</title>
3030
<para>Most users will install an officially released version of eXist-db on their production systems, usually this is perfectly fine. However there can be advantages to installing eXist-db from source code on a production system.</para>
31-
<para>eXist-db may be installed from source code to a production system in one of two ways -</para>
31+
<para>eXist-db may be installed from source code to a production system in one of two ways:</para>
3232
<variablelist>
3333
<varlistentry>
3434
<term>via Local Build Machine (preferred)</term>
@@ -43,7 +43,7 @@
4343
</listitem>
4444
</varlistentry>
4545
</variablelist>
46-
<para>If you install eXist-db from source code, some advantages might be -</para>
46+
<para>If you install eXist-db from source code, some advantages might be:</para>
4747
<variablelist>
4848
<varlistentry>
4949
<term>patches</term>
@@ -68,7 +68,7 @@
6868
</para>
6969
<section>
7070
<title>Upgrading</title>
71-
<para>If you are upgrading the version of eXist-db that you use in your production system, please always follow these two points -</para>
71+
<para>If you are upgrading the version of eXist-db that you use in your production system, please always follow these two points:</para>
7272
<orderedlist>
7373
<listitem>
7474
<para>
@@ -83,7 +83,7 @@
8383
</section>
8484
<section>
8585
<title>Configuring eXist</title>
86-
<para>There are four main things to consider here -</para>
86+
<para>There are four main things to consider here:</para>
8787
<orderedlist>
8888
<listitem>
8989
<para>
@@ -106,15 +106,15 @@
106106
<title>Permissions</title>
107107
<section>
108108
<title>eXist-db Permissions</title>
109-
<para>At present eXist-db ships with fairly relaxed permissions to facilitate rapid application development, but for production systems these should be constrained -</para>
109+
<para>At present eXist-db ships with fairly relaxed permissions to facilitate rapid application development, but for production systems these should be constrained:</para>
110110
<variablelist>
111111
<varlistentry>
112112
<term>admin account</term>
113113
<listitem><para>The password of the admin account is blank by default! Ensure that you set a decent password.</para></listitem>
114114
</varlistentry>
115115
<varlistentry>
116116
<term>default-permissions</term>
117-
<listitem><para>The default permissions for creating resources and collections in eXist-db are set in conf.xml. The current settings are fairly sane, but you may like to improve on them for your own application security.</para></listitem>
117+
<listitem><para>The default permissions for creating resources and collections in eXist-db are set in <filename>conf.xml</filename>. The current settings are fairly sane, but you may like to improve on them for your own application security.</para></listitem>
118118
</varlistentry>
119119
<varlistentry>
120120
<term>/db permissions</term>
@@ -128,22 +128,62 @@
128128
<section>
129129
<title>Operating System Permissions</title>
130130
<para>eXist-db should be deployed and configured to run whilst following the security best practices of the operating system on which it is deployed.</para>
131-
<para>Typically we would recommend creating an "exist" user account and "exist" user group with no login privileges (i.e. no shell and empty password), changing the permissions of the eXist-db installation to be owned by that user and group, and then running eXist-db using those credentials. An example of this on OpenSolaris might be -</para>
131+
<para>Typically we would recommend creating an "exist" user account and "exist" user group with no login privileges (i.e. no shell and empty password), changing the permissions of the eXist-db installation to be owned by that user and group, and then running eXist-db using those credentials. An example of this on OpenSolaris might be:</para>
132132
<programlisting language="bash">
133133
$ pfexec groupadd exist
134134
$ pfexec useradd -c "eXist Native XML Database" -d /home/exist -g exist -m exist
135-
$ pfexec chown -R exist:exist /opt/eXist
135+
$ pfexec chown -R exist:exist /opt/eXist
136136
</programlisting>
137137
</section>
138138
</section>
139139
<section>
140140
<title>Attack Surface</title>
141-
<para>For any live application it is recognised best practice to keep the attack surface of the application as small as possible. There are two aspects to this -</para>
141+
<para>For any live application it is recognised best practice to keep the attack surface of the application as small as possible. There are three aspects to this:</para>
142142
<orderedlist>
143-
<listitem><para>Reducing the application itself to the absolute essentials.</para></listitem>
144-
<listitem><para>Limiting access routes to the application.</para></listitem>
143+
<listitem>
144+
<para>Limiting means of arbitrary code execution.</para>
145+
</listitem>
146+
<listitem>
147+
<para>Reducing the application itself to the absolute essentials.</para>
148+
</listitem>
149+
<listitem>
150+
<para>Limiting access routes to the application.</para>
151+
</listitem>
145152
</orderedlist>
146-
<para>eXist-db is no exception and should be configured for your production systems so that it provides only what you need and no more. For example, the majority of applications will be unlikely to require the WebDAV or SOAP Admin features for operation in a live environment, and as such these and other services can be disabled easily. Things to consider for a live environment -</para>
153+
<para>eXist-db is no exception and should be configured for your production systems so that it provides only what you need and no more. For example, the majority of applications will be unlikely to require the WebDAV or SOAP Admin features for operation in a live environment, and as such these and other services can be disabled easily.</para>
154+
<para>Means for anonymous users to execute arbitrary code require special attention. There are two means of code execution in eXist, which make sense during development, but should be reconsidered for production systems.</para>
155+
<variablelist>
156+
<varlistentry>
157+
<term>Java binding</term>
158+
<listitem>
159+
<para>The ability to execute java code from inside the XQuery processor is disabled by default in the instances' <filename>conf.xml</filename>.<programlisting language="xml">&lt;xquery enable-java-binding="no" .../&gt;</programlisting> It is strongly recommended to keep it disabled on production systems.</para>
160+
</listitem>
161+
</varlistentry>
162+
<varlistentry>
163+
<term>REST server</term>
164+
<listitem><para>We recommend to prevent eXist's REST server from directly recieving web requests, and use URL Rewriting to control code execution via URL instead. This feature is enabled by default in <filename>$EXIST_HOME/webapp/WEB-INF/web.xml</filename>. Changing the param-value to true, allows you to filter request via your own XQuery controller.</para>
165+
<programlisting language="xml">&lt;init-param&gt;
166+
&lt;param-name&gt;hidden&lt;/param-name&gt;
167+
&lt;param-value&gt;true&lt;/param-value&gt;
168+
&lt;/init-param&gt;</programlisting>
169+
<para>The following options allow a more fine-grained control over aspects of remote code execution:</para>
170+
</listitem>
171+
</varlistentry>
172+
<varlistentry>
173+
<term>XQuery submissions</term> <listitem><para>We recommend to restrict the REST servers ability to execute XQuery code to authenticated users, by modifying:<filename>$EXIST_HOME/webapp/WEB-INF/web.xml</filename>.</para>
174+
<programlisting language="xml">&lt;init-param&gt;
175+
&lt;param-name&gt;xquery-submission&lt;/param-name&gt; &lt;param-value&gt;authenticated&lt;/param-value&gt;
176+
&lt;/init-param&gt;</programlisting></listitem>
177+
</varlistentry>
178+
<varlistentry>
179+
<term>XUpdate statements</term>
180+
<listitem><para>In addtion, we recommend to restrict the REST servers ability to execute XUpdate statements, because of the sensitive nature of update operation. Simply modify <filename>$EXIST_HOME/webapp/WEB-INF/web.xml</filename>by changing the param-value from enabled to disabled.</para>
181+
<programlisting language="xml">&lt;init-param&gt;
182+
&lt;param-name&gt;xupdate-submission&lt;/param-name&gt; &lt;param-value&gt;disabled&lt;/param-value&gt;
183+
&lt;/init-param&gt;</programlisting></listitem>
184+
</varlistentry>
185+
</variablelist>
186+
<para>Further considerations for a live environment:</para>
147187
<variablelist>
148188
<varlistentry>
149189
<term>Standalone mode</term>
@@ -155,7 +195,7 @@ $ pfexec chown -R exist:exist /opt/eXist
155195
</varlistentry>
156196
<varlistentry>
157197
<term>Extension Modules</term>
158-
<listitem><para>eXist-db loads several XQuery and Index extension modules by default. You should modify the builtin-modules section of conf.xml, to <emphasis>ONLY</emphasis> load what you need for your application.</para></listitem>
198+
<listitem><para>eXist-db loads several XQuery and Index extension modules by default. You should modify the builtin-modules section of <filename>conf.xml</filename>, to <emphasis>ONLY</emphasis> load what you need for your application.</para></listitem>
159199
</varlistentry>
160200
</variablelist>
161201
</section>
@@ -169,7 +209,7 @@ $ pfexec chown -R exist:exist /opt/eXist
169209
</varlistentry>
170210
<varlistentry>
171211
<term>cacheSize and collectionCache</term>
172-
<listitem><para>These two settings in the db-connection of conf.xml should be adjusted appropriately based on your -Xmx setting (above). See the <ulink url="tuning.xml">tuning guide</ulink> for advice on sensible values.</para></listitem>
212+
<listitem><para>These two settings in the db-connection of <filename>conf.xml</filename> should be adjusted appropriately based on your -Xmx setting (above). See the <ulink url="tuning.xml">tuning guide</ulink> for advice on sensible values.</para></listitem>
173213
</varlistentry>
174214
<varlistentry>
175215
<term>disk space</term>
@@ -179,7 +219,7 @@ $ pfexec chown -R exist:exist /opt/eXist
179219
</section>
180220
<section>
181221
<title>Performance</title>
182-
<para>It has been reported by large scale users that keeping the eXist-db application, database data files and database journal on separate disks connected to different I/O channels can have a positive impact on performance. The location of the database data files and database journal can be changed in conf.xml.</para>
222+
<para>It has been reported by large scale users that keeping the eXist-db application, database data files and database journal on separate disks connected to different I/O channels can have a positive impact on performance. The location of the database data files and database journal can be changed in <filename>conf.xml</filename>.</para>
183223
</section>
184224
</section>
185225
<section>
@@ -192,7 +232,7 @@ $ pfexec chown -R exist:exist /opt/eXist
192232
<listitem><para>Differential database backup.</para></listitem>
193233
<listitem><para>Snapshot of the database data files.</para></listitem>
194234
</orderedlist>
195-
<para>Each of these backup mechanisms is schedulable either with eXist-db or with your operating system scheduler. See the <ulink url="backup.xml">backup</ulink> page and conf.xml for further details.</para>
235+
<para>Each of these backup mechanisms is schedulable either with eXist-db or with your operating system scheduler. See the <ulink url="backup.xml">backup</ulink> page and <filename>conf.xml</filename> for further details.</para>
196236
</section>
197237
<section>
198238
<title>Web Deployments</title>

0 commit comments

Comments
 (0)