summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2017-12-04 16:09:50 +0100
committerjvoisin2017-12-04 16:09:50 +0100
commit32476340c5fd3c76b86487a92fd5c5075342ca99 (patch)
tree0d5de876ae0d3e19544dfcbb3454218aa8654aac
parent2e9d73756cff850569bdbf563815f9f3f3ded06e (diff)
Fix the configuration parser wrt. non-matching brackets
This validation step is a bit idiotic, but we'll replace it with a proper parser anyway.
-rw-r--r--config/examples.ini10
-rw-r--r--src/sp_config_utils.c9
-rw-r--r--src/tests/broken_conf_quotes.phpt9
-rw-r--r--src/tests/broken_regexp.phpt1
-rw-r--r--src/tests/config/broken_conf_quotes.ini3
-rw-r--r--src/tests/example_configuration.phpt2
6 files changed, 23 insertions, 11 deletions
diff --git a/config/examples.ini b/config/examples.ini
index 68a363d..664a67a 100644
--- a/config/examples.ini
+++ b/config/examples.ini
@@ -9,7 +9,6 @@ sp.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");
13sp.disable_function.filename("/core/lib/language_manager.php").function("ALanguageManager>_clone_language_rows").param("from_language").value_r("[^0-9]").drop(); 12sp.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(); 13sp.disable_function.filename("/admin/model/tool/backup.php").function("ModelToolBackup>createBackupTask").param("data[table_list]").value_r("'").drop();
15 14
@@ -25,7 +24,7 @@ sp.disable_function.filename("/modules/Calendar/Activity.php").function("save_mo
25 24
26# The State of Wordpress Security <https://blog.ripstech.com/2016/the-state-of-wordpress-security> 25# The State of Wordpress Security <https://blog.ripstech.com/2016/the-state-of-wordpress-security>
27# All In One WP Security & Firewall 26# 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(); 27sp.disable_function.filename("/admin/wp-security-dashboard-menu.php").function("render_tab3").var("_REQUEST[tab]").value_r("\"").drop();
29 28
30 29
31# PHPKit 1.6.6: Code Execution for Privileged Users <https://blog.ripstech.com/2016/phpkit-code-exection-for-privileged-users> 30# PHPKit 1.6.6: Code Execution for Privileged Users <https://blog.ripstech.com/2016/phpkit-code-exection-for-privileged-users>
@@ -33,15 +32,10 @@ sp.disable_function.filename("/pkinc/func/default.php").function("move_uploaded_
33 32
34 33
35# Coppermine 1.5.42: Second-Order Command Execution <https://blog.ripstech.com/2016/coppermine-second-order-command-execution> 34# 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(); 35sp.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(); 36sp.disable_function.filename("/forgot_passwd.php").function("cpg_db_query").var("CLEAN[id]").value_r("[^a-z0-9]").drop();
38 37
39 38
40# CVE-2014-1610 - Mediawiki RCE
41sp.disable_function.filename("/includes/media/DjVu.php")
42sp.disable_function.filename("/includes/media/ImageHandler.php").var("_GET[page]").value_r("[^0-9]").drop()
43
44
45# CVE-2017-1001000 - https://blog.sucuri.net/2017/02/content-injection-vulnerability-wordpress-rest-api.html 39# 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(); 40sp.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(); 41sp.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_utils.c b/src/sp_config_utils.c
index 71dd373..1a797e5 100644
--- a/src/sp_config_utils.c
+++ b/src/sp_config_utils.c
@@ -20,7 +20,12 @@ static int validate_str(const char *value) {
20 return -1; 20 return -1;
21 } 21 }
22 } 22 }
23 return balance != 0; 23 if (balance != 0) {
24 sp_log_err("config", "You forgot to close %d bracket%c in the string '%s'",
25 balance, (balance>1)?'s':' ', value);
26 return -1;
27 }
28 return 0;
24} 29}
25 30
26int parse_keywords(sp_config_functions *funcs, char *line) { 31int parse_keywords(sp_config_functions *funcs, char *line) {
@@ -112,7 +117,7 @@ err:
112 sp_log_err("error", 117 sp_log_err("error",
113 "There is an issue with the parsing of '%s': it doesn't look like a valid string on line %zu.", 118 "There is an issue with the parsing of '%s': it doesn't look like a valid string on line %zu.",
114 original_line ? original_line : "NULL", sp_line_no); 119 original_line ? original_line : "NULL", sp_line_no);
115} 120 }
116 line = NULL; 121 line = NULL;
117 return NULL; 122 return NULL;
118} 123}
diff --git a/src/tests/broken_conf_quotes.phpt b/src/tests/broken_conf_quotes.phpt
new file mode 100644
index 0000000..7f754e6
--- /dev/null
+++ b/src/tests/broken_conf_quotes.phpt
@@ -0,0 +1,9 @@
1--TEST--
2Broken configuration - missing quote
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/broken_conf_quotes.ini
7--FILE--
8--EXPECT--
9[snuffleupagus][0.0.0.0][config][error] You forgot to close 1 bracket in the string '_SERVER[PHP_SELF'
diff --git a/src/tests/broken_regexp.phpt b/src/tests/broken_regexp.phpt
index 3367997..680cf22 100644
--- a/src/tests/broken_regexp.phpt
+++ b/src/tests/broken_regexp.phpt
@@ -6,4 +6,5 @@ Broken regexp
6sp.configuration_file={PWD}/config/broken_regexp.ini 6sp.configuration_file={PWD}/config/broken_regexp.ini
7--FILE-- 7--FILE--
8--EXPECTF-- 8--EXPECTF--
9[snuffleupagus][0.0.0.0][config][error] You forgot to close 1 bracket in the string '^$['
9[snuffleupagus][0.0.0.0][config][error] '.value_r()' is expecting a valid regexp, and not '"^$["' on line 1. 10[snuffleupagus][0.0.0.0][config][error] '.value_r()' is expecting a valid regexp, and not '"^$["' on line 1.
diff --git a/src/tests/config/broken_conf_quotes.ini b/src/tests/config/broken_conf_quotes.ini
new file mode 100644
index 0000000..7c3b0cd
--- /dev/null
+++ b/src/tests/config/broken_conf_quotes.ini
@@ -0,0 +1,3 @@
1sp.disable_function.filename("static_pages/index.php").var("_SERVER[PHP_SELF").value_r("\"").drop().alias("XSS");
2sp.disable_function.filename("include/imageobject_im.class.php").function("exec").var("CONFIG[im_options]).value_r("[^a-z0-9]").drop();
3
diff --git a/src/tests/example_configuration.phpt b/src/tests/example_configuration.phpt
index 0bbf59c..b7fec48 100644
--- a/src/tests/example_configuration.phpt
+++ b/src/tests/example_configuration.phpt
@@ -6,7 +6,7 @@ Shipped configuration
6sp.configuration_file={PWD}/../../config/examples.ini 6sp.configuration_file={PWD}/../../config/examples.ini
7--FILE-- 7--FILE--
8<?php 8<?php
9system("echo 0"); 9echo 0;
10?> 10?>
11--EXPECTF-- 11--EXPECTF--
120 120