summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-11-11 13:15:52 +0100
committerBen Fuhrmannek2021-11-11 13:15:52 +0100
commit713cb08b58d4e5dd5e7e80b1f82e27cbe52d4381 (patch)
treeb1bd945693215ca349180d44ae929f7f59427f09 /src
parent9111fdf5e6332923a5faf9f8a7e6b428eb91795a (diff)
inverted logic. set xxe_protection.enable() instead of disable_xxe.disable()
Diffstat (limited to 'src')
-rw-r--r--src/php_snuffleupagus.h2
-rw-r--r--src/snuffleupagus.c2
-rw-r--r--src/sp_config.c2
-rw-r--r--src/sp_config.h4
-rw-r--r--src/tests/xxe/config/disable_xxe.ini2
-rw-r--r--src/tests/xxe/config/disable_xxe_disable.ini2
-rw-r--r--src/tests/xxe/disable_xxe_dom_disabled.phpt4
-rw-r--r--src/tests/xxe/disable_xxe_simplexml.phpt3
-rw-r--r--src/tests/xxe/disable_xxe_simplexml_oop.phpt3
-rw-r--r--src/tests/xxe/disable_xxe_xml_parse.phpt5
10 files changed, 17 insertions, 12 deletions
diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h
index 308031b..03c9bb6 100644
--- a/src/php_snuffleupagus.h
+++ b/src/php_snuffleupagus.h
@@ -116,7 +116,7 @@ sp_config_upload_validation config_upload_validation;
116sp_config_cookie config_cookie; 116sp_config_cookie config_cookie;
117sp_config_auto_cookie_secure config_auto_cookie_secure; 117sp_config_auto_cookie_secure config_auto_cookie_secure;
118sp_config_global_strict config_global_strict; 118sp_config_global_strict config_global_strict;
119sp_config_disable_xxe config_disable_xxe; 119sp_config_xxe_protection config_xxe_protection;
120sp_config_eval config_eval; 120sp_config_eval config_eval;
121sp_config_wrapper config_wrapper; 121sp_config_wrapper config_wrapper;
122sp_config_session config_session; 122sp_config_session config_session;
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c
index 6fd6f25..c96a911 100644
--- a/src/snuffleupagus.c
+++ b/src/snuffleupagus.c
@@ -314,7 +314,7 @@ static PHP_INI_MH(OnUpdateConfiguration) {
314 hook_upload(); 314 hook_upload();
315 } 315 }
316 316
317 if (SPCFG(disable_xxe).enable == 0) { 317 if (SPCFG(xxe_protection).enable) {
318 hook_libxml_disable_entity_loader(); 318 hook_libxml_disable_entity_loader();
319 } 319 }
320 320
diff --git a/src/sp_config.c b/src/sp_config.c
index ec6c5a8..bc9aa0d 100644
--- a/src/sp_config.c
+++ b/src/sp_config.c
@@ -17,7 +17,7 @@ static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) {
17 {parse_cookie, SP_TOKEN_COOKIE_ENCRYPTION, NULL}, 17 {parse_cookie, SP_TOKEN_COOKIE_ENCRYPTION, NULL},
18 {parse_global, SP_TOKEN_GLOBAL, NULL}, 18 {parse_global, SP_TOKEN_GLOBAL, NULL},
19 {parse_enable, SP_TOKEN_AUTO_COOKIE_SECURE, &(SPCFG(auto_cookie_secure).enable)}, 19 {parse_enable, SP_TOKEN_AUTO_COOKIE_SECURE, &(SPCFG(auto_cookie_secure).enable)},
20 {parse_enable, SP_TOKEN_DISABLE_XXE, &(SPCFG(disable_xxe).enable)}, 20 {parse_enable, SP_TOKEN_XXE_PROTECTION, &(SPCFG(xxe_protection).enable)},
21 {parse_eval_filter_conf, SP_TOKEN_EVAL_BLACKLIST, &(SPCFG(eval).blacklist)}, 21 {parse_eval_filter_conf, SP_TOKEN_EVAL_BLACKLIST, &(SPCFG(eval).blacklist)},
22 {parse_eval_filter_conf, SP_TOKEN_EVAL_WHITELIST, &(SPCFG(eval).whitelist)}, 22 {parse_eval_filter_conf, SP_TOKEN_EVAL_WHITELIST, &(SPCFG(eval).whitelist)},
23 {parse_session, SP_TOKEN_SESSION_ENCRYPTION, &(SPCFG(session))}, 23 {parse_session, SP_TOKEN_SESSION_ENCRYPTION, &(SPCFG(session))},
diff --git a/src/sp_config.h b/src/sp_config.h
index 262050b..a557105 100644
--- a/src/sp_config.h
+++ b/src/sp_config.h
@@ -57,7 +57,7 @@ typedef struct {
57 57
58typedef struct { 58typedef struct {
59 bool enable; 59 bool enable;
60} sp_config_disable_xxe; 60} sp_config_xxe_protection;
61 61
62typedef struct { 62typedef struct {
63 enum samesite_type { strict = 1, lax = 2 } samesite; 63 enum samesite_type { strict = 1, lax = 2 } samesite;
@@ -202,7 +202,7 @@ typedef struct {
202#define SP_TOKEN_READONLY_EXEC "readonly_exec" 202#define SP_TOKEN_READONLY_EXEC "readonly_exec"
203#define SP_TOKEN_UNSERIALIZE_HMAC "unserialize_hmac" 203#define SP_TOKEN_UNSERIALIZE_HMAC "unserialize_hmac"
204#define SP_TOKEN_UPLOAD_VALIDATION "upload_validation" 204#define SP_TOKEN_UPLOAD_VALIDATION "upload_validation"
205#define SP_TOKEN_DISABLE_XXE "disable_xxe" 205#define SP_TOKEN_XXE_PROTECTION "xxe_protection"
206#define SP_TOKEN_EVAL_BLACKLIST "eval_blacklist" 206#define SP_TOKEN_EVAL_BLACKLIST "eval_blacklist"
207#define SP_TOKEN_EVAL_WHITELIST "eval_whitelist" 207#define SP_TOKEN_EVAL_WHITELIST "eval_whitelist"
208#define SP_TOKEN_SLOPPY_COMPARISON "sloppy_comparison" 208#define SP_TOKEN_SLOPPY_COMPARISON "sloppy_comparison"
diff --git a/src/tests/xxe/config/disable_xxe.ini b/src/tests/xxe/config/disable_xxe.ini
index bc9d1f2..a50a3b9 100644
--- a/src/tests/xxe/config/disable_xxe.ini
+++ b/src/tests/xxe/config/disable_xxe.ini
@@ -1 +1 @@
sp.disable_xxe.enable(); sp.xxe_protection.enable();
diff --git a/src/tests/xxe/config/disable_xxe_disable.ini b/src/tests/xxe/config/disable_xxe_disable.ini
index bb1e432..eaf5755 100644
--- a/src/tests/xxe/config/disable_xxe_disable.ini
+++ b/src/tests/xxe/config/disable_xxe_disable.ini
@@ -1 +1 @@
sp.disable_xxe.disable(); sp.xxe_protection.disable();
diff --git a/src/tests/xxe/disable_xxe_dom_disabled.phpt b/src/tests/xxe/disable_xxe_dom_disabled.phpt
index a49e094..107171c 100644
--- a/src/tests/xxe/disable_xxe_dom_disabled.phpt
+++ b/src/tests/xxe/disable_xxe_dom_disabled.phpt
@@ -1,10 +1,10 @@
1--TEST-- 1--TEST--
2Disable XXE 2Disable XXE (feature enabled)
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> 4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?>
5<?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> 5<?php if (PHP_VERSION_ID >= 80000) print "skip"; ?>
6--INI-- 6--INI--
7sp.configuration_file={PWD}/config/disable_xxe_disable.ini 7sp.configuration_file={PWD}/config/disable_xxe.ini
8--EXTENSIONS-- 8--EXTENSIONS--
9dom 9dom
10--FILE-- 10--FILE--
diff --git a/src/tests/xxe/disable_xxe_simplexml.phpt b/src/tests/xxe/disable_xxe_simplexml.phpt
index 1d3ef4c..9560156 100644
--- a/src/tests/xxe/disable_xxe_simplexml.phpt
+++ b/src/tests/xxe/disable_xxe_simplexml.phpt
@@ -2,8 +2,9 @@
2Disable XXE 2Disable XXE
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?> 4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?>
5<?php if (PHP_VERSION_ID >= 80000) print "skip"; ?>
5--INI-- 6--INI--
6sp.configuration_file={PWD}/config/disable_xxe.ini 7sp.configuration_file={PWD}/config/disable_xxe_disable.ini
7--EXTENSIONS-- 8--EXTENSIONS--
8simplexml 9simplexml
9--XFAIL-- 10--XFAIL--
diff --git a/src/tests/xxe/disable_xxe_simplexml_oop.phpt b/src/tests/xxe/disable_xxe_simplexml_oop.phpt
index e101337..1b2c4ca 100644
--- a/src/tests/xxe/disable_xxe_simplexml_oop.phpt
+++ b/src/tests/xxe/disable_xxe_simplexml_oop.phpt
@@ -2,8 +2,9 @@
2Disable XXE 2Disable XXE
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?> 4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?>
5<?php if (PHP_VERSION_ID >= 80000) print "skip"; ?>
5--INI-- 6--INI--
6sp.configuration_file={PWD}/config/disable_xxe.ini 7sp.configuration_file={PWD}/config/disable_xxe_disable.ini
7--EXTENSIONS-- 8--EXTENSIONS--
8simplexml 9simplexml
9--XFAIL-- 10--XFAIL--
diff --git a/src/tests/xxe/disable_xxe_xml_parse.phpt b/src/tests/xxe/disable_xxe_xml_parse.phpt
index 6b48bea..bc7e338 100644
--- a/src/tests/xxe/disable_xxe_xml_parse.phpt
+++ b/src/tests/xxe/disable_xxe_xml_parse.phpt
@@ -70,7 +70,8 @@ $parser = create_parser();
70$doc = xml_parse($parser, $xml, true); 70$doc = xml_parse($parser, $xml, true);
71xml_parser_free($parser); 71xml_parser_free($parser);
72 72
73--EXPECT-- 73--EXPECTF--
74Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %a.php on line 41
74string(4) "TEST" 75string(4) "TEST"
75 76
76array(0) { 77array(0) {
@@ -81,6 +82,8 @@ array(0) {
81} 82}
82string(7) "TESTING" 83string(7) "TESTING"
83string(4) "TEST" 84string(4) "TEST"
85
86Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %a.php on line 46
84string(4) "TEST" 87string(4) "TEST"
85 88
86array(0) { 89array(0) {