[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

dbates at webkit.org dbates at webkit.org
Thu Oct 29 20:45:49 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 857aa2268763ef6a7858b9c2ea7d18d8999c7627
Author: dbates at webkit.org <dbates at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 16 01:27:33 2009 +0000

    2009-10-15  Daniel Bates  <dbates at webkit.org>
    
            No review, rolling out r49644.
            http://trac.webkit.org/changeset/49644
    
            We need to think about this change some more. See bug #30418
            for more details.
    
            * page/XSSAuditor.cpp:
            (WebCore::XSSAuditor::canEvaluate):
            (WebCore::XSSAuditor::canEvaluateJavaScriptURL):
            (WebCore::XSSAuditor::canCreateInlineEventListener):
            (WebCore::XSSAuditor::canLoadExternalScriptFromSrc):
            (WebCore::XSSAuditor::canLoadObject):
            (WebCore::XSSAuditor::canSetBaseElementURL):
            (WebCore::XSSAuditor::findInRequest):
            * page/XSSAuditor.h:
    2009-10-15  Daniel Bates  <dbates at webkit.org>
    
            No review, rolling out r49644.
            http://trac.webkit.org/changeset/49644
    
            * http/tests/security/xssAuditor/base-href-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/base-href-comment.html: Removed.
            * http/tests/security/xssAuditor/iframe-javascript-url-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/iframe-javascript-url-comment.html: Removed.
            * http/tests/security/xssAuditor/img-onerror-HTML-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/img-onerror-HTML-comment.html: Removed.
            * http/tests/security/xssAuditor/img-onerror-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/img-onerror-comment.html: Removed.
            * http/tests/security/xssAuditor/object-tag-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/object-tag-comment.html: Removed.
            * http/tests/security/xssAuditor/resources/echo-before-image.pl: Removed.
            * http/tests/security/xssAuditor/resources/echo-head-base-href-comment.pl: Removed.
            * http/tests/security/xssAuditor/script-tag-comment-HTML-entity-expected.txt: Removed.
            * http/tests/security/xssAuditor/script-tag-comment-HTML-entity.html: Removed.
            * http/tests/security/xssAuditor/script-tag-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/script-tag-comment.html: Removed.
            * http/tests/security/xssAuditor/script-tag-with-source-comment-expected.txt: Removed.
            * http/tests/security/xssAuditor/script-tag-with-source-comment.html: Removed.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49668 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6cb63f2..b2ba566 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,27 @@
+2009-10-15  Daniel Bates  <dbates at webkit.org>
+
+        No review, rolling out r49644.
+        http://trac.webkit.org/changeset/49644
+
+        * http/tests/security/xssAuditor/base-href-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/base-href-comment.html: Removed.
+        * http/tests/security/xssAuditor/iframe-javascript-url-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/iframe-javascript-url-comment.html: Removed.
+        * http/tests/security/xssAuditor/img-onerror-HTML-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/img-onerror-HTML-comment.html: Removed.
+        * http/tests/security/xssAuditor/img-onerror-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/img-onerror-comment.html: Removed.
+        * http/tests/security/xssAuditor/object-tag-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/object-tag-comment.html: Removed.
+        * http/tests/security/xssAuditor/resources/echo-before-image.pl: Removed.
+        * http/tests/security/xssAuditor/resources/echo-head-base-href-comment.pl: Removed.
+        * http/tests/security/xssAuditor/script-tag-comment-HTML-entity-expected.txt: Removed.
+        * http/tests/security/xssAuditor/script-tag-comment-HTML-entity.html: Removed.
+        * http/tests/security/xssAuditor/script-tag-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/script-tag-comment.html: Removed.
+        * http/tests/security/xssAuditor/script-tag-with-source-comment-expected.txt: Removed.
+        * http/tests/security/xssAuditor/script-tag-with-source-comment.html: Removed.
+
 2009-10-15  Brian Weinstein  <bweinstein at apple.com>
 
         Rubber-stamped by Adele Peterson.
diff --git a/LayoutTests/http/tests/security/xssAuditor/base-href-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/base-href-comment-expected.txt
deleted file mode 100644
index 3a83578..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/base-href-comment-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request
-ALERT: This is a safe script.
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/base-href-comment.html b/LayoutTests/http/tests/security/xssAuditor/base-href-comment.html
deleted file mode 100644
index d587772..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/base-href-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-head-base-href-comment.pl?q=<base href='http://127.0.0.1:8000/security/xssAuditor/resources/base-href/?">
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/iframe-javascript-url-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/iframe-javascript-url-comment-expected.txt
deleted file mode 100644
index 513e2f8..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/iframe-javascript-url-comment-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
-
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/iframe-javascript-url-comment.html b/LayoutTests/http/tests/security/xssAuditor/iframe-javascript-url-comment.html
deleted file mode 100644
index e3bcecb..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/iframe-javascript-url-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-    layoutTestController.dumpAsText();
-    layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src='http://localhost:8000/security/xssAuditor/resources/echo-before-image.pl?q=%3Ciframe%20src=javascript:alert(document.domain)//'>
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/img-onerror-HTML-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/img-onerror-HTML-comment-expected.txt
deleted file mode 100644
index 513e2f8..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/img-onerror-HTML-comment-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
-
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/img-onerror-HTML-comment.html b/LayoutTests/http/tests/security/xssAuditor/img-onerror-HTML-comment.html
deleted file mode 100644
index 58ae003..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/img-onerror-HTML-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-before-image.pl?q=<img src=%22about%3Ablank%22 OnError %3D%22alert(/XSS/)%3B%3C%21--">
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/img-onerror-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/img-onerror-comment-expected.txt
deleted file mode 100644
index 513e2f8..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/img-onerror-comment-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
-
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/img-onerror-comment.html b/LayoutTests/http/tests/security/xssAuditor/img-onerror-comment.html
deleted file mode 100644
index 32b6631..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/img-onerror-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-before-image.pl?q=<img src=%22about%3Ablank%22 OnError %3D%22alert(/XSS/)%3B//">
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/object-tag-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/object-tag-comment-expected.txt
deleted file mode 100644
index 672136f..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/object-tag-comment-expected.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/object-tag-comment.html b/LayoutTests/http/tests/security/xssAuditor/object-tag-comment.html
deleted file mode 100644
index fd67d2e..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/object-tag-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-before-image.pl?q=<object name='plugin' type='application/x-webkit-test-netscape'><param name='movie' value=%22http://127.0.0.1:8000/security/xssAuditor/resources/dummy.swf?">
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/resources/echo-before-image.pl b/LayoutTests/http/tests/security/xssAuditor/resources/echo-before-image.pl
deleted file mode 100755
index 5f45b75..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/resources/echo-before-image.pl
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl -wT
-use strict;
-use CGI;
-
-my $cgi = new CGI;
-
-print "Content-Type: text/html; charset=UTF-8\n\n";
-
-print "<!DOCTYPE html>\n";
-print "<html>\n";
-print "<body>\n";
-print $cgi->param('q');
-print "<img src=\"dummy.jpg\">";
-print "<script></script>\n";
-print "<object></object>\n";
-print "</body>\n";
-print "</html>\n";
diff --git a/LayoutTests/http/tests/security/xssAuditor/resources/echo-head-base-href-comment.pl b/LayoutTests/http/tests/security/xssAuditor/resources/echo-head-base-href-comment.pl
deleted file mode 100755
index 1760e51..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/resources/echo-head-base-href-comment.pl
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/perl -wT
-use strict;
-use CGI;
-
-my $cgi = new CGI;
-
-print "Content-Type: text/html; charset=UTF-8\n\n";
-
-print "<!DOCTYPE html>\n";
-print "<html>\n";
-print "<head>\n";
-print $cgi->param('q');
-print "<style src='dummy'>\n";
-print "</head>\n";
-print "<body>\n";
-print "<script src='safe-script.js'></script>\n";
-print "</body>\n";
-print "</html>\n";
diff --git a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-HTML-entity-expected.txt b/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-HTML-entity-expected.txt
deleted file mode 100644
index 513e2f8..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-HTML-entity-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
-
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-HTML-entity.html b/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-HTML-entity.html
deleted file mode 100644
index f3fe61f..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-HTML-entity.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-intertag.pl?q=<script>/*xx%26copy%3B*/alert(/XSS/)</script>">
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-expected.txt
deleted file mode 100644
index 513e2f8..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
-
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment.html b/LayoutTests/http/tests/security/xssAuditor/script-tag-comment.html
deleted file mode 100644
index 0345b98..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/script-tag-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-before-image.pl?q=<script>alert(/XSS/);//">
-</iframe>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/xssAuditor/script-tag-with-source-comment-expected.txt b/LayoutTests/http/tests/security/xssAuditor/script-tag-with-source-comment-expected.txt
deleted file mode 100644
index 513e2f8..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/script-tag-with-source-comment-expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
-
-
diff --git a/LayoutTests/http/tests/security/xssAuditor/script-tag-with-source-comment.html b/LayoutTests/http/tests/security/xssAuditor/script-tag-with-source-comment.html
deleted file mode 100644
index 97cbd1a..0000000
--- a/LayoutTests/http/tests/security/xssAuditor/script-tag-with-source-comment.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.layoutTestController) {
-  layoutTestController.dumpAsText();
-  layoutTestController.setXSSAuditorEnabled(true);
-}
-</script>
-</head>
-<body>
-<iframe src="http://localhost:8000/security/xssAuditor/resources/echo-before-image.pl?q=<script src=%22http://127.0.0.1:8000/security/xssAuditor/resources/xss.js?">
-</iframe>
-</body>
-</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 23ea144..4681399 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2009-10-15  Daniel Bates  <dbates at webkit.org>
+
+        No review, rolling out r49644.
+        http://trac.webkit.org/changeset/49644
+        
+        We need to think about this change some more. See bug #30418 
+        for more details.
+
+        * page/XSSAuditor.cpp:
+        (WebCore::XSSAuditor::canEvaluate):
+        (WebCore::XSSAuditor::canEvaluateJavaScriptURL):
+        (WebCore::XSSAuditor::canCreateInlineEventListener):
+        (WebCore::XSSAuditor::canLoadExternalScriptFromSrc):
+        (WebCore::XSSAuditor::canLoadObject):
+        (WebCore::XSSAuditor::canSetBaseElementURL):
+        (WebCore::XSSAuditor::findInRequest):
+        * page/XSSAuditor.h:
+
 2009-10-14  Jon Honeycutt  <jhoneycutt at apple.com>
 
         Add SPI to determine whether a node is a halted plug-in.
