diff options
| author | Connor Carr | 2017-10-08 17:06:55 +0100 |
|---|---|---|
| committer | jvoisin | 2017-10-08 18:06:55 +0200 |
| commit | 21e6837c1c8442eb01e069b87a01e5996d41f2e9 (patch) | |
| tree | f97931aef6ea060a9d761c4acb62d6d3e9a6eaa2 /doc/source/config.rst | |
| parent | 99f18f7818f8f3ee354c78276d7cd981312c7d43 (diff) | |
Grammar/Punctuation changes (#29)
Diffstat (limited to 'doc/source/config.rst')
| -rw-r--r-- | doc/source/config.rst | 74 |
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 | ||
| 4 | Since PHP *ini-like* configuration model isn't flexible enough, | 4 | Since PHP *ini-like* configuration model isn't flexible enough, |
| 5 | Snuffleupagus is using its own format, in the file specified by | 5 | Snuffleupagus is using its own format in the file specified by |
| 6 | the directive ``sp.configuration_file`` (in your ``php.ini`` file), | 6 | the directive ``sp.configuration_file`` (in your ``php.ini`` file), |
| 7 | like ``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini``. | 7 | like ``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini``. |
| 8 | 8 | ||
| 9 | Options are chainable by using dots (``.``), and string parameters | 9 | Options 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 | ||
| 12 | Comments are prefixed either with ``#``, or ``;``. | 12 | Comments are prefixed either with ``#``, or ``;``. |
| 13 | 13 | ||
| 14 | Some rules applies in a specific ``function`` (context), on a specific ``variable`` | 14 | Some 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 | ||
| 26 | Most of the features can be used in ``simulation`` mode by appending the | 26 | Most 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 |
| 28 | if they might break your website. The simulation mode won't block the request, | 28 | whether or not they could break your website. The simulation mode won't block the request, |
| 29 | but will write a warning in the log. | 29 | but will write a warning in the log. |
| 30 | 30 | ||
| 31 | The rules are evaluated in the order that they are written, and the **first** one | 31 | The rules are evaluated in the order that they are written, the **first** one |
| 32 | to match will terminate the evaluation (except for rules in simulation mode). | 32 | to match will terminate the evaluation (except for rules in simulation mode). |
| 33 | 33 | ||
| 34 | Bugclass-killer features | 34 | Bugclass-killer features |
| @@ -70,12 +70,12 @@ It can either be ``enabled`` or ``disabled``. | |||
| 70 | global | 70 | global |
| 71 | ^^^^^^ | 71 | ^^^^^^ |
| 72 | 72 | ||
| 73 | This configuration variable contain parameters that are used by other ones: | 73 | This 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 |
| 90 | abritrary code execution in their context. | 90 | abritrary code execution in their context. |
| 91 | 91 | ||
| 92 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. | 92 | It 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 | ||
| 131 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. | 131 | It 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. | |||
| 138 | Choosing the proper environment variable | 138 | Choosing the proper environment variable |
| 139 | """""""""""""""""""""""""""""""""""""""" | 139 | """""""""""""""""""""""""""""""""""""""" |
| 140 | 140 | ||
| 141 | It's up to you to chose a meaningul environment variable to derive the key from. | 141 | It's up to you to choose a meaningful environment variable to derive the key from. |
| 142 | Suhosin `is using <https://www.suhosin.org/stories/configuration.html#suhosin-session-cryptraddr>`_ | 142 | Suhosin `is using <https://www.suhosin.org/stories/configuration.html#suhosin-session-cryptraddr>`_ |
| 143 | the ``REMOTE_ADDR`` one, tying the validity of the cookie to the IP address of the user; | 143 | the ``REMOTE_ADDR`` one, tying the validity of the cookie to the IP address of the user; |
| 144 | unfortunately, nowadays, people are `roaming <https://en.wikipedia.org/wiki/Roaming>`_ a lot on their smartphone, | 144 | unfortunately, nowadays, people are `roaming <https://en.wikipedia.org/wiki/Roaming>`_ a lot on their smartphone, |
| 145 | hopping from WiFi to 4G, … | 145 | hopping from WiFi to 4G. |
| 146 | 146 | ||
| 147 | This is why we recommend, if possible, to use the *extended master secret* | 147 | This is why we recommend, if possible, to use the *extended master secret* |
| 148 | from TLS connections (`RFC7627 <https://tools.ietf.org/html/rfc7627>`_) | 148 | from TLS connections (`RFC7627 <https://tools.ietf.org/html/rfc7627>`_) |
| 149 | instead, to make the valitity of the cookie TLS-dependent, by using the ``SSL_SESSION_ID`` variable. | 149 | instead. 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 | ||
| 156 | If you're not using TLS (you should.), you can always use the ``REMOTE_ADDR`` one, | 156 | If you aren't using TLS (you should be), you can always use the ``REMOTE_ADDR`` one, |
| 157 | or ``X-Real-IP`` if you're behind a reverse proxy. | 157 | or ``X-Real-IP`` if you're behind a reverse proxy. |
| 158 | 158 | ||
| 159 | readonly_exec | 159 | readonly_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 | ||
| 165 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. | 165 | It 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 |
| 177 | to the file being uploaded as argument, and various information about it in the environment: | 177 | to 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 | |||
| 185 | code, with something like `vld <https://derickrethans.nl/projects.html#vld>`_ | 185 | code, 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 | ||
| 188 | The upload will be **allowed** if the script return the value ``0``. Every other | 188 | The upload will be **allowed** if the script returns the value ``0``. Every other |
| 189 | value will prevent the file from being uploaded. | 189 | value will prevent the file from being uploaded. |
| 190 | 190 | ||
| 191 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. | 191 | It 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 | |||
| 210 | Virtual-patching | 210 | Virtual-patching |
| 211 | ---------------- | 211 | ---------------- |
| 212 | 212 | ||
| 213 | Snuffleupagus provides virtual-patching, via the ``disable_functions`` directive, allowing you to stop or control dangerous behaviours. | 213 | Snuffleupagus provides virtual-patching via the ``disable_functions`` directive, allowing you to stop or control dangerous behaviours. |
| 214 | Admitting you have a call to ``system()`` that lacks proper user-input validation, thus leading to an **RCE**, this might be the right tool. | 214 | In 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 | ||
| 222 | Of course, this is a trivial example, and a lot can be achieved with this feature, as you will see below. | 222 | Of course, this is a trivial example, a lot can be achieved with this feature, as you will see below. |
| 223 | 223 | ||
| 224 | 224 | ||
| 225 | Filters | 225 | Filters |
| @@ -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 | ||
| 268 | The ``function`` filter is able to do various dereferencing: | 268 | The ``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 | ||
| 273 | The ``param`` filter is also able to do some dereferencing: | 273 | The ``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 | ||
| 281 | For clarity's sake, the presence of the ``allow`` or ``drop`` action is **mandatory**. | 281 | For 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. |
