summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorjvoisin2017-09-26 17:57:30 +0200
committerjvoisin2017-09-26 17:57:30 +0200
commit3040b02639bd71dbcd936311546ef9296165aea5 (patch)
tree871173e901c04255de595653b8e1dc237a675b51 /doc/source
parent3c14dba94e837322e030b19b41654952624cb485 (diff)
Update a bit the configuration
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/conf.py2
-rw-r--r--doc/source/config.rst50
-rw-r--r--doc/source/faq.rst27
-rw-r--r--doc/source/features.rst12
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.
58version = u'0.1' 58version = u'0.1'
59# The full version, including alpha/beta/rc tags. 59# The full version, including alpha/beta/rc tags.
60release = u'Public Alpha' 60release = 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
24Most 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
26if they might break your website. The simulation mode won't block the request,
27but will write a warning in the log.
28
23The rules are evaluated in the order that they are written, and the **first** one 29The rules are evaluated in the order that they are written, and the **first** one
24to match will terminate the evaluation (except for rules in simulation mode). 30to match will terminate the evaluation (except for rules in simulation mode).
25 31
@@ -34,7 +40,7 @@ global_strict
34forcing PHP to throw a `TypeError <https://secure.php.net/manual/en/class.typeerror.php>`_ 40forcing PHP to throw a `TypeError <https://secure.php.net/manual/en/class.typeerror.php>`_
35exception if an argument type being passed to a function does not match its corresponding declared parameter type. 41exception if an argument type being passed to a function does not match its corresponding declared parameter type.
36 42
37It can either be ``enabled`` or ``disabled`` 43It 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
82abritrary code execution in their context. 88abritrary code execution in their context.
83 89
90It 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
119It can either be ``enabled`` or ``disabled``. 127It 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
133It can either be ``enabled`` or ``disabled``. 141It 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>`_
156The upload will be **allowed** if the script return the value ``0``. Every other 164The upload will be **allowed** if the script return the value ``0``. Every other
157value will prevent the file from being uploaded. 165value will prevent the file from being uploaded.
158 166
167It 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
191Filters 201Filters
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
211The ``type`` must be one of the following values: 221The ``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
231Details 241Details
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>`_,
36we thought that using an elephant as a mascot would be a great idea. 36we thought that using an elephant as a mascot would be a great idea.
37 37
38 38
39Why did you write Snuffleupagus? 39Who are you and why did you write Snuffleupagus?
40"""""""""""""""""""""""""""""""" 40""""""""""""""""""""""""""""""""""""""""""""""""
41 41
42We're working for `NBS System <https://nbs-system.com/en/>`__, 42We're working for `NBS System <https://nbs-system.com/en/>`__,
43a web hosting company (meaning that we're dealing with PHP code all day long), 43a web hosting company (meaning that we're dealing with PHP code all day long),
44with a strong focus on security. We do have hardening 44with 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>`_, …)
46below the web stack, but most of the time, when a website is compromised, 47below the web stack, but most of the time, when a website is compromised,
47it's either to send ads, spam, deface it, steal data, … 48it's either to send ads, spam, deface it, steal data, …
48This is why we need to harden the website itself too, but we can't touch its 49This 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
61We're using the `disable_function <https://secure.php.net/manual/en/ini.core.php#ini.disable-functions>`_ 62We're using the `disable_function <https://secure.php.net/manual/en/ini.core.php#ini.disable-functions>`_
62directive, but unfortunately, it doesn't provide enough usable granularity (guess how many CMS are using 63directive, but unfortunately, it doesn't provide enough usable granularity (guess how many CMS are using
63``system`` to do various mandatory maintenance tasks…). 64the `system <https://secure.php.net/manual/en/function.system.php#refsect1-function.system-notes>`_
65function to perform various mandatory maintenance tasks…).
64 66
65This is why we decided to write our own hardening module, in the spirit of Suhosin, 67This is why we decided to write our own hardening module, in the spirit of Suhosin,
66via virtual-patching support, and other cool new features. 68via virtual-patching support, and other cool new features.
@@ -91,8 +93,8 @@ How mature is this project?
91""""""""""""""""""""""""""" 93"""""""""""""""""""""""""""
92 94
93This project was floating around since early 2016, and we did the first commit 95This project was floating around since early 2016, and we did the first commit
94the 28ᵗʰ of December of the same year. We're currently in a private alpha phase, 96the 28ᵗʰ of December of the same year. We're currently in an alpha phase,
95finding and fixing as much bugs as possible with the help of friends. 97finding and fixing as much bugs as possible before the beta.
96 98
97Are you saying that PHP isn't secure? 99Are 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
108We do think that an security issue that "requires the use of code or settings known to be insecure" 110We do think that an security issue that "requires the use of code or settings known to be insecure"
109is still a security issue, and should be treated as such. 111is still a security issue, and should be treated as such.
110 112
113We don't have the pretention to state that Snuffleupagus will magically solve
114all your security issues, but we believe that it might definitely help.
115
111Installation and configuration 116Installation and configuration
112------------------------------ 117------------------------------
113 118
@@ -115,8 +120,10 @@ Can snuffleupagus break my application?
115""""""""""""""""""""""""""""""""""""""" 120"""""""""""""""""""""""""""""""""""""""
116Yes. 121Yes.
117 122
118Some options won't break anything, like ``harden_rand``, but some like ``global_strict`` 123Some options won't break anything, like :ref:`harden-rand <harden-rand-feature>`,
119or overly-restrictives virtual-patching rules might pretty well break your website. 124but some like :ref:`global_strict <global-strict-feature>`
125or overly-restrictives :ref:`virtual-patching<virtual-patching-feature>`
126rules might pretty well break your website.
120It's up to you to configure Snuffleupaggus accordingly to your needs. 127It's up to you to configure Snuffleupaggus accordingly to your needs.
121 128
122You can also enable the ``simulation`` mode on features that you're not sure about, 129You 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
131Does Snuffleupagus run on Windows? 138Does Snuffleupagus run on Windows?
132"""""""""""""""""""""""""""""""""" 139""""""""""""""""""""""""""""""""""
133No idea. 140No idea, feel free to `try <https://github.com/nbs-system/snuffleupagus/issues/2>`_.
134 141
135 142
136Will Snuffleupagus run on my old PHP 5? 143Will Snuffleupagus run on my old PHP 5?
@@ -206,7 +213,7 @@ Where can I find even more help?
206"""""""""""""""""""""""""""""""" 213""""""""""""""""""""""""""""""""
207The :doc:`configuration page <config>` might be what you're looking for. 214The :doc:`configuration page <config>` might be what you're looking for.
208If you're adventurous, you can also check the `issue tracker <https://github.com/nbs-system/snuffleupagus/issues/?q=is%3Aissue>`_ 215If 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
211I need professional support for my company. 218I 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
154Weak-PRNG via rand/mt_rand 155Weak-PRNG via rand/mt_rand
155^^^^^^^^^^^^^^^^^^^^^^^^^^ 156^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -238,6 +239,9 @@ This behaviour is suggested in the documentation:
238Exploitation, post-exploitation and general hardening 239Exploitation, post-exploitation and general hardening
239----------------------------------------------------- 240-----------------------------------------------------
240 241
242
243.. _virtual-patching-feature:
244
241Virtual-patching 245Virtual-patching
242^^^^^^^^^^^^^^^^ 246^^^^^^^^^^^^^^^^
243 247
@@ -262,6 +266,8 @@ of dangerous functions, droping them everywhere else:
262The intent is to make post-exploitation process (such as backdooring of legitimate code, or RAT usage) a lot harder for the attacker. 266The 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
265Global strict mode 271Global strict mode
266^^^^^^^^^^^^^^^^^^ 272^^^^^^^^^^^^^^^^^^
267 273
@@ -300,7 +306,7 @@ and using this feature to lock this up.
300 306
301Dumping capabilities 307Dumping capabilities
302^^^^^^^^^^^^^^^^^^^^ 308^^^^^^^^^^^^^^^^^^^^
303It's possible to apply the ``dump(:str)`` filter to any virtual-patching rule, 309It's possible to apply the ``dump()`` filter to any virtual-patching rule,
304to dump the complete web request, along with the filename and the corresponding 310to dump the complete web request, along with the filename and the corresponding
305line number. By using the *right* set of restrictive rules (or by using the 311line 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
337Arbitrary file inclusion is a common vulnerability, that might be detected 343Arbitrary file inclusion is a common vulnerability, that might be detected
338by preventing the use of anything else than a whitelist of extensions in calls 344by preventing the inclusion of anything that doens't match a strict set
339to ``include`` or ``require``. 345of file extensions in calls to ``include`` or ``require``.
340 346
341*Cheap* SQL injections detection 347*Cheap* SQL injections detection
342"""""""""""""""""""""""""""""""" 348""""""""""""""""""""""""""""""""