diff --git a/WebCore/page/XSSAuditor.cpp b/WebCore/page/XSSAuditor.cpp
index bcc3726..890c3fa 100644
--- a/WebCore/page/XSSAuditor.cpp
+++ b/WebCore/page/XSSAuditor.cpp
@@ -46,11 +46,6 @@ using namespace WTF;
 
 namespace WebCore {
 
-// Note, we believe it is sufficient to only look at a substring of 7
-// characters (or less) of code.  Observe that "alert()" is seven characters
-// in length.
-static const unsigned minAttackLength = 7;
-
 static bool isNonCanonicalCharacter(UChar c)
 {
     // We remove all non-ASCII characters, including non-printable ASCII characters.
@@ -110,7 +105,7 @@ bool XSSAuditor::canEvaluate(const String& code) const
     if (!isEnabled())
         return true;
 
-    if (findInRequest(String(), code, false, true)) {
+    if (findInRequest(code, false, true)) {
         DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute a JavaScript script. Source code of script found within request.\n"));
         m_frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String());
         return false;
@@ -123,7 +118,7 @@ bool XSSAuditor::canEvaluateJavaScriptURL(const String& code) const
     if (!isEnabled())
         return true;
 
-    if (findInRequest(String(), code, true, false, true)) {
+    if (findInRequest(code, true, false, true)) {
         DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute a JavaScript script. Source code of script found within request.\n"));
         m_frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String());
         return false;
@@ -136,7 +131,7 @@ bool XSSAuditor::canCreateInlineEventListener(const String&, const String& code)
     if (!isEnabled())
         return true;
 
-    if (findInRequest(String(), code, true, true)) {
+    if (findInRequest(code, true, true)) {
         DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute a JavaScript script. Source code of script found within request.\n"));
         m_frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String());
         return false;
@@ -159,7 +154,7 @@ bool XSSAuditor::canLoadExternalScriptFromSrc(const String& context, const Strin
     if (m_frame->document()->url().host() == scriptURL.host() && scriptURL.query().isEmpty())
         return true;
 
-    if (findInRequest(context, url)) {
+    if (findInRequest(context + url)) {
         DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute a JavaScript script. Source code of script found within request.\n"));
         m_frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String());
         return false;
@@ -172,7 +167,7 @@ bool XSSAuditor::canLoadObject(const String& url) const
     if (!isEnabled())
         return true;
 
-    if (findInRequest(String(), url)) {
+    if (findInRequest(url)) {
         DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute a JavaScript script. Source code of script found within request"));
         m_frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String());
         return false;
@@ -186,7 +181,7 @@ bool XSSAuditor::canSetBaseElementURL(const String& url) const
         return true;
     
     KURL baseElementURL(m_frame->document()->url(), url);
-    if (m_frame->document()->url().host() != baseElementURL.host() && findInRequest(String(), url)) {
+    if (m_frame->document()->url().host() != baseElementURL.host() && findInRequest(url)) {
         DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute a JavaScript script. Source code of script found within request"));
         m_frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, consoleMessage, 1, String());
         return false;
@@ -260,19 +255,19 @@ String XSSAuditor::decodeHTMLEntities(const String& string, bool leaveUndecodabl
     return String::adopt(result);
 }
 
-bool XSSAuditor::findInRequest(const String& context, const String& string, bool decodeEntities, bool allowRequestIfNoIllegalURICharacters, 
+bool XSSAuditor::findInRequest(const String& string, bool decodeEntities, bool allowRequestIfNoIllegalURICharacters, 
                                bool decodeURLEscapeSequencesTwice) const
 {
     bool result = false;
     Frame* parentFrame = m_frame->tree()->parent();
     if (parentFrame && m_frame->document()->url() == blankURL())
-        result = findInRequest(parentFrame, context, string, decodeEntities, allowRequestIfNoIllegalURICharacters, decodeURLEscapeSequencesTwice);
+        result = findInRequest(parentFrame, string, decodeEntities, allowRequestIfNoIllegalURICharacters, decodeURLEscapeSequencesTwice);
     if (!result)
-        result = findInRequest(m_frame, context, string, decodeEntities, allowRequestIfNoIllegalURICharacters, decodeURLEscapeSequencesTwice);
+        result = findInRequest(m_frame, string, decodeEntities, allowRequestIfNoIllegalURICharacters, decodeURLEscapeSequencesTwice);
     return result;
 }
 
-bool XSSAuditor::findInRequest(Frame* frame, const String& context, const String& string, bool decodeEntities, bool allowRequestIfNoIllegalURICharacters, 
+bool XSSAuditor::findInRequest(Frame* frame, const String& string, bool decodeEntities, bool allowRequestIfNoIllegalURICharacters, 
                                bool decodeURLEscapeSequencesTwice) const
 {
     ASSERT(frame->document());
@@ -286,15 +281,13 @@ bool XSSAuditor::findInRequest(Frame* frame, const String& context, const String
         return false;
 
     FormData* formDataObj = frame->loader()->documentLoader()->originalRequest().httpBody();
-    const bool hasFormData = formDataObj && !formDataObj->isEmpty();
     String pageURL = frame->document()->url().string();
-    
-    String canonicalizedString;
-    if (!hasFormData && string.length() > 2 * pageURL.length()) {
+
+    if (!formDataObj && string.length() >= 2 * pageURL.length()) {
         // Q: Why do we bother to do this check at all?
         // A: Canonicalizing large inline scripts can be expensive.  We want to
-        //    reduce the size of the string before we call canonicalize below, 
-        //    since it could result in an unneeded allocation and memcpy.
+        //    bail out before the call to canonicalize below, which could
+        //    result in an unneeded allocation and memcpy.
         //
         // Q: Why do we multiply by two here?
         // A: We attempt to detect reflected XSS even when the server
@@ -302,37 +295,39 @@ bool XSSAuditor::findInRequest(Frame* frame, const String& context, const String
         //    attacker can do get the server to inflate his/her input by a
         //    factor of two by sending " characters, which the server
         //    transforms to \".
-        canonicalizedString = string.substring(0, 2 * pageURL.length());
-    } else
-        canonicalizedString = string;
+        return false;
+    }
 
     if (frame->document()->url().protocolIs("data"))
         return false;
 
-    canonicalizedString = canonicalize(canonicalizedString);
+    String canonicalizedString = canonicalize(string);
     if (canonicalizedString.isEmpty())
         return false;
 
-    // We only look at the first minAttackLength characters to avoid looking at
-    // characters the attacker has pulled in from the page using an attack string
-    // like: <img onerror="alert(/XSS/);//
-    canonicalizedString = canonicalizedString.substring(0, minAttackLength);
+    if (string.length() < pageURL.length()) {
+        // The string can actually fit inside the pageURL.
+        String decodedPageURL = m_cache.canonicalizeURL(pageURL, frame->document()->decoder()->encoding(), decodeEntities, decodeURLEscapeSequencesTwice);
 
-    if (!context.isEmpty())
-        canonicalizedString = context + canonicalizedString;
+        if (allowRequestIfNoIllegalURICharacters && (!formDataObj || formDataObj->isEmpty()) 
+            && decodedPageURL.find(&isIllegalURICharacter, 0) == -1)
+            return false; // Injection is impossible because the request does not contain any illegal URI characters. 
 
-    String decodedPageURL = m_cache.canonicalizeURL(pageURL, frame->document()->decoder()->encoding(), decodeEntities, decodeURLEscapeSequencesTwice);
-
-    if (allowRequestIfNoIllegalURICharacters && !hasFormData && decodedPageURL.find(&isIllegalURICharacter, 0) == -1)
-        return false; // Injection is impossible because the request does not contain any illegal URI characters. 
-
-    if (decodedPageURL.find(canonicalizedString, 0, false) != -1)
-        return true;  // We've found the string in the GET data.
+        if (decodedPageURL.find(canonicalizedString, 0, false) != -1)
+            return true;  // We've found the smoking gun.
+    }
 
-    if (hasFormData) {
-        String decodedFormData = m_cache.canonicalizeURL(formDataObj->flattenToString(), frame->document()->decoder()->encoding(), decodeEntities, decodeURLEscapeSequencesTwice);
-        if (decodedFormData.find(canonicalizedString, 0, false) != -1)
-            return true;  // We found the string in the POST data.
+    if (formDataObj && !formDataObj->isEmpty()) {
+        String formData = formDataObj->flattenToString();
+        if (string.length() < formData.length()) {
+            // Notice it is sufficient to compare the length of the string to
+            // the url-encoded POST data because the length of the url-decoded
+            // code is less than or equal to the length of the url-encoded
+            // string.
+            String decodedFormData = m_cache.canonicalizeURL(formData, frame->document()->decoder()->encoding(), decodeEntities, decodeURLEscapeSequencesTwice);
+            if (decodedFormData.find(canonicalizedString, 0, false) != -1)
+                return true;  // We found the string in the POST data.
+        }
     }
 
     return false;
diff --git a/WebCore/page/XSSAuditor.h b/WebCore/page/XSSAuditor.h
index de42720..adfa5c7 100644
--- a/WebCore/page/XSSAuditor.h
+++ b/WebCore/page/XSSAuditor.h
@@ -122,9 +122,9 @@ namespace WebCore {
                                 bool decodeURLEscapeSequencesTwice = false);
         static String decodeHTMLEntities(const String&, bool leaveUndecodableEntitiesUntouched = true);
 
-        bool findInRequest(const String& context, const String&, bool decodeEntities = true, bool allowRequestIfNoIllegalURICharacters = false, 
+        bool findInRequest(const String&, bool decodeEntities = true, bool allowRequestIfNoIllegalURICharacters = false, 
                            bool decodeURLEscapeSequencesTwice = false) const;
-        bool findInRequest(Frame*, const String& context, const String&, bool decodeEntities = true, bool allowRequestIfNoIllegalURICharacters = false, 
+        bool findInRequest(Frame*, const String&, bool decodeEntities = true, bool allowRequestIfNoIllegalURICharacters = false, 
                            bool decodeURLEscapeSequencesTwice = false) const;
 
         // The frame to audit.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list