summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Voisin2023-01-03 21:39:56 +0100
committerGitHub2023-01-03 21:39:56 +0100
commit0423e1b63364f4dd741d3a8ac8a880407ff37371 (patch)
tree9090e7a6630fbc929d1bc18000579a1388c1158f
parent7d006a4b971aec04c42c06c877c0e496f1f62bc0 (diff)
parent3b794ec1f8ba52c1a30ca0099297c89a41fa49aa (diff)
Add example configuration for Xenforo 2.2.12
-rw-r--r--config/xenforo.rules141
1 files changed, 141 insertions, 0 deletions
diff --git a/config/xenforo.rules b/config/xenforo.rules
new file mode 100644
index 0000000..9f29e1d
--- /dev/null
+++ b/config/xenforo.rules
@@ -0,0 +1,141 @@
1# This is a sample configuration for Snuffleupagus to accomodate Xenforo v2.2.12 on PHP 8.1
2# We keep the default configuration values commented out where they have been shown to be harmful
3
4# Global configuration variables
5sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS.");
6
7# Enforce secure cookies
8# -- You ought to be using HTTPS-only anyway
9sp.auto_cookie_secure.enable();
10
11# Harden the PRNG
12sp.harden_random.enable();
13
14# Disabled XXE
15sp.xxe_protection.enable();
16
17# Globally activate strict mode
18# -- Entirely breaks Xenforo; 99% of requests abuse lose typing directly in their entrypoint
19# sp.global_strict.enable();
20
21# Prevent unserialize-related exploits
22# -- Xenforo heavily uses serialization in database and caches; enable at your own risk
23# sp.unserialize_hmac.enable();
24
25# Only allow execution of read-only files. This is a low-hanging fruit that you should enable.
26# -- Xenforo has a 0777 file permissions model and will refuse to run with anything else, both for
27# -- code caches and its own webroot; this isn't workable at all with this
28# sp.readonly_exec.enable();
29
30# PHP has a lot of wrappers, most of them aren't usually useful, you should
31# only enable the ones you're using.
32# -- Seems OK in general, could break somewhere along the way however
33sp.wrappers_whitelist.list("file,php,phar");
34
35# Prevent sloppy comparisons.
36sp.sloppy_comparison.enable();
37
38# use SameSite on session cookie
39# https://snuffleupagus.readthedocs.io/features.html#protection-against-cross-site-request-forgery
40sp.cookie.name("PHPSESSID").samesite("lax");
41# -- Xenforo cookies
42sp.cookie.name("xf_csrf").samesite("lax");
43sp.cookie.name("xf_session").samesite("lax");
44sp.cookie.name("xf_user").samesite("lax");
45
46# Harden the `chmod` function
47# -- Xenforo aggressively makes files executable left and right, alas
48# sp.disable_function.function("chmod").param("mode").value_r("^[0-9]{2}[67]$").drop();
49
50# Prevent various `mail`-related vulnerabilities
51sp.disable_function.function("mail").param("additional_parameters").value_r("\\-").drop();
52
53# Since it's now burned, me might as well mitigate it publicly
54sp.disable_function.function("putenv").param("assignment").value_r("LD_").drop()
55
56# This one was burned in Nov 2019 - https://gist.github.com/LoadLow/90b60bd5535d6c3927bb24d5f9955b80
57sp.disable_function.function("putenv").param("assignment").value_r("GCONV_").drop()
58
59# Since people are stupid enough to use `extract` on things like $_GET or $_POST, we might as well mitigate this vector
60sp.disable_function.function("extract").param("array").value_r("^_").drop()
61sp.disable_function.function("extract").param("flags").value("0").drop()
62
63# This is also burned:
64# ini_set('open_basedir','..');chdir('..');…;chdir('..');ini_set('open_basedir','/');echo(file_get_contents('/etc/passwd'));
65# Since we have no way of matching on two parameters at the same time, we're
66# blocking calls to open_basedir altogether: nobody is using it via ini_set anyway.
67# Moreover, there are non-public bypasses that are also using this vector ;)
68sp.disable_function.function("ini_set").param("option").value_r("open_basedir").drop()
69
70##Prevent various `include`-related vulnerabilities
71# -- "php8" is necessary here, due to the following snippet in one of the vendored Symfony dependencies
72# -- if (PHP_VERSION_ID >= 80000) {
73# -- require_once __DIR__.'/Resources/mb_convert_variables.php8';
74# -- }
75sp.disable_function.function("require_once").value_r("\.(inc|phtml|php|php8)$").allow();
76sp.disable_function.function("include_once").value_r("\.(inc|phtml|php)$").allow();
77sp.disable_function.function("require").value_r("\.(inc|phtml|php)$").allow();
78sp.disable_function.function("include").value_r("\.(inc|phtml|php)$").allow();
79sp.disable_function.function("require_once").drop()
80sp.disable_function.function("include_once").drop()
81sp.disable_function.function("require").drop()
82sp.disable_function.function("include").drop()
83
84# Prevent `system`-related injections
85sp.disable_function.function("system").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop();
86sp.disable_function.function("shell_exec").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop();
87sp.disable_function.function("exec").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop();
88sp.disable_function.function("proc_open").param("command").value_r("[$|;&`\\n\\(\\)\\\\]").drop();
89
90# Prevent runtime modification of interesting things
91# -- Xenforo applies its own set of ini rules sanitization and this cannot be disabled without a hard fork
92# sp.disable_function.function("ini_set").param("option").value("assert.active").drop();
93# sp.disable_function.function("ini_set").param("option").value("zend.assertions").drop();
94# sp.disable_function.function("ini_set").param("option").value("memory_limit").drop();
95sp.disable_function.function("ini_set").param("option").value("include_path").drop();
96sp.disable_function.function("ini_set").param("option").value("open_basedir").drop();
97
98# Detect some backdoors via environment recon
99# -- Xenforo does its own recon of the environment and this cannot be disabled without a hard fork
100# sp.disable_function.function("ini_get").param("option").value("allow_url_fopen").drop();
101# sp.disable_function.function("ini_get").param("option").value("open_basedir").drop();
102sp.disable_function.function("ini_get").param("option").value_r("suhosin").drop();
103sp.disable_function.function("function_exists").param("function").value("eval").drop();
104sp.disable_function.function("function_exists").param("function").value("exec").drop();
105sp.disable_function.function("function_exists").param("function").value("system").drop();
106sp.disable_function.function("function_exists").param("function").value("shell_exec").drop();
107sp.disable_function.function("function_exists").param("function").value("proc_open").drop();
108sp.disable_function.function("function_exists").param("function").value("passthru").drop();
109sp.disable_function.function("is_callable").param("value").value("eval").drop();
110sp.disable_function.function("is_callable").param("value").value("exec").drop();
111sp.disable_function.function("is_callable").param("value").value("system").drop();
112sp.disable_function.function("is_callable").param("value").value("shell_exec").drop();
113sp.disable_function.function("is_callable").param("value").value("proc_open").drop();
114sp.disable_function.function("is_callable").param("value").value("passthru").drop();
115
116# Ghetto error-based sqli detection
117sp.disable_function.function("mysql_query").ret("FALSE").drop();
118sp.disable_function.function("mysqli_query").ret("FALSE").drop();
119sp.disable_function.function("PDO::query").ret("FALSE").drop();
120
121# Ensure that certificates are properly verified
122sp.disable_function.function("curl_setopt").param("value").value("1").allow();
123sp.disable_function.function("curl_setopt").param("value").value("2").allow();
124# `81` is SSL_VERIFYHOST and `64` SSL_VERIFYPEER
125sp.disable_function.function("curl_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYCLIENT off.");
126sp.disable_function.function("curl_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off.");
127
128# File upload
129sp.disable_function.function("move_uploaded_file").param("destination").value_r("\\.ph").drop();
130sp.disable_function.function("move_uploaded_file").param("destination").value_r("\\.ht").drop();
131
132# Logging lockdown
133# -- Xenforo applies its own set of ini rules sanitization and this cannot be disabled without a hard fork
134# sp.disable_function.function("ini_set").param("option").value_r("error_log").drop()
135# sp.disable_function.function("ini_set").param("option").value_r("error_reporting").drop()
136# sp.disable_function.function("ini_set").param("option").value_r("display_errors").drop()
137
138# Configuration you might want to enable on production environments only
139# sp.ini.key("display_errors").set("0").ro();
140# sp.ini.key("display_startup_errors").set("0").ro();
141# sp.ini.key("expose_php").set("0").ro();