summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2017-11-06 14:24:24 +0100
committerblotus2017-11-06 14:24:24 +0100
commit8070f622122344ae52b55c3f80e43a1733ae59e2 (patch)
treec117f5a2a27efb04a4161c2809b26641a2fec0e4
parent27876d63eecbac187921dcf9e8ab2b3341302c05 (diff)
53 absolute path (#62)
* Add error for relative path
-rw-r--r--config/examples.ini30
-rw-r--r--src/sp_config_keywords.c9
-rw-r--r--src/tests/broken_conf_invalid_filename.phpt9
-rw-r--r--src/tests/config/broken_conf_invalid_filename.ini1
-rw-r--r--src/tests/config/config_disabled_functions_param_allow.ini2
-rw-r--r--src/tests/config/disabled_functions.ini2
6 files changed, 34 insertions, 19 deletions
diff --git a/config/examples.ini b/config/examples.ini
index c522f1a..68a363d 100644
--- a/config/examples.ini
+++ b/config/examples.ini
@@ -1,47 +1,47 @@
1# Restrict system calls to specific file 1# Restrict system calls to specific file
2sp.disable_function.function("system").filename("update.php").allow(); 2sp.disable_function.function("system").filename("/update.php").allow();
3sp.disable_function.function("system").drop(); 3sp.disable_function.function("system").drop();
4 4
5 5
6# Restrict system calls to specific file with a specific hash 6# Restrict system calls to specific file with a specific hash
7sp.disable_function.function("system").filename("update.php").hash("d27c6c5686bc129716b6aac8dfefe2d519a80eb6cc144e97ad42c728d423eed0").allow(); 7sp.disable_function.function("system").filename("/update.php").hash("d27c6c5686bc129716b6aac8dfefe2d519a80eb6cc144e97ad42c728d423eed0").allow();
8sp.disable_function.function("system").drop(); 8sp.disable_function.function("system").drop();
9 9
10 10
11# AbanteCart 1.2.8 - Multiple SQL Injections <https://blog.ripstech.com/2016/abantecart-multiple-sql-injections> 11# AbanteCart 1.2.8 - Multiple SQL Injections <https://blog.ripstech.com/2016/abantecart-multiple-sql-injections>
12sp.disable_function.filename("static_pages/index.php").var("_SERVER[PHP_SELF").value_r("\"").drop().alias("XSS"); 12sp.disable_function.filename("/static_pages/index.php").var("_SERVER[PHP_SELF").value_r("\"").drop().alias("XSS");
13sp.disable_function.filename("core/lib/language_manager.php").function("ALanguageManager>_clone_language_rows").param("from_language").value_r("[^0-9]").drop(); 13sp.disable_function.filename("/core/lib/language_manager.php").function("ALanguageManager>_clone_language_rows").param("from_language").value_r("[^0-9]").drop();
14sp.disable_function.filename("admin/model/tool/backup.php").function("ModelToolBackup>createBackupTask").param("data[table_list]").value_r("'").drop(); 14sp.disable_function.filename("/admin/model/tool/backup.php").function("ModelToolBackup>createBackupTask").param("data[table_list]").value_r("'").drop();
15 15
16 16
17# Redaxo 5.2.0: Remote Code Execution via CSRF <https://blog.ripstech.com/2016/redaxo-remote-code-execution-via-csrf> 17# Redaxo 5.2.0: Remote Code Execution via CSRF <https://blog.ripstech.com/2016/redaxo-remote-code-execution-via-csrf>
18# See <http://code.vtiger.com/vtiger/vtigercrm/commit/9b5c5338f80237ae072a06e1ba4a5cfcbfe063b0> for details 18# See <http://code.vtiger.com/vtiger/vtigercrm/commit/9b5c5338f80237ae072a06e1ba4a5cfcbfe063b0> for details
19sp.disable_function.filename("redaxo/src/addons/structure/pages/linkmap.php").function("substr").param("string").value_r("\"").drop(); 19sp.disable_function.filename("/redaxo/src/addons/structure/pages/linkmap.php").function("substr").param("string").value_r("\"").drop();
20 20
21 21
22# Guest Post: Vtiger 6.5.0 - SQL Injection <https://blog.ripstech.com/2016/vtiger-sql-injection/> 22# Guest Post: Vtiger 6.5.0 - SQL Injection <https://blog.ripstech.com/2016/vtiger-sql-injection/>
23sp.disable_function.filename("modules/Calendar/Activity.php").function("save_module").param("query").value_r("[^0-9;]").drop(); 23sp.disable_function.filename("/modules/Calendar/Activity.php").function("save_module").param("query").value_r("[^0-9;]").drop();
24 24
25 25
26# The State of Wordpress Security <https://blog.ripstech.com/2016/the-state-of-wordpress-security> 26# The State of Wordpress Security <https://blog.ripstech.com/2016/the-state-of-wordpress-security>
27# All In One WP Security & Firewall 27# All In One WP Security & Firewall
28sp.disable_function.filename("admin/wp-security-dashboard-menu.php").function("render_tab3").var("_REQUEST[tab]]").value_r("\"").drop(); 28sp.disable_function.filename("/admin/wp-security-dashboard-menu.php").function("render_tab3").var("_REQUEST[tab]]").value_r("\"").drop();
29 29
30 30
31# PHPKit 1.6.6: Code Execution for Privileged Users <https://blog.ripstech.com/2016/phpkit-code-exection-for-privileged-users> 31# PHPKit 1.6.6: Code Execution for Privileged Users <https://blog.ripstech.com/2016/phpkit-code-exection-for-privileged-users>
32sp.disable_function.filename("pkinc/func/default.php").function("move_uploaded_file").param("destination").value_r("\\.ph\\.+$").drop(); 32sp.disable_function.filename("/pkinc/func/default.php").function("move_uploaded_file").param("destination").value_r("\\.ph\\.+$").drop();
33 33
34 34
35# Coppermine 1.5.42: Second-Order Command Execution <https://blog.ripstech.com/2016/coppermine-second-order-command-execution> 35# Coppermine 1.5.42: Second-Order Command Execution <https://blog.ripstech.com/2016/coppermine-second-order-command-execution>
36sp.disable_function.filename("include/imageobject_im.class.php").function("exec").var("CONFIG[im_options]).value_r("[^a-z0-9]").drop(); 36sp.disable_function.filename("/include/imageobject_im.class.php").function("exec").var("CONFIG[im_options]).value_r("[^a-z0-9]").drop();
37sp.disable_function.filename("forgot_passwd.php").function("cpg_db_query").var("CLEAN[id]").value_r("[^a-z0-9]").drop(); 37sp.disable_function.filename("/forgot_passwd.php").function("cpg_db_query").var("CLEAN[id]").value_r("[^a-z0-9]").drop();
38 38
39 39
40# CVE-2014-1610 - Mediawiki RCE 40# CVE-2014-1610 - Mediawiki RCE
41sp.disable_function.filename("includes/media/DjVu.php") 41sp.disable_function.filename("/includes/media/DjVu.php")
42sp.disable_function.filename("includes/media/ImageHandler.php").var("_GET[page]").value_r("[^0-9]").drop() 42sp.disable_function.filename("/includes/media/ImageHandler.php").var("_GET[page]").value_r("[^0-9]").drop()
43 43
44 44
45# CVE-2017-1001000 - https://blog.sucuri.net/2017/02/content-injection-vulnerability-wordpress-rest-api.html 45# CVE-2017-1001000 - https://blog.sucuri.net/2017/02/content-injection-vulnerability-wordpress-rest-api.html
46sp.disable_function.filename("wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php").function("register_routes").var("_GET[id]").value_r("[^0-9]").drop(); 46sp.disable_function.filename("/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php").function("register_routes").var("_GET[id]").value_r("[^0-9]").drop();
47sp.disable_function.filename("wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php").function("register_routes").var("_POST[id]").value_r("[^0-9]").drop(); \ No newline at end of file 47sp.disable_function.filename("/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php").function("register_routes").var("_POST[id]").value_r("[^0-9]").drop();
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index b1b22b5..34b855a 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -197,7 +197,7 @@ int parse_disabled_functions(char *line) {
197 MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret"); 197 MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "r_ret", "ret");
198#undef MUTUALLY_EXCLUSIVE 198#undef MUTUALLY_EXCLUSIVE
199 199
200 if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) { 200 if (1 < ((df->r_param?1:0) + (df->param?1:0) + ((-1 != df->pos)?1:0))) {
201 sp_log_err("config", 201 sp_log_err("config",
202 "Invalid configuration line: 'sp.disabled_functions%s':" 202 "Invalid configuration line: 'sp.disabled_functions%s':"
203 "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.", 203 "'.r_param', '.param' and '.pos' are mutually exclusive on line %zu.",
@@ -215,6 +215,12 @@ int parse_disabled_functions(char *line) {
215 " must take a function name on line %zu.", 215 " must take a function name on line %zu.",
216 line, sp_line_no); 216 line, sp_line_no);
217 return -1; 217 return -1;
218 } else if (df->filename && *df->filename != '/') {
219 sp_log_err("config",
220 "Invalid configuration line: 'sp.disabled_functions%s':"
221 "'.filename' must be an absolute path on line %zu.",
222 line, sp_line_no);
223 return -1;
218 } else if (!(allow ^ drop)) { 224 } else if (!(allow ^ drop)) {
219 sp_log_err("config", 225 sp_log_err("config",
220 "Invalid configuration line: 'sp.disabled_functions%s': The " 226 "Invalid configuration line: 'sp.disabled_functions%s': The "
@@ -244,7 +250,6 @@ int parse_disabled_functions(char *line) {
244 return -1; 250 return -1;
245 } 251 }
246 } 252 }
247
248 df->allow = allow; 253 df->allow = allow;
249 254
250 if (df->function) { 255 if (df->function) {
diff --git a/src/tests/broken_conf_invalid_filename.phpt b/src/tests/broken_conf_invalid_filename.phpt
new file mode 100644
index 0000000..61b967b
--- /dev/null
+++ b/src/tests/broken_conf_invalid_filename.phpt
@@ -0,0 +1,9 @@
1--TEST--
2Broken configuration filename without absolute path
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/broken_conf_invalid_filename.ini
7--FILE--
8--EXPECTF--
9[snuffleupagus][0.0.0.0][config][error] Invalid configuration line: 'sp.disabled_functions.function("sprintf").filename("wrong file name").drop();':'.filename' must be an absolute path on line 1.
diff --git a/src/tests/config/broken_conf_invalid_filename.ini b/src/tests/config/broken_conf_invalid_filename.ini
new file mode 100644
index 0000000..1be3b51
--- /dev/null
+++ b/src/tests/config/broken_conf_invalid_filename.ini
@@ -0,0 +1 @@
sp.disable_function.function("sprintf").filename("wrong file name").drop();
diff --git a/src/tests/config/config_disabled_functions_param_allow.ini b/src/tests/config/config_disabled_functions_param_allow.ini
index aa86f52..8e139e4 100644
--- a/src/tests/config/config_disabled_functions_param_allow.ini
+++ b/src/tests/config/config_disabled_functions_param_allow.ini
@@ -1,3 +1,3 @@
1sp.disable_function.function("system").param("command").value("echo win").filename("test.php").drop(); 1sp.disable_function.function("system").param("command").value("echo win").filename("/test.php").drop();
2sp.disable_function.function("system").param("command").value("echo win").allow(); 2sp.disable_function.function("system").param("command").value("echo win").allow();
3sp.disable_function.function("system").drop(); 3sp.disable_function.function("system").drop();
diff --git a/src/tests/config/disabled_functions.ini b/src/tests/config/disabled_functions.ini
index 18aab27..226a107 100644
--- a/src/tests/config/disabled_functions.ini
+++ b/src/tests/config/disabled_functions.ini
@@ -4,5 +4,5 @@ sp.disable_function.function("printf").disable().drop();
4sp.disable_function.function("printf").simulation().drop(); 4sp.disable_function.function("printf").simulation().drop();
5sp.disable_function.function("print").disable().drop(); # this is a comment 5sp.disable_function.function("print").disable().drop(); # this is a comment
6sp.disable_function.function_r("^var_dump$").drop(); 6sp.disable_function.function_r("^var_dump$").drop();
7sp.disable_function.function("sprintf").filename("wrong file name").drop(); 7sp.disable_function.function("sprintf").filename("/wrong file name").drop();
8sp.disable_function.function("eval").drop(); 8sp.disable_function.function("eval").drop();