-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[M68 Merge] Fixed CSP directive value parsing accepted character range
[email protected] (cherry picked from commit 5b8466d) Bug: 845961 Change-Id: Ifc9609058cd7cbd268785db46534e3ed09da6ce3 Reviewed-on: https://chromium-review.googlesource.com/1071510 Commit-Queue: Andy Paicu <[email protected]> Reviewed-by: Mike West <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#561834} Reviewed-on: https://chromium-review.googlesource.com/1080929 Reviewed-by: Andrew Whalley <[email protected]> Cr-Commit-Position: refs/branch-heads/3440@{#62} Cr-Branched-From: 010ddcf-refs/heads/master@{#561733}
- Loading branch information
Andrew R. Whalley
committed
May 31, 2018
1 parent
33cf620
commit a318c5d
Showing
5 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
144 changes: 144 additions & 0 deletions
144
...s/external/wpt/content-security-policy/embedded-enforcement/required_csp-header-crlf.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Embedded Enforcement: Sec-Required-CSP header.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support/testharness-helper.sub.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
var tests = [ | ||
// CRLF characters | ||
{ "name": "\\r\\n character after directive name", | ||
"csp": "script-src\r\n'unsafe-inline'", | ||
"expected": null }, | ||
{ "name": "\\r\\n character in directive value", | ||
"csp": "script-src 'unsafe-inline'\r\n'unsafe-eval'", | ||
"expected": null }, | ||
{ "name": "\\n character after directive name", | ||
"csp": "script-src\n'unsafe-inline'", | ||
"expected": null }, | ||
{ "name": "\\n character in directive value", | ||
"csp": "script-src 'unsafe-inline'\n'unsafe-eval'", | ||
"expected": null }, | ||
{ "name": "\\r character after directive name", | ||
"csp": "script-src\r'unsafe-inline'", | ||
"expected": null }, | ||
{ "name": "\\r character in directive value", | ||
"csp": "script-src 'unsafe-inline'\r'unsafe-eval'", | ||
"expected": null }, | ||
|
||
// HTML encoded CRLF characters | ||
{ "name": "%0D%0A character after directive name", | ||
"csp": "script-src%0D%0A'unsafe-inline'", | ||
"expected": null }, | ||
{ "name": "%0D%0A character in directive value", | ||
"csp": "script-src 'unsafe-inline'%0D%0A'unsafe-eval'", | ||
"expected": null }, | ||
{ "name": "%0A character after directive name", | ||
"csp": "script-src%0A'unsafe-inline'", | ||
"expected": null }, | ||
{ "name": "%0A character in directive value", | ||
"csp": "script-src 'unsafe-inline'%0A'unsafe-eval'", | ||
"expected": null }, | ||
{ "name": "%0D character after directive name", | ||
"csp": "script-src%0D'unsafe-inline'", | ||
"expected": null }, | ||
{ "name": "%0D character in directive value", | ||
"csp": "script-src 'unsafe-inline'%0D'unsafe-eval'", | ||
"expected": null }, | ||
|
||
// Attempt HTTP Header injection | ||
{ "name": "Attempt injecting after directive name using \\r\\n", | ||
"csp": "script-src\r\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive name using \\r", | ||
"csp": "script-src\rTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive name using \\n", | ||
"csp": "script-src\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
{ "name": "Attempt injecting after directive value using \\r\\n", | ||
"csp": "script-src example.com\r\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive value using \\r", | ||
"csp": "script-src example.com\rTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive value using \\n", | ||
"csp": "script-src example.com\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
{ "name": "Attempt injecting after semicolon using \\r\\n", | ||
"csp": "script-src example.com;\r\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after semicolon using \\r", | ||
"csp": "script-src example.com;\rTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after semicolon using \\n", | ||
"csp": "script-src example.com;\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
{ "name": "Attempt injecting after space between name and value using \\r\\n", | ||
"csp": "script-src \r\nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after space between name and value using \\r", | ||
"csp": "script-src \rTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after space between name and value using \\n", | ||
"csp": "script-src \nTest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
// Attempt HTTP Header injection using URL encoded characters | ||
{ "name": "Attempt injecting after directive name using %0D%0A", | ||
"csp": "script-src%0D%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive name using %0D", | ||
"csp": "script-src%0DTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive name using %0A", | ||
"csp": "script-src%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
{ "name": "Attempt injecting after directive value using %0D%0A", | ||
"csp": "script-src example.com%0D%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive value using %0D", | ||
"csp": "script-src example.com%0DTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after directive value using %0A", | ||
"csp": "script-src example.com%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
{ "name": "Attempt injecting after semicolon using %0D%0A", | ||
"csp": "script-src example.com;%0D%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after semicolon using %0D", | ||
"csp": "script-src example.com;%0DTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after semicolon using %0A", | ||
"csp": "script-src example.com;%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
{ "name": "Attempt injecting after space between name and value using %0D%0A", | ||
"csp": "script-src %0D%0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after space between name and value using %0D", | ||
"csp": "script-src %0DTest-Header-Injection: dummy", | ||
"expected": null }, | ||
{ "name": "Attempt injecting after space between name and value using %0A", | ||
"csp": "script-src %0ATest-Header-Injection: dummy", | ||
"expected": null }, | ||
|
||
]; | ||
|
||
tests.forEach(test => { | ||
async_test(t => { | ||
var url = generateURLString(Host.SAME_ORIGIN, PolicyHeader.REQUIRED_CSP); | ||
assert_required_csp(t, url, test.csp, [test.expected]); | ||
}, "Test CRLF: " + test.name); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
7 changes: 6 additions & 1 deletion
7
...ts/external/wpt/content-security-policy/embedded-enforcement/support/echo-required-csp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters