diff options
| -rw-r--r-- | config/default.rules | 2 | ||||
| -rw-r--r-- | config/default_php8.rules | 2 | ||||
| -rw-r--r-- | config/suhosin.rules | 2 | ||||
| -rw-r--r-- | doc/source/config.rst | 7 | ||||
| -rw-r--r-- | src/php_snuffleupagus.h | 2 | ||||
| -rw-r--r-- | src/snuffleupagus.c | 2 | ||||
| -rw-r--r-- | src/sp_config.c | 2 | ||||
| -rw-r--r-- | src/sp_config.h | 4 | ||||
| -rw-r--r-- | src/tests/xxe/config/disable_xxe.ini | 2 | ||||
| -rw-r--r-- | src/tests/xxe/config/disable_xxe_disable.ini | 2 | ||||
| -rw-r--r-- | src/tests/xxe/disable_xxe_dom_disabled.phpt | 4 | ||||
| -rw-r--r-- | src/tests/xxe/disable_xxe_simplexml.phpt | 3 | ||||
| -rw-r--r-- | src/tests/xxe/disable_xxe_simplexml_oop.phpt | 3 | ||||
| -rw-r--r-- | src/tests/xxe/disable_xxe_xml_parse.phpt | 5 |
14 files changed, 24 insertions, 18 deletions
diff --git a/config/default.rules b/config/default.rules index b964073..2de703b 100644 --- a/config/default.rules +++ b/config/default.rules | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | sp.harden_random.enable(); | 7 | sp.harden_random.enable(); |
| 8 | 8 | ||
| 9 | # Disabled XXE | 9 | # Disabled XXE |
| 10 | sp.disable_xxe.enable(); | 10 | sp.xxe_protection.enable(); |
| 11 | 11 | ||
| 12 | # Global configuration variables | 12 | # Global configuration variables |
| 13 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); | 13 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); |
diff --git a/config/default_php8.rules b/config/default_php8.rules index de2da5c..1d16191 100644 --- a/config/default_php8.rules +++ b/config/default_php8.rules | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | sp.harden_random.enable(); | 8 | sp.harden_random.enable(); |
| 9 | 9 | ||
| 10 | # Disabled XXE | 10 | # Disabled XXE |
| 11 | sp.disable_xxe.enable(); | 11 | sp.xxe_protection.enable(); |
| 12 | 12 | ||
| 13 | # Global configuration variables | 13 | # Global configuration variables |
| 14 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); | 14 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); |
diff --git a/config/suhosin.rules b/config/suhosin.rules index 4beb4c8..0bdc453 100644 --- a/config/suhosin.rules +++ b/config/suhosin.rules | |||
| @@ -276,6 +276,6 @@ sp.harden_random.enable(); | |||
| 276 | sp.auto_cookie_secure.enable(); | 276 | sp.auto_cookie_secure.enable(); |
| 277 | #sp.cookie.name("cookie1").samesite("lax"); | 277 | #sp.cookie.name("cookie1").samesite("lax"); |
| 278 | #sp.cookie.name("cookie2").samesite("strict");; | 278 | #sp.cookie.name("cookie2").samesite("strict");; |
| 279 | sp.disable_xxe.enable(); | 279 | sp.xxe_protection.enable(); |
| 280 | #sp.sloppy_comparison.enable(); | 280 | #sp.sloppy_comparison.enable(); |
| 281 | 281 | ||
diff --git a/doc/source/config.rst b/doc/source/config.rst index 10b0afd..63ddf7b 100644 --- a/doc/source/config.rst +++ b/doc/source/config.rst | |||
| @@ -293,14 +293,15 @@ It can either be ``enabled`` or ``disabled`` and can be used in ``simulation`` m | |||
| 293 | sp.upload_validation.script("/var/www/is_valid_php.py").enable(); | 293 | sp.upload_validation.script("/var/www/is_valid_php.py").enable(); |
| 294 | 294 | ||
| 295 | 295 | ||
| 296 | disable_xxe | 296 | xxe_protection |
| 297 | ^^^^^^^^^^^ | 297 | ^^^^^^^^^^^ |
| 298 | 298 | ||
| 299 | :ref:`disable_xxe <xxe-feature>`, enabled by default, will prevent XXE attacks by disabling the loading of external entities (``libxml_disable_entity_loader``) in the XML parser. | 299 | :ref:`xxe_protection <xxe-feature>`, disabled by default, will prevent XXE attacks by disabling the loading of external entities (``libxml_disable_entity_loader``) in the XML parser. |
| 300 | 300 | ||
| 301 | :: | 301 | :: |
| 302 | 302 | ||
| 303 | sp.disable_xxe.enable(); | 303 | sp.xxe_protection.enable(); |
| 304 | sp.xxe_protection.disable(); | ||
| 304 | 305 | ||
| 305 | 306 | ||
| 306 | Whitelist of stream-wrappers | 307 | Whitelist of stream-wrappers |
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; | |||
| 116 | sp_config_cookie config_cookie; | 116 | sp_config_cookie config_cookie; |
| 117 | sp_config_auto_cookie_secure config_auto_cookie_secure; | 117 | sp_config_auto_cookie_secure config_auto_cookie_secure; |
| 118 | sp_config_global_strict config_global_strict; | 118 | sp_config_global_strict config_global_strict; |
| 119 | sp_config_disable_xxe config_disable_xxe; | 119 | sp_config_xxe_protection config_xxe_protection; |
| 120 | sp_config_eval config_eval; | 120 | sp_config_eval config_eval; |
| 121 | sp_config_wrapper config_wrapper; | 121 | sp_config_wrapper config_wrapper; |
| 122 | sp_config_session config_session; | 122 | sp_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 | ||
| 58 | typedef struct { | 58 | typedef struct { |
| 59 | bool enable; | 59 | bool enable; |
| 60 | } sp_config_disable_xxe; | 60 | } sp_config_xxe_protection; |
| 61 | 61 | ||
| 62 | typedef struct { | 62 | typedef 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-- |
| 2 | Disable XXE | 2 | Disable 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-- |
| 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe.ini |
| 8 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
| 9 | dom | 9 | dom |
| 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 @@ | |||
| 2 | Disable XXE | 2 | Disable 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-- |
| 6 | sp.configuration_file={PWD}/config/disable_xxe.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini |
| 7 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
| 8 | simplexml | 9 | simplexml |
| 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 @@ | |||
| 2 | Disable XXE | 2 | Disable 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-- |
| 6 | sp.configuration_file={PWD}/config/disable_xxe.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini |
| 7 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
| 8 | simplexml | 9 | simplexml |
| 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); |
| 71 | xml_parser_free($parser); | 71 | xml_parser_free($parser); |
| 72 | 72 | ||
| 73 | --EXPECT-- | 73 | --EXPECTF-- |
| 74 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %a.php on line 41 | ||
| 74 | string(4) "TEST" | 75 | string(4) "TEST" |
| 75 | 76 | ||
| 76 | array(0) { | 77 | array(0) { |
| @@ -81,6 +82,8 @@ array(0) { | |||
| 81 | } | 82 | } |
| 82 | string(7) "TESTING" | 83 | string(7) "TESTING" |
| 83 | string(4) "TEST" | 84 | string(4) "TEST" |
| 85 | |||
| 86 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %a.php on line 46 | ||
| 84 | string(4) "TEST" | 87 | string(4) "TEST" |
| 85 | 88 | ||
| 86 | array(0) { | 89 | array(0) { |
