diff options
Diffstat (limited to 'config/default_php8.rules')
| -rw-r--r-- | config/default_php8.rules | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/config/default_php8.rules b/config/default_php8.rules deleted file mode 100644 index 0490654..0000000 --- a/config/default_php8.rules +++ /dev/null | |||
| @@ -1,128 +0,0 @@ | |||
| 1 | # This is the default configuration file for Snuffleupagus (https://snuffleupagus.rtfd.io), | ||
| 2 | # for php8. | ||
| 3 | # It contains "reasonable" defaults that won't break your websites, | ||
| 4 | # and a lot of commented directives that you can enable if you want to | ||
| 5 | # have a better protection. | ||
| 6 | |||
| 7 | # Harden the PRNG | ||
| 8 | sp.harden_random.enable(); | ||
| 9 | |||
| 10 | # Disabled XXE | ||
| 11 | sp.xxe_protection.enable(); | ||
| 12 | |||
| 13 | # Global configuration variables | ||
| 14 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); | ||
| 15 | |||
| 16 | # Globally activate strict mode | ||
| 17 | # https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict | ||
| 18 | # sp.global_strict.enable(); | ||
| 19 | |||
| 20 | # Prevent unserialize-related exploits | ||
| 21 | # sp.unserialize_hmac.enable(); | ||
| 22 | |||
| 23 | # Only allow execution of read-only files. This is a low-hanging fruit that you should enable. | ||
| 24 | # sp.readonly_exec.enable(); | ||
| 25 | |||
| 26 | # PHP has a lot of wrappers, most of them aren't usually useful, you should | ||
| 27 | # only enable the ones you're using. | ||
| 28 | # sp.wrappers_whitelist.list("file,php,phar"); | ||
| 29 | # The "php" wrapper can be further filtered, e.g. to only allow `php://stdout`, `php://stdin` and `php://stderr`: | ||
| 30 | # sp.wrappers_whitelist.php_list("stdout,stdin,stderr"); | ||
| 31 | |||
| 32 | # Prevent sloppy comparisons. | ||
| 33 | # sp.sloppy_comparison.enable(); | ||
| 34 | |||
| 35 | # Use SameSite on session cookie | ||
| 36 | # https://snuffleupagus.readthedocs.io/features.html#protection-against-cross-site-request-forgery | ||
| 37 | sp.cookie.name("PHPSESSID").samesite("lax"); | ||
| 38 | |||
| 39 | # Harden the `chmod` function (0777 (oct = 511, 0666 = 438) | ||
| 40 | sp.disable_function.function("chmod").param("permissions").value("438").drop(); | ||
| 41 | sp.disable_function.function("chmod").param("permissions").value("511").drop(); | ||
| 42 | |||
| 43 | # Prevent various `mail`-related vulnerabilities | ||
| 44 | # Uncommend the second rule if you're using php8.3+ | ||
| 45 | #sp.disable_function.function("mail").param("additional_parameters").value_r("\\-").drop(); | ||
| 46 | #sp.disable_function.function("mail").param("additional_params").value_r("\\-").drop(); | ||
| 47 | |||
| 48 | # Since it's now burned, me might as well mitigate it publicly | ||
| 49 | sp.disable_function.function("putenv").param("assignment").value_r("LD_").drop() | ||
| 50 | sp.disable_function.function("putenv").param("assignment").value("PATH").drop() | ||
| 51 | |||
| 52 | # This one was burned in Nov 2019 - https://gist.github.com/LoadLow/90b60bd5535d6c3927bb24d5f9955b80 | ||
| 53 | sp.disable_function.function("putenv").param("assignment").value_r("GCONV_").drop() | ||
| 54 | |||
| 55 | # Since people are stupid enough to use `extract` on things like $_GET or $_POST, we might as well mitigate this vector | ||
| 56 | sp.disable_function.function("extract").param("array").value_r("^_").drop() | ||
| 57 | sp.disable_function.function("extract").param("flags").value("0").drop() | ||
| 58 | |||
| 59 | # See https://dustri.org/b/ini_set-based-open_basedir-bypass.html | ||
| 60 | # Since we have no way of matching on two parameters at the same time, we're | ||
| 61 | # blocking calls to open_basedir altogether: nobody is using it via ini_set anyway. | ||
| 62 | # Moreover, there are non-public bypasses that are also using this vector ;) | ||
| 63 | sp.disable_function.function("ini_set").param("option").value_r("open_basedir").drop() | ||
| 64 | |||
| 65 | # Prevent various `include`-related vulnerabilities | ||
| 66 | sp.disable_function.function("require_once").value_r("\.(inc|phtml|php)$").allow(); | ||
| 67 | sp.disable_function.function("include_once").value_r("\.(inc|phtml|php)$").allow(); | ||
| 68 | sp.disable_function.function("require").value_r("\.(inc|phtml|php)$").allow(); | ||
| 69 | sp.disable_function.function("include").value_r("\.(inc|phtml|php)$").allow(); | ||
| 70 | sp.disable_function.function("require_once").drop() | ||
| 71 | sp.disable_function.function("include_once").drop() | ||
| 72 | sp.disable_function.function("require").drop() | ||
| 73 | sp.disable_function.function("include").drop() | ||
| 74 | |||
| 75 | # Prevent `system`-related injections | ||
| 76 | sp.disable_function.function("system").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop(); | ||
| 77 | sp.disable_function.function("shell_exec").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop(); | ||
| 78 | sp.disable_function.function("exec").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop(); | ||
| 79 | sp.disable_function.function("proc_open").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop(); | ||
| 80 | |||
| 81 | # Prevent runtime modification of interesting things | ||
| 82 | sp.disable_function.function("ini_set").param("option").value("assert.active").drop(); | ||
| 83 | sp.disable_function.function("ini_set").param("option").value("zend.assertions").drop(); | ||
| 84 | sp.disable_function.function("ini_set").param("option").value("memory_limit").drop(); | ||
| 85 | sp.disable_function.function("ini_set").param("option").value("include_path").drop(); | ||
| 86 | sp.disable_function.function("ini_set").param("option").value("open_basedir").drop(); | ||
| 87 | |||
| 88 | # Detect some backdoors via environment recon | ||
| 89 | sp.disable_function.function("ini_get").param("option").value("allow_url_fopen").drop(); | ||
| 90 | sp.disable_function.function("ini_get").param("option").value("open_basedir").drop(); | ||
| 91 | sp.disable_function.function("ini_get").param("option").value_r("suhosin").drop(); | ||
| 92 | sp.disable_function.function("function_exists").param("function").value("eval").drop(); | ||
| 93 | sp.disable_function.function("function_exists").param("function").value("exec").drop(); | ||
| 94 | sp.disable_function.function("function_exists").param("function").value("system").drop(); | ||
| 95 | sp.disable_function.function("function_exists").param("function").value("shell_exec").drop(); | ||
| 96 | sp.disable_function.function("function_exists").param("function").value("proc_open").drop(); | ||
| 97 | sp.disable_function.function("function_exists").param("function").value("passthru").drop(); | ||
| 98 | sp.disable_function.function("is_callable").param("value").value("eval").drop(); | ||
| 99 | sp.disable_function.function("is_callable").param("value").value("exec").drop(); | ||
| 100 | sp.disable_function.function("is_callable").param("value").value("system").drop(); | ||
| 101 | sp.disable_function.function("is_callable").param("value").value("shell_exec").drop(); | ||
| 102 | sp.disable_function.function("is_callable").param("value").value("proc_open").drop(); | ||
| 103 | sp.disable_function.function("is_callable").param("value").value("passthru").drop(); | ||
| 104 | |||
| 105 | # Ghetto error-based sqli detection | ||
| 106 | # sp.disable_function.function("mysql_query").ret("FALSE").drop(); | ||
| 107 | # sp.disable_function.function("mysqli_query").ret("FALSE").drop(); | ||
| 108 | # sp.disable_function.function("PDO::query").ret("FALSE").drop(); | ||
| 109 | |||
| 110 | # Ensure that certificates are properly verified | ||
| 111 | sp.disable_function.function("curl_setopt").param("value").value("1").allow(); | ||
| 112 | sp.disable_function.function("curl_setopt").param("value").value("2").allow(); | ||
| 113 | # `81` is SSL_VERIFYHOST and `64` SSL_VERIFYPEER | ||
| 114 | sp.disable_function.function("curl_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYCLIENT off."); | ||
| 115 | sp.disable_function.function("curl_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 116 | |||
| 117 | # Ensure that file:// protocol is not allowed in CURL | ||
| 118 | sp.disable_function.function("curl_setopt").param("value").value_r("file://").drop().alias("file:// protocol is disabled"); | ||
| 119 | sp.disable_function.function("curl_init").param("url").value_r("file://").drop().alias("file:// protocol is disabled"); | ||
| 120 | |||
| 121 | # File upload | ||
| 122 | sp.disable_function.function("move_uploaded_file").param("to").value_r("\\.ph").drop(); | ||
| 123 | sp.disable_function.function("move_uploaded_file").param("to").value_r("\\.ht").drop(); | ||
| 124 | |||
| 125 | # Logging lockdown | ||
| 126 | sp.disable_function.function("ini_set").param("option").value_r("error_log").drop() | ||
| 127 | sp.disable_function.function("ini_set").param("option").value_r("error_reporting").drop() | ||
| 128 | sp.disable_function.function("ini_set").param("option").value_r("display_errors").drop() | ||
