summaryrefslogtreecommitdiff
path: root/doc/source/config.rst
diff options
context:
space:
mode:
authorConnor Carr2017-10-08 17:06:55 +0100
committerjvoisin2017-10-08 18:06:55 +0200
commit21e6837c1c8442eb01e069b87a01e5996d41f2e9 (patch)
treef97931aef6ea060a9d761c4acb62d6d3e9a6eaa2 /doc/source/config.rst
parent99f18f7818f8f3ee354c78276d7cd981312c7d43 (diff)
Grammar/Punctuation changes (#29)
Diffstat (limited to 'doc/source/config.rst')
-rw-r--r--doc/source/config.rst74
1 files changed, 37 insertions, 37 deletions
diff --git a/doc/source/config.rst b/doc/source/config.rst
index 7170385..1b2ed09 100644
--- a/doc/source/config.rst
+++ b/doc/source/config.rst
@@ -2,33 +2,33 @@ Configuration
2============= 2=============
3 3
4Since PHP *ini-like* configuration model isn't flexible enough, 4Since PHP *ini-like* configuration model isn't flexible enough,
5Snuffleupagus is using its own format, in the file specified by 5Snuffleupagus is using its own format in the file specified by
6the directive ``sp.configuration_file`` (in your ``php.ini`` file), 6the directive ``sp.configuration_file`` (in your ``php.ini`` file),
7like ``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini``. 7like ``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini``.
8 8
9Options are chainable by using dots (``.``), and string parameters 9Options are chainable by using dots (``.``) and string parameters
10**must** be quoted, while booleans and integers aren't. 10**must** be quoted, while booleans and integers aren't.
11 11
12Comments are prefixed either with ``#``, or ``;``. 12Comments are prefixed either with ``#``, or ``;``.
13 13
14Some rules applies in a specific ``function`` (context), on a specific ``variable`` 14Some rules apply in a specific ``function`` (context) on a specific ``variable``
15(data), like ``disable_functions``, others can only be enabled/disabled, like 15(data), like ``disable_functions``. Others can only be enabled/disabled, like
16``harden_random``. 16``harden_random``.
17 17
18 18
19.. warning:: 19.. warning::
20 20
21 Careful, a wrongly configured Snuffleupagus might break your website. 21 If you configure Snuffleupagus incorrectly, you could break your website.
22 It's up to you to understand its :doc:`features <features>`, 22 It's up to you to understand the :doc:`features <features>`,
23 read the present documentation about how to configure them, 23 read the present documentation about how to configure them,
24 evaluate your threat model, and write your configuration file accordingly. 24 evaluate your threat model and write your configuration file accordingly.
25 25
26Most of the features can be used in ``simulation`` mode by appending the 26Most of the features can be used in ``simulation`` mode by appending the
27``.simulation()`` option to them (eg. ``sp.readonly_exec.simulation()enable();``) to see 27``.simulation()`` option to them (eg. ``sp.readonly_exec.simulation()enable();``) to see
28if they might break your website. The simulation mode won't block the request, 28whether or not they could break your website. The simulation mode won't block the request,
29but will write a warning in the log. 29but will write a warning in the log.
30 30
31The rules are evaluated in the order that they are written, and the **first** one 31The rules are evaluated in the order that they are written, the **first** one
32to match will terminate the evaluation (except for rules in simulation mode). 32to match will terminate the evaluation (except for rules in simulation mode).
33 33
34Bugclass-killer features 34Bugclass-killer features
@@ -70,12 +70,12 @@ It can either be ``enabled`` or ``disabled``.
70global 70global
71^^^^^^ 71^^^^^^
72 72
73This configuration variable contain parameters that are used by other ones: 73This configuration variable contains parameters that are used by multiple functions:
74 74
75- ``secret_key``: A secret key used by various cryptographic features, 75- ``secret_key``: A secret key used by various cryptographic features,
76 like `cookies protection <features.html#session-cookie-stealing-via-xss>`__ or `unserialize protection <features.html#unserialize-related-magic>`__, 76 like `cookies protection <features.html#session-cookie-stealing-via-xss>`__ or `unserialize protection <features.html#unserialize-related-magic>`__,
77 so do make sure that it's random and long enough. 77 please ensure the length and complexity is sufficient.
78 You can generate it with something like this: ``head -c 256 /dev/urandom | tr -dc 'a-zA-Z0-9'``. 78 You can generate it with functions such as: ``head -c 256 /dev/urandom | tr -dc 'a-zA-Z0-9'``.
79 79
80:: 80::
81 81
@@ -86,10 +86,10 @@ unserialize_hmac
86 * `default: disabled` 86 * `default: disabled`
87 * `more <features.html#unserialize-related-magic>`__ 87 * `more <features.html#unserialize-related-magic>`__
88 88
89``unserialize_hmac`` will add integrity check to ``unserialize`` calls, preventing 89``unserialize_hmac`` will add an integrity check to ``unserialize`` calls, preventing
90abritrary code execution in their context. 90abritrary code execution in their context.
91 91
92It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. 92It can either be ``enabled`` or ``disabled`` and can be used in ``simulation`` mode.
93 93
94:: 94::
95 95
@@ -120,15 +120,15 @@ cookie_encryption
120 120
121.. warning:: 121.. warning::
122 122
123 To use this feature, you **must** set the :ref:`global.secret_key <config_global>` and 123 To use this feature, you **must** set the :ref:`global.secret_key <config_global>`
124 and the :ref:`global.cookie_env_var <config_global>` variables. 124 and the :ref:`global.cookie_env_var <config_global>` variables.
125 This design decision prevents attacker from 125 This design decision prevents an attacker from
126 `trivially bruteforcing <https://www.idontplaydarts.com/2011/11/decrypting-suhosin-sessions-and-cookies/>`_ 126 `trivially bruteforcing <https://www.idontplaydarts.com/2011/11/decrypting-suhosin-sessions-and-cookies/>`_
127 or re-using session cookies. 127 or re-using session cookies.
128 128
129``cookie_secure`` will activate transparent encryption of specific cookies. 129``cookie_secure`` will activate transparent encryption of specific cookies.
130 130
131It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. 131It can either be ``enabled`` or ``disabled`` and can be used in ``simulation`` mode.
132 132
133:: 133::
134 134
@@ -138,22 +138,22 @@ It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode.
138Choosing the proper environment variable 138Choosing the proper environment variable
139"""""""""""""""""""""""""""""""""""""""" 139""""""""""""""""""""""""""""""""""""""""
140 140
141It's up to you to chose a meaningul environment variable to derive the key from. 141It's up to you to choose a meaningful environment variable to derive the key from.
142Suhosin `is using <https://www.suhosin.org/stories/configuration.html#suhosin-session-cryptraddr>`_ 142Suhosin `is using <https://www.suhosin.org/stories/configuration.html#suhosin-session-cryptraddr>`_
143the ``REMOTE_ADDR`` one, tying the validity of the cookie to the IP address of the user; 143the ``REMOTE_ADDR`` one, tying the validity of the cookie to the IP address of the user;
144unfortunately, nowadays, people are `roaming <https://en.wikipedia.org/wiki/Roaming>`_ a lot on their smartphone, 144unfortunately, nowadays, people are `roaming <https://en.wikipedia.org/wiki/Roaming>`_ a lot on their smartphone,
145hopping from WiFi to 4G, … 145hopping from WiFi to 4G.
146 146
147This is why we recommend, if possible, to use the *extended master secret* 147This is why we recommend, if possible, to use the *extended master secret*
148from TLS connections (`RFC7627 <https://tools.ietf.org/html/rfc7627>`_) 148from TLS connections (`RFC7627 <https://tools.ietf.org/html/rfc7627>`_)
149instead, to make the valitity of the cookie TLS-dependent, by using the ``SSL_SESSION_ID`` variable. 149instead. The will make the validity of the cookie TLS-dependent, by using the ``SSL_SESSION_ID`` variable.
150 150
151- In `Apache <https://httpd.apache.org/docs/current/mod/mod_ssl.html>`_, 151- In `Apache <https://httpd.apache.org/docs/current/mod/mod_ssl.html>`_,
152 it possible to enable by adding ``SSLOptions StdEnvVars`` in your Apache2 configuration. 152 it is possible to enable by adding ``SSLOptions StdEnvVars`` in your Apache2 configuration.
153- In `nginx <https://nginx.org/en/docs/http/ngx_http_ssl_module.html#variables>`_, 153- In `nginx <https://nginx.org/en/docs/http/ngx_http_ssl_module.html#variables>`_,
154 you have to use ``fastcgi_param SSL_SESSION_ID $ssl_session_id if_not_empty;``. 154 you have to use ``fastcgi_param SSL_SESSION_ID $ssl_session_id if_not_empty;``.
155 155
156If you're not using TLS (you should.), you can always use the ``REMOTE_ADDR`` one, 156If you aren't using TLS (you should be), you can always use the ``REMOTE_ADDR`` one,
157or ``X-Real-IP`` if you're behind a reverse proxy. 157or ``X-Real-IP`` if you're behind a reverse proxy.
158 158
159readonly_exec 159readonly_exec
@@ -162,7 +162,7 @@ readonly_exec
162 162
163``readonly_exec`` will prevent the execution of writable PHP files. 163``readonly_exec`` will prevent the execution of writable PHP files.
164 164
165It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. 165It can either be ``enabled`` or ``disabled`` and can be used in ``simulation`` mode.
166 166
167:: 167::
168 168
@@ -174,7 +174,7 @@ upload_validation
174 * `more <features.html#remote-code-execution-via-file-upload>`__ 174 * `more <features.html#remote-code-execution-via-file-upload>`__
175 175
176``upload_validation`` will call a given script upon a file upload, with the path 176``upload_validation`` will call a given script upon a file upload, with the path
177to the file being uploaded as argument, and various information about it in the environment: 177to the file being uploaded as argument and various information about it in the environment:
178 178
179* ``SP_FILENAME``: the name of the uploaded file 179* ``SP_FILENAME``: the name of the uploaded file
180* ``SP_FILESIZE``: the size of the file being uploaded 180* ``SP_FILESIZE``: the size of the file being uploaded
@@ -185,10 +185,10 @@ This feature can be used, for example, to check if an uploaded file contains php
185code, with something like `vld <https://derickrethans.nl/projects.html#vld>`_ 185code, with something like `vld <https://derickrethans.nl/projects.html#vld>`_
186(``php -d vld.execute=0 -d vld.active=1 -d extension=vld.so yourfile.php``). 186(``php -d vld.execute=0 -d vld.active=1 -d extension=vld.so yourfile.php``).
187 187
188The upload will be **allowed** if the script return the value ``0``. Every other 188The upload will be **allowed** if the script returns the value ``0``. Every other
189value will prevent the file from being uploaded. 189value will prevent the file from being uploaded.
190 190
191It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. 191It can either be ``enabled`` or ``disabled`` and can be used in ``simulation`` mode.
192 192
193:: 193::
194 194
@@ -210,8 +210,8 @@ disable_xxe
210Virtual-patching 210Virtual-patching
211---------------- 211----------------
212 212
213Snuffleupagus provides virtual-patching, via the ``disable_functions`` directive, allowing you to stop or control dangerous behaviours. 213Snuffleupagus provides virtual-patching via the ``disable_functions`` directive, allowing you to stop or control dangerous behaviours.
214Admitting you have a call to ``system()`` that lacks proper user-input validation, thus leading to an **RCE**, this might be the right tool. 214In the situation where you have a call to ``system()`` that lacks proper user-input validation, this could cause issues as it would lead to an **RCE**. The virtual-patching would allow this to be prevented.
215 215
216:: 216::
217 217
@@ -219,7 +219,7 @@ Admitting you have a call to ``system()`` that lacks proper user-input validatio
219 sp.disable_functions.function("system").filename("id.php").param("cmd").value("id").allow(); 219 sp.disable_functions.function("system").filename("id.php").param("cmd").value("id").allow();
220 sp.disable_functions.function("system").filename("id.php").drop() 220 sp.disable_functions.function("system").filename("id.php").drop()
221 221
222Of course, this is a trivial example, and a lot can be achieved with this feature, as you will see below. 222Of course, this is a trivial example, a lot can be achieved with this feature, as you will see below.
223 223
224 224
225Filters 225Filters
@@ -238,7 +238,7 @@ Filters
238- ``ret(value)``: match on the function's return ``value`` 238- ``ret(value)``: match on the function's return ``value``
239- ``ret_r(regexp)``: match with a ``regexp`` on the function's return 239- ``ret_r(regexp)``: match with a ``regexp`` on the function's return
240- ``ret_type(type_name)``: match on the ``type_name`` of the function's return value 240- ``ret_type(type_name)``: match on the ``type_name`` of the function's return value
241- ``value(value)``: match on a litteral ``value`` 241- ``value(value)``: match on a literal ``value``
242- ``value_r(regexp)``: match on a value matching the ``regexp`` 242- ``value_r(regexp)``: match on a value matching the ``regexp``
243- ``var(name)``: match on a **local variable** ``name`` 243- ``var(name)``: match on a **local variable** ``name``
244 244
@@ -267,22 +267,22 @@ Details
267 267
268The ``function`` filter is able to do various dereferencing: 268The ``function`` filter is able to do various dereferencing:
269 269
270- ``function("AwesomeClass::my_method")`` will match in the method ``my_method`` in the class ``AwesomeClass`` 270- ``function("AwesomeClass::my_method")`` will match the method ``my_method`` in the class ``AwesomeClass``
271- ``function("AwesomeNamespace\\my_function")`` will match in the function ``my_function`` in the namespace ``AwesomeNamespace`` 271- ``function("AwesomeNamespace\\my_function")`` will match the function ``my_function`` in the namespace ``AwesomeNamespace``
272 272
273The ``param`` filter is also able to do some dereferencing: 273The ``param`` filter is also able to do some dereferencing:
274 274
275- ``param(foo[bar])`` will get match on the value corresponding to the ``bar`` key in the hashtable ``foo``. 275- ``param(foo[bar])`` will get a match on the value corresponding to the ``bar`` key in the hashtable ``foo``.
276 Remember that in PHP, almost every data structure is a hashtable. You can of course nest this like 276 Remember that in PHP, almost every data structure is a hashtable. You can of course nest this like
277 ``param(foo[bar][baz][batman])``. 277 ``param(foo[bar][baz][batman])``.
278- The ``var`` filter will walk the calltrace until it finds the variable's name, or the end of it, 278- The ``var`` filter will walk the calltrace until it finds the variable name, or the end of the calltrace,
279 allowing to match on global variables: ``.var("_GET[param]")`` will match on the GET parameter ``param``. 279 allowing the filter to match global variables: ``.var("_GET[param]")`` will match on the GET parameter ``param``.
280 280
281For clarity's sake, the presence of the ``allow`` or ``drop`` action is **mandatory**. 281For clarity, the presence of the ``allow`` or ``drop`` action is **mandatory**.
282 282
283.. warning:: 283.. warning::
284 284
285 When you're writing rules, please do keep in mind that the **order matters**. 285 When you're writing rules, please do keep in mind that **the order matters**.
286 For example, if you're denying a call to ``system()`` and then allowing it in a 286 For example, if you're denying a call to ``system()`` and then allowing it in a
287 more narrowed way later, the call will be denied, 287 more narrowed way later, the call will be denied,
288 because it'll match the deny first. 288 because it'll match the deny first.