From 1a8aa70474fbd18758401c4bdd354c1a43756ccc Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Mon, 5 Mar 2018 10:45:03 +0100 Subject: Added parenthesis check around "document" elements and fixed non-existent document.window filter to window.document --- system/core/Security.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/Security.php b/system/core/Security.php index b8f76e5e2..506b4c7e8 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -134,7 +134,9 @@ class CI_Security { */ protected $_never_allowed_str = array( 'document.cookie' => '[removed]', + '(document).cookie' => '[removed]', 'document.write' => '[removed]', + '(document).write' => '[removed]', '.parentNode' => '[removed]', '.innerHTML' => '[removed]', '-moz-binding' => '[removed]', @@ -152,7 +154,7 @@ class CI_Security { */ protected $_never_allowed_regex = array( 'javascript\s*:', - '(document|(document\.)?window)\.(location|on\w*)', + '(\(?document\)?|\(?window\)?(\.document)?)\.(location|on\w*)', 'expression\s*(\(|&\#40;)', // CSS and IE 'vbscript\s*:', // IE, surprise! 'wscript\s*:', // IE @@ -905,7 +907,7 @@ class CI_Security { return str_replace( $match[1], preg_replace( - '#href=.*?(?:(?:alert|prompt|confirm)(?:\(|&\#40;)|javascript:|livescript:|mocha:|charset=|window\.|document\.|\.cookie|_filter_attributes($match[1]) ), @@ -933,7 +935,7 @@ class CI_Security { return str_replace( $match[1], preg_replace( - '#src=.*?(?:(?:alert|prompt|confirm|eval)(?:\(|&\#40;)|javascript:|livescript:|mocha:|charset=|window\.|document\.|\.cookie|_filter_attributes($match[1]) ), -- cgit v1.2.3-24-g4f1b From c4eeb617e453153134c28050d421157c730c7bc9 Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Mon, 5 Mar 2018 11:31:00 +0100 Subject: Fixed typo --- system/core/Security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Security.php b/system/core/Security.php index 506b4c7e8..091093637 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -833,7 +833,7 @@ class CI_Security { // For other tags, see if their attributes are "evil" and strip those elseif (isset($matches['attributes'])) { - // We'll store the already fitlered attributes here + // We'll store the already filtered attributes here $attributes = array(); // Attribute-catching pattern -- cgit v1.2.3-24-g4f1b