diff options
| author | jvoisin | 2017-09-26 17:57:30 +0200 |
|---|---|---|
| committer | jvoisin | 2017-09-26 17:57:30 +0200 |
| commit | 3040b02639bd71dbcd936311546ef9296165aea5 (patch) | |
| tree | 871173e901c04255de595653b8e1dc237a675b51 /doc/source | |
| parent | 3c14dba94e837322e030b19b41654952624cb485 (diff) | |
Update a bit the configuration
Diffstat (limited to 'doc/source')
| -rw-r--r-- | doc/source/conf.py | 2 | ||||
| -rw-r--r-- | doc/source/config.rst | 50 | ||||
| -rw-r--r-- | doc/source/faq.rst | 27 | ||||
| -rw-r--r-- | doc/source/features.rst | 12 |
4 files changed, 57 insertions, 34 deletions
diff --git a/doc/source/conf.py b/doc/source/conf.py index b2af5f2..2ec387d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py | |||
| @@ -57,7 +57,7 @@ author = u'Sebastien Blot & Julien Voisin' | |||
| 57 | # The short X.Y version. | 57 | # The short X.Y version. |
| 58 | version = u'0.1' | 58 | version = u'0.1' |
| 59 | # The full version, including alpha/beta/rc tags. | 59 | # The full version, including alpha/beta/rc tags. |
| 60 | release = u'Public Alpha' | 60 | release = u'beta' |
| 61 | 61 | ||
| 62 | # The language for content autogenerated by Sphinx. Refer to documentation | 62 | # The language for content autogenerated by Sphinx. Refer to documentation |
| 63 | # for a list of supported languages. | 63 | # for a list of supported languages. |
diff --git a/doc/source/config.rst b/doc/source/config.rst index 7299fb1..760ae1b 100644 --- a/doc/source/config.rst +++ b/doc/source/config.rst | |||
| @@ -13,6 +13,7 @@ Some rules applies in a specific ``function`` (context), on a specific ``variabl | |||
| 13 | (data), like ``disable_functions``, others can only be enabled/disabled, like | 13 | (data), like ``disable_functions``, others can only be enabled/disabled, like |
| 14 | ``harden_random``. | 14 | ``harden_random``. |
| 15 | 15 | ||
| 16 | |||
| 16 | .. warning:: | 17 | .. warning:: |
| 17 | 18 | ||
| 18 | Careful, a wrongly configured Snuffleupagus might break your website. | 19 | Careful, a wrongly configured Snuffleupagus might break your website. |
| @@ -20,6 +21,11 @@ Some rules applies in a specific ``function`` (context), on a specific ``variabl | |||
| 20 | read the present documentation about how to configure them, | 21 | read the present documentation about how to configure them, |
| 21 | evaluate your threat model, and write your configuration file accordingly. | 22 | evaluate your threat model, and write your configuration file accordingly. |
| 22 | 23 | ||
| 24 | Most of the features can be used in ``simulation`` mode by appending the | ||
| 25 | ``.simulation()`` option to them (eg. ``sp.readonly_exec.simulation()enable();``) to see | ||
| 26 | if they might break your website. The simulation mode won't block the request, | ||
| 27 | but will write a warning in the log. | ||
| 28 | |||
| 23 | The rules are evaluated in the order that they are written, and the **first** one | 29 | The rules are evaluated in the order that they are written, and the **first** one |
| 24 | to match will terminate the evaluation (except for rules in simulation mode). | 30 | to match will terminate the evaluation (except for rules in simulation mode). |
| 25 | 31 | ||
| @@ -34,7 +40,7 @@ global_strict | |||
| 34 | forcing PHP to throw a `TypeError <https://secure.php.net/manual/en/class.typeerror.php>`_ | 40 | forcing PHP to throw a `TypeError <https://secure.php.net/manual/en/class.typeerror.php>`_ |
| 35 | exception if an argument type being passed to a function does not match its corresponding declared parameter type. | 41 | exception if an argument type being passed to a function does not match its corresponding declared parameter type. |
| 36 | 42 | ||
| 37 | It can either be ``enabled`` or ``disabled`` | 43 | It can either be ``enabled`` or ``disabled``. |
| 38 | 44 | ||
| 39 | :: | 45 | :: |
| 40 | 46 | ||
| @@ -81,6 +87,8 @@ unserialize_hmac | |||
| 81 | ``unserialize_hmac`` will add integrity check to ``unserialize`` calls, preventing | 87 | ``unserialize_hmac`` will add integrity check to ``unserialize`` calls, preventing |
| 82 | abritrary code execution in their context. | 88 | abritrary code execution in their context. |
| 83 | 89 | ||
| 90 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. | ||
| 91 | |||
| 84 | :: | 92 | :: |
| 85 | 93 | ||
| 86 | sp.unserialize_hmac.enable(); | 94 | sp.unserialize_hmac.enable(); |
| @@ -116,7 +124,7 @@ cookie_encryption | |||
| 116 | 124 | ||
| 117 | ``cookie_secure`` will activate transparent encryption of specific cookies. | 125 | ``cookie_secure`` will activate transparent encryption of specific cookies. |
| 118 | 126 | ||
| 119 | It can either be ``enabled`` or ``disabled``. | 127 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. |
| 120 | 128 | ||
| 121 | :: | 129 | :: |
| 122 | 130 | ||
| @@ -130,7 +138,7 @@ readonly_exec | |||
| 130 | 138 | ||
| 131 | ``readonly_exec`` will prevent the execution of writable PHP files. | 139 | ``readonly_exec`` will prevent the execution of writable PHP files. |
| 132 | 140 | ||
| 133 | It can either be ``enabled`` or ``disabled``. | 141 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. |
| 134 | 142 | ||
| 135 | :: | 143 | :: |
| 136 | 144 | ||
| @@ -156,6 +164,8 @@ code, with something like `vld <https://derickrethans.nl/projects.html#vld>`_ | |||
| 156 | The upload will be **allowed** if the script return the value ``0``. Every other | 164 | The upload will be **allowed** if the script return the value ``0``. Every other |
| 157 | value will prevent the file from being uploaded. | 165 | value will prevent the file from being uploaded. |
| 158 | 166 | ||
| 167 | It can either be ``enabled`` or ``disabled``, and used in ``simulation`` mode. | ||
| 168 | |||
| 159 | :: | 169 | :: |
| 160 | 170 | ||
| 161 | sp.upload_validation.script("/var/www/is_valid_php.py").enable(); | 171 | sp.upload_validation.script("/var/www/is_valid_php.py").enable(); |
| @@ -191,22 +201,22 @@ Of course, this is a trivial example, and a lot can be achieved with this featur | |||
| 191 | Filters | 201 | Filters |
| 192 | ^^^^^^^ | 202 | ^^^^^^^ |
| 193 | 203 | ||
| 194 | - ``alias(:str)``: human-readable description of the rule | 204 | - ``alias(description)``: human-readable ``description`` of the rule |
| 195 | - ``cidr(ip/mask:str)``: match on the client's `cidr <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing>`_ | 205 | - ``cidr(ip/mask)``: match on the client's `cidr <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing>`_ |
| 196 | - ``filename(name:str)``: match in the file ``name`` | 206 | - ``filename(name)``: match in the file ``name`` |
| 197 | - ``filename_r(regexp:str)``: the file name matching the ``regexp`` | 207 | - ``filename_r(regexp)``: the file name matching the ``regexp`` |
| 198 | - ``function(name:str)``: match on function ``name`` | 208 | - ``function(name)``: match on function ``name`` |
| 199 | - ``function_r(regexp:str)``: the function matching the ``regexp`` | 209 | - ``function_r(regexp)``: the function matching the ``regexp`` |
| 200 | - ``hash(:str)``: match on the file's `sha256 <https://en.wikipedia.org/wiki/SHA-2>`_ sum | 210 | - ``hash(sha256)``: match on the file's `sha256 <https://en.wikipedia.org/wiki/SHA-2>`_ sum |
| 201 | - ``param(name:str)``: match on the function's parameter ``name`` | 211 | - ``param(name)``: match on the function's parameter ``name`` |
| 202 | - ``param_r(regexp:str)``: match on the function's parameter ``regexp`` | 212 | - ``param_r(regexp)``: match on the function's parameter ``regexp`` |
| 203 | - ``param_type(type:str)``: match on the function's parameter ``type`` | 213 | - ``param_type(type)``: match on the function's parameter ``type`` |
| 204 | - ``ret(value:str)``: match on the function's return ``value`` | 214 | - ``ret(value)``: match on the function's return ``value`` |
| 205 | - ``ret_r(regexp:str)``: match with a ``regexp`` on the function's return | 215 | - ``ret_r(regexp)``: match with a ``regexp`` on the function's return |
| 206 | - ``ret_type(type_name:str)``: match on the ``type_name`` of the function's return value | 216 | - ``ret_type(type_name)``: match on the ``type_name`` of the function's return value |
| 207 | - ``value(:str)``: match on a litteral value | 217 | - ``value(value)``: match on a litteral ``value`` |
| 208 | - ``value_r(:regexp)``: match on a value matching the ``regexp`` | 218 | - ``value_r(regexp)``: match on a value matching the ``regexp`` |
| 209 | - ``var(name:str)``: match on a **local variable** ``name`` | 219 | - ``var(name)``: match on a **local variable** ``name`` |
| 210 | 220 | ||
| 211 | The ``type`` must be one of the following values: | 221 | The ``type`` must be one of the following values: |
| 212 | 222 | ||
| @@ -225,7 +235,7 @@ Actions | |||
| 225 | 235 | ||
| 226 | - ``allow()``: **allow** the request if the rule matches | 236 | - ``allow()``: **allow** the request if the rule matches |
| 227 | - ``drop()``: **drop** the request if the rule matches | 237 | - ``drop()``: **drop** the request if the rule matches |
| 228 | - ``dump(directory:str)``: dump the request in the ``directory`` if it matches the rule | 238 | - ``dump(directory)``: dump the request in the ``directory`` if it matches the rule |
| 229 | - ``simulation()``: enabled the simulation mode | 239 | - ``simulation()``: enabled the simulation mode |
| 230 | 240 | ||
| 231 | Details | 241 | Details |
diff --git a/doc/source/faq.rst b/doc/source/faq.rst index cd9dfe3..09cb244 100644 --- a/doc/source/faq.rst +++ b/doc/source/faq.rst | |||
| @@ -36,13 +36,14 @@ Like PHP's `ElePHPant <https://secure.php.net/elephpant.php>`_, | |||
| 36 | we thought that using an elephant as a mascot would be a great idea. | 36 | we thought that using an elephant as a mascot would be a great idea. |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | Why did you write Snuffleupagus? | 39 | Who are you and why did you write Snuffleupagus? |
| 40 | """""""""""""""""""""""""""""""" | 40 | """""""""""""""""""""""""""""""""""""""""""""""" |
| 41 | 41 | ||
| 42 | We're working for `NBS System <https://nbs-system.com/en/>`__, | 42 | We're working for `NBS System <https://nbs-system.com/en/>`__, |
| 43 | a web hosting company (meaning that we're dealing with PHP code all day long), | 43 | a web hosting company (meaning that we're dealing with PHP code all day long), |
| 44 | with a strong focus on security. We do have hardening | 44 | with a strong focus on security. We do have hardening |
| 45 | (kernel, `WAF <https://naxsi.org>`_, `IDS <https://en.wikipedia.org/wiki/Intrusion_detection_system>`_, …) | 45 | (`kernel <https://grsecurity.net/>`_, `WAF <https://naxsi.org>`_, |
| 46 | `IDS <https://en.wikipedia.org/wiki/Intrusion_detection_system>`_, …) | ||
| 46 | below the web stack, but most of the time, when a website is compromised, | 47 | below the web stack, but most of the time, when a website is compromised, |
| 47 | it's either to send ads, spam, deface it, steal data, … | 48 | it's either to send ads, spam, deface it, steal data, … |
| 48 | This is why we need to harden the website itself too, but we can't touch its | 49 | This is why we need to harden the website itself too, but we can't touch its |
| @@ -60,7 +61,8 @@ We're huge fans of `Suhosin <https://suhosin.org>`_, unfortunately: | |||
| 60 | 61 | ||
| 61 | We're using the `disable_function <https://secure.php.net/manual/en/ini.core.php#ini.disable-functions>`_ | 62 | We're using the `disable_function <https://secure.php.net/manual/en/ini.core.php#ini.disable-functions>`_ |
| 62 | directive, but unfortunately, it doesn't provide enough usable granularity (guess how many CMS are using | 63 | directive, but unfortunately, it doesn't provide enough usable granularity (guess how many CMS are using |
| 63 | ``system`` to do various mandatory maintenance tasks…). | 64 | the `system <https://secure.php.net/manual/en/function.system.php#refsect1-function.system-notes>`_ |
| 65 | function to perform various mandatory maintenance tasks…). | ||
| 64 | 66 | ||
| 65 | This is why we decided to write our own hardening module, in the spirit of Suhosin, | 67 | This is why we decided to write our own hardening module, in the spirit of Suhosin, |
| 66 | via virtual-patching support, and other cool new features. | 68 | via virtual-patching support, and other cool new features. |
| @@ -91,8 +93,8 @@ How mature is this project? | |||
| 91 | """"""""""""""""""""""""""" | 93 | """"""""""""""""""""""""""" |
| 92 | 94 | ||
| 93 | This project was floating around since early 2016, and we did the first commit | 95 | This project was floating around since early 2016, and we did the first commit |
| 94 | the 28ᵗʰ of December of the same year. We're currently in a private alpha phase, | 96 | the 28ᵗʰ of December of the same year. We're currently in an alpha phase, |
| 95 | finding and fixing as much bugs as possible with the help of friends. | 97 | finding and fixing as much bugs as possible before the beta. |
| 96 | 98 | ||
| 97 | Are you saying that PHP isn't secure? | 99 | Are you saying that PHP isn't secure? |
| 98 | """"""""""""""""""""""""""""""""""""" | 100 | """"""""""""""""""""""""""""""""""""" |
| @@ -108,6 +110,9 @@ issues, as stated in their `documentation <https://wiki.php.net/security#not_a_s | |||
| 108 | We do think that an security issue that "requires the use of code or settings known to be insecure" | 110 | We do think that an security issue that "requires the use of code or settings known to be insecure" |
| 109 | is still a security issue, and should be treated as such. | 111 | is still a security issue, and should be treated as such. |
| 110 | 112 | ||
| 113 | We don't have the pretention to state that Snuffleupagus will magically solve | ||
| 114 | all your security issues, but we believe that it might definitely help. | ||
| 115 | |||
| 111 | Installation and configuration | 116 | Installation and configuration |
| 112 | ------------------------------ | 117 | ------------------------------ |
| 113 | 118 | ||
| @@ -115,8 +120,10 @@ Can snuffleupagus break my application? | |||
| 115 | """"""""""""""""""""""""""""""""""""""" | 120 | """"""""""""""""""""""""""""""""""""""" |
| 116 | Yes. | 121 | Yes. |
| 117 | 122 | ||
| 118 | Some options won't break anything, like ``harden_rand``, but some like ``global_strict`` | 123 | Some options won't break anything, like :ref:`harden-rand <harden-rand-feature>`, |
| 119 | or overly-restrictives virtual-patching rules might pretty well break your website. | 124 | but some like :ref:`global_strict <global-strict-feature>` |
| 125 | or overly-restrictives :ref:`virtual-patching<virtual-patching-feature>` | ||
| 126 | rules might pretty well break your website. | ||
| 120 | It's up to you to configure Snuffleupaggus accordingly to your needs. | 127 | It's up to you to configure Snuffleupaggus accordingly to your needs. |
| 121 | 128 | ||
| 122 | You can also enable the ``simulation`` mode on features that you're not sure about, | 129 | You can also enable the ``simulation`` mode on features that you're not sure about, |
| @@ -130,7 +137,7 @@ By checking the logs; Snuffleupagus systematically prefix them with ``[snuffleup | |||
| 130 | 137 | ||
| 131 | Does Snuffleupagus run on Windows? | 138 | Does Snuffleupagus run on Windows? |
| 132 | """""""""""""""""""""""""""""""""" | 139 | """""""""""""""""""""""""""""""""" |
| 133 | No idea. | 140 | No idea, feel free to `try <https://github.com/nbs-system/snuffleupagus/issues/2>`_. |
| 134 | 141 | ||
| 135 | 142 | ||
| 136 | Will Snuffleupagus run on my old PHP 5? | 143 | Will Snuffleupagus run on my old PHP 5? |
| @@ -206,7 +213,7 @@ Where can I find even more help? | |||
| 206 | """""""""""""""""""""""""""""""" | 213 | """""""""""""""""""""""""""""""" |
| 207 | The :doc:`configuration page <config>` might be what you're looking for. | 214 | The :doc:`configuration page <config>` might be what you're looking for. |
| 208 | If you're adventurous, you can also check the `issue tracker <https://github.com/nbs-system/snuffleupagus/issues/?q=is%3Aissue>`_ | 215 | If you're adventurous, you can also check the `issue tracker <https://github.com/nbs-system/snuffleupagus/issues/?q=is%3Aissue>`_ |
| 209 | (make sure to check the closed issues too). | 216 | (make sure to check the `closed issues <https://github.com/nbs-system/snuffleupagus/issues?q=is%3Aissue+is%3Aclosed>`_ too). |
| 210 | 217 | ||
| 211 | I need professional support for my company. | 218 | I need professional support for my company. |
| 212 | """"""""""""""""""""""""""""""""""""""""""" | 219 | """"""""""""""""""""""""""""""""""""""""""" |
diff --git a/doc/source/features.rst b/doc/source/features.rst index b06aa98..076e4e4 100644 --- a/doc/source/features.rst +++ b/doc/source/features.rst | |||
| @@ -150,6 +150,7 @@ This family of vulnerabilities lead to various CVE, like: | |||
| 150 | - `CVE-2012-5692 <https://www.rapid7.com/db/modules/exploit/unix/webapp/invision_pboard_unserialize_exec>`_: Unauthenticated remote code execution in IP.Board | 150 | - `CVE-2012-5692 <https://www.rapid7.com/db/modules/exploit/unix/webapp/invision_pboard_unserialize_exec>`_: Unauthenticated remote code execution in IP.Board |
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | .. _harden-rand-feature: | ||
| 153 | 154 | ||
| 154 | Weak-PRNG via rand/mt_rand | 155 | Weak-PRNG via rand/mt_rand |
| 155 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | 156 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| @@ -238,6 +239,9 @@ This behaviour is suggested in the documentation: | |||
| 238 | Exploitation, post-exploitation and general hardening | 239 | Exploitation, post-exploitation and general hardening |
| 239 | ----------------------------------------------------- | 240 | ----------------------------------------------------- |
| 240 | 241 | ||
| 242 | |||
| 243 | .. _virtual-patching-feature: | ||
| 244 | |||
| 241 | Virtual-patching | 245 | Virtual-patching |
| 242 | ^^^^^^^^^^^^^^^^ | 246 | ^^^^^^^^^^^^^^^^ |
| 243 | 247 | ||
| @@ -262,6 +266,8 @@ of dangerous functions, droping them everywhere else: | |||
| 262 | The intent is to make post-exploitation process (such as backdooring of legitimate code, or RAT usage) a lot harder for the attacker. | 266 | The intent is to make post-exploitation process (such as backdooring of legitimate code, or RAT usage) a lot harder for the attacker. |
| 263 | 267 | ||
| 264 | 268 | ||
| 269 | .. _global-strict-feature: | ||
| 270 | |||
| 265 | Global strict mode | 271 | Global strict mode |
| 266 | ^^^^^^^^^^^^^^^^^^ | 272 | ^^^^^^^^^^^^^^^^^^ |
| 267 | 273 | ||
| @@ -300,7 +306,7 @@ and using this feature to lock this up. | |||
| 300 | 306 | ||
| 301 | Dumping capabilities | 307 | Dumping capabilities |
| 302 | ^^^^^^^^^^^^^^^^^^^^ | 308 | ^^^^^^^^^^^^^^^^^^^^ |
| 303 | It's possible to apply the ``dump(:str)`` filter to any virtual-patching rule, | 309 | It's possible to apply the ``dump()`` filter to any virtual-patching rule, |
| 304 | to dump the complete web request, along with the filename and the corresponding | 310 | to dump the complete web request, along with the filename and the corresponding |
| 305 | line number. By using the *right* set of restrictive rules (or by using the | 311 | line number. By using the *right* set of restrictive rules (or by using the |
| 306 | *overly* restrictives ones in ``simulation`` mode), you might be able | 312 | *overly* restrictives ones in ``simulation`` mode), you might be able |
| @@ -335,8 +341,8 @@ Arbitrary file inclusion hardening | |||
| 335 | """""""""""""""""""""""""""""""""" | 341 | """""""""""""""""""""""""""""""""" |
| 336 | 342 | ||
| 337 | Arbitrary file inclusion is a common vulnerability, that might be detected | 343 | Arbitrary file inclusion is a common vulnerability, that might be detected |
| 338 | by preventing the use of anything else than a whitelist of extensions in calls | 344 | by preventing the inclusion of anything that doens't match a strict set |
| 339 | to ``include`` or ``require``. | 345 | of file extensions in calls to ``include`` or ``require``. |
| 340 | 346 | ||
| 341 | *Cheap* SQL injections detection | 347 | *Cheap* SQL injections detection |
| 342 | """""""""""""""""""""""""""""""" | 348 | """""""""""""""""""""""""""""""" |
