|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<title>Embedded Enforcement: Sec-Required-CSP header.</title> |
| 5 | + <script src="/resources/testharness.js"></script> |
| 6 | + <script src="/resources/testharnessreport.js"></script> |
| 7 | + <script src="support/testharness-helper.sub.js"></script> |
| 8 | +</head> |
| 9 | +<body> |
| 10 | + <script> |
| 11 | + var tests = [ |
| 12 | + // CRLF characters |
| 13 | + { "name": "\\r\\n character after directive name", |
| 14 | + "csp": "script-src\r\n'unsafe-inline'", |
| 15 | + "expected": null }, |
| 16 | + { "name": "\\r\\n character in directive value", |
| 17 | + "csp": "script-src 'unsafe-inline'\r\n'unsafe-eval'", |
| 18 | + "expected": null }, |
| 19 | + { "name": "\\n character after directive name", |
| 20 | + "csp": "script-src\n'unsafe-inline'", |
| 21 | + "expected": null }, |
| 22 | + { "name": "\\n character in directive value", |
| 23 | + "csp": "script-src 'unsafe-inline'\n'unsafe-eval'", |
| 24 | + "expected": null }, |
| 25 | + { "name": "\\r character after directive name", |
| 26 | + "csp": "script-src\r'unsafe-inline'", |
| 27 | + "expected": null }, |
| 28 | + { "name": "\\r character in directive value", |
| 29 | + "csp": "script-src 'unsafe-inline'\r'unsafe-eval'", |
| 30 | + "expected": null }, |
| 31 | + |
| 32 | + // HTML encoded CRLF characters |
| 33 | + { "name": "%0D%0A character after directive name", |
| 34 | + "csp": "script-src%0D%0A'unsafe-inline'", |
| 35 | + "expected": null }, |
| 36 | + { "name": "%0D%0A character in directive value", |
| 37 | + "csp": "script-src 'unsafe-inline'%0D%0A'unsafe-eval'", |
| 38 | + "expected": null }, |
| 39 | + { "name": "%0A character after directive name", |
| 40 | + "csp": "script-src%0A'unsafe-inline'", |
| 41 | + "expected": null }, |
| 42 | + { "name": "%0A character in directive value", |
| 43 | + "csp": "script-src 'unsafe-inline'%0A'unsafe-eval'", |
| 44 | + "expected": null }, |
| 45 | + { "name": "%0D character after directive name", |
| 46 | + "csp": "script-src%0D'unsafe-inline'", |
| 47 | + "expected": null }, |
| 48 | + { "name": "%0D character in directive value", |
| 49 | + "csp": "script-src 'unsafe-inline'%0D'unsafe-eval'", |
| 50 | + "expected": null }, |
| 51 | + |
| 52 | + // Attempt HTTP Header injection |
| 53 | + { "name": "Attempt injecting after directive name using \\r\\n", |
| 54 | + "csp": "script-src\r\nTest-Header-Injection: dummy", |
| 55 | + "expected": null }, |
| 56 | + { "name": "Attempt injecting after directive name using \\r", |
| 57 | + "csp": "script-src\rTest-Header-Injection: dummy", |
| 58 | + "expected": null }, |
| 59 | + { "name": "Attempt injecting after directive name using \\n", |
| 60 | + "csp": "script-src\nTest-Header-Injection: dummy", |
| 61 | + "expected": null }, |
| 62 | + |
| 63 | + { "name": "Attempt injecting after directive value using \\r\\n", |
| 64 | + "csp": "script-src example.com\r\nTest-Header-Injection: dummy", |
| 65 | + "expected": null }, |
| 66 | + { "name": "Attempt injecting after directive value using \\r", |
| 67 | + "csp": "script-src example.com\rTest-Header-Injection: dummy", |
| 68 | + "expected": null }, |
| 69 | + { "name": "Attempt injecting after directive value using \\n", |
| 70 | + "csp": "script-src example.com\nTest-Header-Injection: dummy", |
| 71 | + "expected": null }, |
| 72 | + |
| 73 | + { "name": "Attempt injecting after semicolon using \\r\\n", |
| 74 | + "csp": "script-src example.com;\r\nTest-Header-Injection: dummy", |
| 75 | + "expected": null }, |
| 76 | + { "name": "Attempt injecting after semicolon using \\r", |
| 77 | + "csp": "script-src example.com;\rTest-Header-Injection: dummy", |
| 78 | + "expected": null }, |
| 79 | + { "name": "Attempt injecting after semicolon using \\n", |
| 80 | + "csp": "script-src example.com;\nTest-Header-Injection: dummy", |
| 81 | + "expected": null }, |
| 82 | + |
| 83 | + { "name": "Attempt injecting after space between name and value using \\r\\n", |
| 84 | + "csp": "script-src \r\nTest-Header-Injection: dummy", |
| 85 | + "expected": null }, |
| 86 | + { "name": "Attempt injecting after space between name and value using \\r", |
| 87 | + "csp": "script-src \rTest-Header-Injection: dummy", |
| 88 | + "expected": null }, |
| 89 | + { "name": "Attempt injecting after space between name and value using \\n", |
| 90 | + "csp": "script-src \nTest-Header-Injection: dummy", |
| 91 | + "expected": null }, |
| 92 | + |
| 93 | + // Attempt HTTP Header injection using URL encoded characters |
| 94 | + { "name": "Attempt injecting after directive name using %0D%0A", |
| 95 | + "csp": "script-src%0D%0ATest-Header-Injection: dummy", |
| 96 | + "expected": null }, |
| 97 | + { "name": "Attempt injecting after directive name using %0D", |
| 98 | + "csp": "script-src%0DTest-Header-Injection: dummy", |
| 99 | + "expected": null }, |
| 100 | + { "name": "Attempt injecting after directive name using %0A", |
| 101 | + "csp": "script-src%0ATest-Header-Injection: dummy", |
| 102 | + "expected": null }, |
| 103 | + |
| 104 | + { "name": "Attempt injecting after directive value using %0D%0A", |
| 105 | + "csp": "script-src example.com%0D%0ATest-Header-Injection: dummy", |
| 106 | + "expected": null }, |
| 107 | + { "name": "Attempt injecting after directive value using %0D", |
| 108 | + "csp": "script-src example.com%0DTest-Header-Injection: dummy", |
| 109 | + "expected": null }, |
| 110 | + { "name": "Attempt injecting after directive value using %0A", |
| 111 | + "csp": "script-src example.com%0ATest-Header-Injection: dummy", |
| 112 | + "expected": null }, |
| 113 | + |
| 114 | + { "name": "Attempt injecting after semicolon using %0D%0A", |
| 115 | + "csp": "script-src example.com;%0D%0ATest-Header-Injection: dummy", |
| 116 | + "expected": null }, |
| 117 | + { "name": "Attempt injecting after semicolon using %0D", |
| 118 | + "csp": "script-src example.com;%0DTest-Header-Injection: dummy", |
| 119 | + "expected": null }, |
| 120 | + { "name": "Attempt injecting after semicolon using %0A", |
| 121 | + "csp": "script-src example.com;%0ATest-Header-Injection: dummy", |
| 122 | + "expected": null }, |
| 123 | + |
| 124 | + { "name": "Attempt injecting after space between name and value using %0D%0A", |
| 125 | + "csp": "script-src %0D%0ATest-Header-Injection: dummy", |
| 126 | + "expected": null }, |
| 127 | + { "name": "Attempt injecting after space between name and value using %0D", |
| 128 | + "csp": "script-src %0DTest-Header-Injection: dummy", |
| 129 | + "expected": null }, |
| 130 | + { "name": "Attempt injecting after space between name and value using %0A", |
| 131 | + "csp": "script-src %0ATest-Header-Injection: dummy", |
| 132 | + "expected": null }, |
| 133 | + |
| 134 | + ]; |
| 135 | + |
| 136 | + tests.forEach(test => { |
| 137 | + async_test(t => { |
| 138 | + var url = generateURLString(Host.SAME_ORIGIN, PolicyHeader.REQUIRED_CSP); |
| 139 | + assert_required_csp(t, url, test.csp, [test.expected]); |
| 140 | + }, "Test CRLF: " + test.name); |
| 141 | + }); |
| 142 | + </script> |
| 143 | +</body> |
| 144 | +</html> |
0 commit comments