Commit fae997a2 authored by Tom Sepez's avatar Tom Sepez Committed by Commit Bot

XSSAuditor: do not look for reflection in URL fragment.

The server never sees it, so it can't be part of a reflected XSS. It
may be part of a DOM XSS, but XSSAuditor doesn't handle these, except
for a few document.write() cases that aren't likely to manifest in
the wild (but are hit by tests).

Bug: 877347
Change-Id: I6835c7702d0a8db829f5fde17be15015112a5e13
Reviewed-on: https://chromium-review.googlesource.com/c/1336368Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608430}
parent b268b3ed
CONSOLE ERROR: line 6: The XSS Auditor refused to execute a script in 'http://localhost:8000/security/xssAuditor/resources/echo-dom-write-location.php?#%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E' because its source code was found within the request. The server sent an 'X-XSS-Protection' header requesting this behavior.
CONSOLE ERROR: line 21: The XSS Auditor refused to execute a script in 'http://localhost:8000/security/xssAuditor/resources/anchor-url-dom-write-location-click.php#%3Ca%20id%3D%22anchorLink%22%20href%3D%22%23%22%20onclick%3D%22alert%280%29%22%3EClick%3C/a%3E' because its source code was found within the request. The server sent an 'X-XSS-Protection' header requesting this behavior.
CONSOLE ERROR: line 21: The XSS Auditor refused to execute a script in 'http://localhost:8000/security/xssAuditor/resources/anchor-url-dom-write-location-click.php#%3Ca%20id%3D%22anchorLink%22%20href%3D%22%23%22%20onclick%3D%22al%00ert%280%29%22%3EClick%3C/a%3E' because its source code was found within the request. The server sent an 'X-XSS-Protection' header requesting this behavior.
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setXSSAuditorEnabled(true);
}
</script>
</head>
<body>
<iframe src='http://localhost:8000/security/xssAuditor/resources/anchor-url-dom-write-location-click.php#%3Ca%20id%3D%22anchorLink%22%20href%3D%22%23%22%20onclick%3D%22al%00ert%280%29%22%3EClick%3C/a%3E'>
</iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setXSSAuditorEnabled(true);
}
</script>
</head>
<body>
<iframe src='http://localhost:8000/security/xssAuditor/resources/anchor-url-dom-write-location-click.php#%3Ca%20id%3D%22anchorLink%22%20href%3D%22%23%22%20onclick%3D%22alert%280%29%22%3EClick%3C/a%3E'>
</iframe>
</body>
</html>
CONSOLE ERROR: line 21: The XSS Auditor refused to execute a script in 'http://localhost:8000/security/xssAuditor/resources/anchor-url-dom-write-location-click.php#%3Ca%20id=%22anchorLink%22%20href=%22javascript:alert(String.fromCharCode(0x58,0x53,0x53))%22%3EClick%3C/a%3E' because its source code was found within the request. The server sent an 'X-XSS-Protection' header requesting this behavior.
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setXSSAuditorEnabled(true);
}
</script>
</head>
<body>
<iframe src='http://localhost:8000/security/xssAuditor/resources/anchor-url-dom-write-location-click.php#%3Ca%20id=%22anchorLink%22%20href=%22javascript:alert(String.fromCharCode(0x58,0x53,0x53))%22%3EClick%3C/a%3E'>
</iframe>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setXSSAuditorEnabled(true);
}
</script>
</head>
<body>
<iframe src='http://localhost:8000/security/xssAuditor/resources/echo-dom-write-location.php?#<script>alert(String.fromCharCode(0x58,0x53,0x53))</script>'>
</iframe>
</body>
</html>
...@@ -374,7 +374,9 @@ void XSSAuditor::Init(Document* document, ...@@ -374,7 +374,9 @@ void XSSAuditor::Init(Document* document,
if (!is_enabled_) if (!is_enabled_)
return; return;
document_url_ = document->Url().Copy(); document_url_ = document->Url();
document_url_.RemoveFragmentIdentifier();
document_url_ = document_url_.Copy(); // Make thread safe.
// In theory, the Document could have detached from the LocalFrame after the // In theory, the Document could have detached from the LocalFrame after the
// XSSAuditor was constructed. // XSSAuditor was constructed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment