Source/WebCore/ChangeLog

 12013-02-13 Mike West <mkwst@chromium.org>
 2
 3 CSP 1.1: Experiment with 'reflected-xss' directive.
 4 https://bugs.webkit.org/show_bug.cgi?id=104479
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Content Security Policy 1.1 defines a 'reflected-xss' directive that
 9 works in much the same way as WebKit's current 'X-XSS-Protection'
 10 header[1]. This patch implements the new directive by parsing it
 11 inside ContentSecurityPolicy, and exposing that state to XSSAuditor.
 12
 13 XSSAuditor now grabs the CSP directive's state, and mixes it with the
 14 X-XSS-Protection header's state to determine how the page should be
 15 handled. Moreover, both headers' states are now expressed in terms of
 16 ContentSecurityPolicy::ReflectedXSSDisposition.
 17
 18 [1]: https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#reflected-xss--experimental
 19
 20 Tests: http/tests/security/contentSecurityPolicy/1.1/reflected-xss-allow.html
 21 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-allow.html
 22 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-block.html
 23 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-filter.html
 24 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-invalid.html
 25 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-unset.html
 26 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-allow.html
 27 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-block.html
 28 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-filter.html
 29 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-invalid.html
 30 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-unset.html
 31 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-allow.html
 32 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-block.html
 33 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-filter.html
 34 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-invalid.html
 35 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-unset.html
 36 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-allow.html
 37 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-block.html
 38 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-filter.html
 39 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-invalid.html
 40 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-unset.html
 41 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-allow.html
 42 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-block.html
 43 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-filter.html
 44 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-invalid.html
 45 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-unset.html
 46 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-block.html
 47 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-empty.html
 48 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-filter.html
 49 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-invalid.html
 50 http/tests/security/contentSecurityPolicy/1.1/reflected-xss-parsing.html
 51
 52 * html/parser/XSSAuditor.cpp:
 53 (WebCore::combineXSSProtectionHeaderAndCSP):
 54 Given both headers' states, return the state which the XSSAuditor
 55 should use when parsing a page. Blocking overrides filtering, which
 56 overrides disabling.
 57 (WebCore):
 58 (WebCore::XSSAuditor::init):
 59 Process the 'X-XSS-Protection' header before grabbing the CSP
 60 header's state. Both are passed into the new
 61 combineXSSProtectionHeaderAndCSP method to generate the final
 62 state that ought to be used.
 63 (WebCore::XSSAuditor::XSSAuditor):
 64 (WebCore::XSSAuditor::filterToken):
 65 * html/parser/XSSAuditor.h:
 66 Switch to ContentSecurityPolicy::ReflectedXSSDisposition internally
 67 in XSSAuditor.
 68 * page/ContentSecurityPolicy.cpp:
 69 (WebCore::CSPDirectiveList::reflectedXSSDisposition):
 70 Enum defining the possible state of the 'reflected-xss' CSP directive.
 71 (CSPDirectiveList):
 72 (WebCore::CSPDirectiveList::CSPDirectiveList):
 73 (WebCore::CSPDirectiveList::parseReflectedXSS):
 74 Given a 'reflected-xss' directive's value, set the
 75 ReflectedXSSDisposition into a new property on the CSPDirectiveList.
 76 (WebCore):
 77 (WebCore::CSPDirectiveList::addDirective):
 78 Accept 'reflected-xss' as a valid directive if we're in
 79 experimental mode.
 80 (WebCore::ContentSecurityPolicy::reflectedXSSDisposition):
 81 Expose the directive's state via the public API.
 82 (WebCore::ContentSecurityPolicy::reportInvalidReflectedXSS):
 83 Generate console errors when invalid reflected-xss directive values
 84 are encounted during parsing.
 85 * page/ContentSecurityPolicy.h:
 86 * platform/network/HTTPParsers.cpp:
 87 (WebCore::parseXSSProtectionHeader):
 88 * platform/network/HTTPParsers.h:
 89 (WebCore):
 90 Start using ContentSecurityPolicy::ReflectedXSSDisposition rather
 91 than the XSSProtectionDisposition enum.
 92
1932013-02-12 Kentaro Hara <haraken@chromium.org>
294
395 [V8] Generate wrapper methods for custom getters/setters

Source/WebCore/html/parser/XSSAuditor.cpp

2828#include "XSSAuditor.h"
2929
3030#include "Console.h"
 31#include "ContentSecurityPolicy.h"
3132#include "DOMWindow.h"
3233#include "DecodeEscapeSequences.h"
3334#include "Document.h"

@@static String fullyDecodeString(const String& string, const TextEncoding& encodi
173174 return workingString;
174175}
175176
 177static ContentSecurityPolicy::ReflectedXSSDisposition combineXSSProtectionHeaderAndCSP(ContentSecurityPolicy::ReflectedXSSDisposition xssProtection, ContentSecurityPolicy::ReflectedXSSDisposition reflectedXSS)
 178{
 179 ContentSecurityPolicy::ReflectedXSSDisposition result = std::max(xssProtection, reflectedXSS);
 180
 181 if (result == ContentSecurityPolicy::ReflectedXSSInvalid || result == ContentSecurityPolicy::FilterReflectedXSS || result == ContentSecurityPolicy::ReflectedXSSUnset)
 182 return ContentSecurityPolicy::FilterReflectedXSS;
 183
 184 return result;
 185}
 186
176187XSSAuditor::XSSAuditor()
177188 : m_isEnabled(false)
178  , m_xssProtection(XSSProtectionEnabled)
 189 , m_xssProtection(ContentSecurityPolicy::FilterReflectedXSS)
179190 , m_state(Uninitialized)
180191 , m_scriptTagNestingLevel(0)
181192 , m_encoding(UTF8Encoding())

@@void XSSAuditor::init(Document* document)
236247 String errorDetails;
237248 unsigned errorPosition = 0;
238249 String reportURL;
239  m_xssProtection = parseXSSProtectionHeader(headerValue, errorDetails, errorPosition, reportURL);
 250 KURL xssProtectionReportURL;
240251
241  if ((m_xssProtection == XSSProtectionEnabled || m_xssProtection == XSSProtectionBlockEnabled) && !reportURL.isEmpty()) {
242  m_reportURL = document->completeURL(reportURL);
243  if (MixedContentChecker::isMixedContent(document->securityOrigin(), m_reportURL)) {
 252 // Process the X-XSS-Protection header, then mix in the CSP header's value.
 253 ContentSecurityPolicy::ReflectedXSSDisposition xssProtectionHeader = parseXSSProtectionHeader(headerValue, errorDetails, errorPosition, reportURL);
 254 if ((xssProtectionHeader == ContentSecurityPolicy::FilterReflectedXSS || xssProtectionHeader == ContentSecurityPolicy::BlockReflectedXSS) && !reportURL.isEmpty()) {
 255 xssProtectionReportURL = document->completeURL(reportURL);
 256 if (MixedContentChecker::isMixedContent(document->securityOrigin(), xssProtectionReportURL)) {
244257 errorDetails = "insecure reporting URL for secure page";
245  m_xssProtection = XSSProtectionInvalid;
246  m_reportURL = KURL();
 258 xssProtectionHeader = ContentSecurityPolicy::ReflectedXSSInvalid;
 259 xssProtectionReportURL = KURL();
247260 }
248261 }
249 
250  if (m_xssProtection == XSSProtectionInvalid) {
 262 if (xssProtectionHeader == ContentSecurityPolicy::ReflectedXSSInvalid)
251263 document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Error parsing header X-XSS-Protection: " + headerValue + ": " + errorDetails + " at character position " + String::format("%u", errorPosition) + ". The default protections will be applied.");
252  m_xssProtection = XSSProtectionEnabled;
253  }
 264
 265 m_xssProtection = combineXSSProtectionHeaderAndCSP(xssProtectionHeader, document->contentSecurityPolicy()->reflectedXSSDisposition());
 266 m_reportURL = xssProtectionReportURL; // FIXME: Combine the two report URLs in some reasonable way.
254267
255268 FormData* httpBody = documentLoader->originalRequest().httpBody();
256269 if (httpBody && !httpBody->isEmpty()) {

@@void XSSAuditor::init(Document* document)
280293PassOwnPtr<XSSInfo> XSSAuditor::filterToken(const FilterTokenRequest& request)
281294{
282295 ASSERT(m_state == Initialized);
283  if (!m_isEnabled || m_xssProtection == XSSProtectionDisabled)
 296 if (!m_isEnabled || m_xssProtection == ContentSecurityPolicy::AllowReflectedXSS)
284297 return nullptr;
285298
286299 bool didBlockScript = false;

@@PassOwnPtr<XSSInfo> XSSAuditor::filterToken(const FilterTokenRequest& request)
294307 }
295308
296309 if (didBlockScript) {
297  bool didBlockEntirePage = (m_xssProtection == XSSProtectionBlockEnabled);
 310 bool didBlockEntirePage = (m_xssProtection == ContentSecurityPolicy::BlockReflectedXSS);
298311 OwnPtr<XSSInfo> xssInfo = XSSInfo::create(m_reportURL, m_originalURL, m_originalHTTPBody, didBlockEntirePage);
299312 if (!m_reportURL.isEmpty()) {
300313 m_reportURL = KURL();

Source/WebCore/html/parser/XSSAuditor.h

@@private:
101101
102102 KURL m_documentURL;
103103 bool m_isEnabled;
104  XSSProtectionDisposition m_xssProtection;
 104 ContentSecurityPolicy::ReflectedXSSDisposition m_xssProtection;
105105
106106 String m_originalURL;
107107 String m_originalHTTPBody;

Source/WebCore/page/ContentSecurityPolicy.cpp

@@static const char styleSrc[] = "style-src";
120120static const char formAction[] = "form-action";
121121static const char pluginTypes[] = "plugin-types";
122122static const char scriptNonce[] = "script-nonce";
 123static const char reflectedXSS[] = "reflected-xss";
123124#endif
124125
125126bool isDirectiveName(const String& name)

@@bool isDirectiveName(const String& name)
139140 || equalIgnoringCase(name, formAction)
140141 || equalIgnoringCase(name, pluginTypes)
141142 || equalIgnoringCase(name, scriptNonce)
 143 || equalIgnoringCase(name, reflectedXSS)
142144#endif
143145 );
144146}

@@public:
839841
840842 void gatherReportURIs(DOMStringList&) const;
841843 const String& evalDisabledErrorMessage() { return m_evalDisabledErrorMessage; }
 844 ContentSecurityPolicy::ReflectedXSSDisposition reflectedXSSDisposition() const { return m_reflectedXSSDisposition; }
842845
843846private:
844847 CSPDirectiveList(ContentSecurityPolicy*, ContentSecurityPolicy::HeaderType);

@@private:
849852 void parseReportURI(const String& name, const String& value);
850853 void parseScriptNonce(const String& name, const String& value);
851854 void parsePluginTypes(const String& name, const String& value);
 855 void parseReflectedXSS(const String& name, const String& value);
852856 void addDirective(const String& name, const String& value);
853857 void applySandboxPolicy(const String& name, const String& sandboxPolicy);
854858

@@private:
883887 bool m_experimental;
884888 bool m_reportOnly;
885889 bool m_haveSandboxPolicy;
 890 ContentSecurityPolicy::ReflectedXSSDisposition m_reflectedXSSDisposition;
886891
887892 OwnPtr<MediaListDirective> m_pluginTypes;
888893 OwnPtr<NonceDirective> m_scriptNonce;

@@CSPDirectiveList::CSPDirectiveList(ContentSecurityPolicy* policy, ContentSecurit
908913 , m_experimental(false)
909914 , m_reportOnly(false)
910915 , m_haveSandboxPolicy(false)
 916 , m_reflectedXSSDisposition(ContentSecurityPolicy::ReflectedXSSUnset)
911917{
912918 m_reportOnly = (type == ContentSecurityPolicy::ReportStableDirectives || type == ContentSecurityPolicy::ReportAllDirectives);
913919 m_experimental = (type == ContentSecurityPolicy::ReportAllDirectives || type == ContentSecurityPolicy::EnforceAllDirectives);

@@void CSPDirectiveList::applySandboxPolicy(const String& name, const String& sand
13151321 m_policy->reportInvalidSandboxFlags(invalidTokens);
13161322}
13171323
 1324void CSPDirectiveList::parseReflectedXSS(const String& name, const String& value)
 1325{
 1326 if (m_reflectedXSSDisposition != ContentSecurityPolicy::ReflectedXSSUnset) {
 1327 m_policy->reportDuplicateDirective(name);
 1328 m_reflectedXSSDisposition = ContentSecurityPolicy::ReflectedXSSInvalid;
 1329 return;
 1330 }
 1331
 1332 if (value.isEmpty()) {
 1333 m_reflectedXSSDisposition = ContentSecurityPolicy::ReflectedXSSInvalid;
 1334 m_policy->reportInvalidReflectedXSS(value);
 1335 return;
 1336 }
 1337
 1338 const UChar* position = value.characters();
 1339 const UChar* end = position + value.length();
 1340
 1341 skipWhile<isASCIISpace>(position, end);
 1342 const UChar* begin = position;
 1343 skipWhile<isNotASCIISpace>(position, end);
 1344
 1345 // value1
 1346 // ^
 1347 if (equalIgnoringCase("allow", begin, position - begin))
 1348 m_reflectedXSSDisposition = ContentSecurityPolicy::AllowReflectedXSS;
 1349 else if (equalIgnoringCase("filter", begin, position - begin))
 1350 m_reflectedXSSDisposition = ContentSecurityPolicy::FilterReflectedXSS;
 1351 else if (equalIgnoringCase("block", begin, position - begin))
 1352 m_reflectedXSSDisposition = ContentSecurityPolicy::BlockReflectedXSS;
 1353 else {
 1354 m_reflectedXSSDisposition = ContentSecurityPolicy::ReflectedXSSInvalid;
 1355 m_policy->reportInvalidReflectedXSS(value);
 1356 return;
 1357 }
 1358
 1359 skipWhile<isASCIISpace>(position, end);
 1360 if (position == end && m_reflectedXSSDisposition != ContentSecurityPolicy::ReflectedXSSUnset)
 1361 return;
 1362
 1363 // value1 value2
 1364 // ^
 1365 m_reflectedXSSDisposition = ContentSecurityPolicy::ReflectedXSSInvalid;
 1366 m_policy->reportInvalidReflectedXSS(value);
 1367}
 1368
13181369void CSPDirectiveList::addDirective(const String& name, const String& value)
13191370{
13201371 ASSERT(!name.isEmpty());

@@void CSPDirectiveList::addDirective(const String& name, const String& value)
13491400 setCSPDirective<MediaListDirective>(name, value, m_pluginTypes);
13501401 else if (equalIgnoringCase(name, scriptNonce))
13511402 setCSPDirective<NonceDirective>(name, value, m_scriptNonce);
 1403 else if (equalIgnoringCase(name, reflectedXSS))
 1404 parseReflectedXSS(name, value);
13521405 }
13531406#endif
13541407 else

@@bool ContentSecurityPolicy::isActive() const
15711624 return !m_policies.isEmpty();
15721625}
15731626
 1627ContentSecurityPolicy::ReflectedXSSDisposition ContentSecurityPolicy::reflectedXSSDisposition() const
 1628{
 1629 ReflectedXSSDisposition disposition = ReflectedXSSUnset;
 1630 for (size_t i = 0; i < m_policies.size(); ++i) {
 1631 if (m_policies[i]->reflectedXSSDisposition() > disposition)
 1632 disposition = m_policies[i]->reflectedXSSDisposition();
 1633 }
 1634 return disposition;
 1635}
 1636
15741637void ContentSecurityPolicy::gatherReportURIs(DOMStringList& list) const
15751638{
15761639 for (size_t i = 0; i < m_policies.size(); ++i)

@@void ContentSecurityPolicy::reportInvalidSandboxFlags(const String& invalidFlags
17051768 logToConsole("Error while parsing the 'sandbox' Content Security Policy directive: " + invalidFlags);
17061769}
17071770
 1771void ContentSecurityPolicy::reportInvalidReflectedXSS(const String& invalidValue) const
 1772{
 1773 logToConsole("The 'reflected-xss' Content Security Policy directive has the invalid value \"" + invalidValue + "\". Value values are \"allow\", \"filter\", and \"block\".");
 1774}
 1775
17081776void ContentSecurityPolicy::reportInvalidDirectiveValueCharacter(const String& directiveName, const String& value) const
17091777{
17101778 String message = makeString("The value for Content Security Policy directive '", directiveName, "' contains an invalid character: '", value, "'. Non-whitespace characters outside ASCII 0x21-0x7E must be percent-encoded, as described in RFC 3986, section 2.1: http://tools.ietf.org/html/rfc3986#section-2.1.");

Source/WebCore/page/ContentSecurityPolicy.h

@@public:
7171 SuppressReport
7272 };
7373
 74 enum ReflectedXSSDisposition {
 75 ReflectedXSSUnset = 0,
 76 AllowReflectedXSS,
 77 ReflectedXSSInvalid,
 78 FilterReflectedXSS,
 79 BlockReflectedXSS
 80 };
 81
7482 void didReceiveHeader(const String&, HeaderType);
7583
7684 // These functions are wrong because they assume that there is only one header.

@@public:
96104 bool allowConnectToSource(const KURL&, ReportingStatus = SendReport) const;
97105 bool allowFormAction(const KURL&, ReportingStatus = SendReport) const;
98106
 107 ReflectedXSSDisposition reflectedXSSDisposition() const;
 108
99109 void setOverrideAllowInlineStyle(bool);
100110
101111 bool isActive() const;

@@public:
109119 void reportInvalidPluginTypes(const String&) const;
110120 void reportInvalidSandboxFlags(const String&) const;
111121 void reportInvalidSourceExpression(const String& directiveName, const String& source) const;
 122 void reportInvalidReflectedXSS(const String&) const;
112123 void reportUnsupportedDirective(const String&) const;
113124 void reportViolation(const String& directiveText, const String& consoleMessage, const KURL& blockedURL, const Vector<KURL>& reportURIs, const String& header, const String& contextURL = String(), const WTF::OrdinalNumber& contextLine = WTF::OrdinalNumber::beforeFirst(), ScriptState* = 0) const;
114125

Source/WebCore/platform/network/HTTPParsers.cpp

3333#include "config.h"
3434#include "HTTPParsers.h"
3535
 36#include "ContentSecurityPolicy.h"
3637#include <wtf/DateMath.h>
3738#include <wtf/text/CString.h>
3839#include <wtf/text/StringBuilder.h>

@@void findCharsetInMediaType(const String& mediaType, unsigned int& charsetPos, u
340341 }
341342}
342343
343 XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL)
 344ContentSecurityPolicy::ReflectedXSSDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL)
344345{
345346 DEFINE_STATIC_LOCAL(String, failureReasonInvalidToggle, (ASCIILiteral("expected 0 or 1")));
346347 DEFINE_STATIC_LOCAL(String, failureReasonInvalidSeparator, (ASCIILiteral("expected semicolon")));

@@XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String&
354355 unsigned pos = 0;
355356
356357 if (!skipWhiteSpace(header, pos, false))
357  return XSSProtectionEnabled;
 358 return ContentSecurityPolicy::ReflectedXSSUnset;
358359
359360 if (header[pos] == '0')
360  return XSSProtectionDisabled;
 361 return ContentSecurityPolicy::AllowReflectedXSS;
361362
362363 if (header[pos++] != '1') {
363364 failureReason = failureReasonInvalidToggle;
364  return XSSProtectionInvalid;
 365 return ContentSecurityPolicy::ReflectedXSSInvalid;
365366 }
366367
367  XSSProtectionDisposition result = XSSProtectionEnabled;
 368 ContentSecurityPolicy::ReflectedXSSDisposition result = ContentSecurityPolicy::FilterReflectedXSS;
368369 bool modeDirectiveSeen = false;
369370 bool reportDirectiveSeen = false;
370371

@@XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String&
376377 if (header[pos++] != ';') {
377378 failureReason = failureReasonInvalidSeparator;
378379 failurePosition = pos;
379  return XSSProtectionInvalid;
 380 return ContentSecurityPolicy::ReflectedXSSInvalid;
380381 }
381382
382383 if (!skipWhiteSpace(header, pos, false))

@@XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String&
387388 if (modeDirectiveSeen) {
388389 failureReason = failureReasonDuplicateMode;
389390 failurePosition = pos;
390  return XSSProtectionInvalid;
 391 return ContentSecurityPolicy::ReflectedXSSInvalid;
391392 }
392393 modeDirectiveSeen = true;
393394 if (!skipEquals(header, pos)) {
394395 failureReason = failureReasonInvalidEquals;
395396 failurePosition = pos;
396  return XSSProtectionInvalid;
 397 return ContentSecurityPolicy::ReflectedXSSInvalid;
397398 }
398399 if (!skipToken(header, pos, "block")) {
399400 failureReason = failureReasonInvalidMode;
400401 failurePosition = pos;
401  return XSSProtectionInvalid;
 402 return ContentSecurityPolicy::ReflectedXSSInvalid;
402403 }
403  result = XSSProtectionBlockEnabled;
 404 result = ContentSecurityPolicy::BlockReflectedXSS;
404405 } else if (skipToken(header, pos, "report")) {
405406 if (reportDirectiveSeen) {
406407 failureReason = failureReasonDuplicateReport;
407408 failurePosition = pos;
408  return XSSProtectionInvalid;
 409 return ContentSecurityPolicy::ReflectedXSSInvalid;
409410 }
410411 reportDirectiveSeen = true;
411412 if (!skipEquals(header, pos)) {
412413 failureReason = failureReasonInvalidEquals;
413414 failurePosition = pos;
414  return XSSProtectionInvalid;
 415 return ContentSecurityPolicy::ReflectedXSSInvalid;
415416 }
416417 size_t startPos = pos;
417418 if (!skipValue(header, pos)) {
418419 failureReason = failureReasonInvalidReport;
419420 failurePosition = pos;
420  return XSSProtectionInvalid;
 421 return ContentSecurityPolicy::ReflectedXSSInvalid;
421422 }
422423 reportURL = header.substring(startPos, pos - startPos);
423424 failurePosition = startPos; // If later semantic check deems unacceptable.
424425 } else {
425426 failureReason = failureReasonInvalidDirective;
426427 failurePosition = pos;
427  return XSSProtectionInvalid;
 428 return ContentSecurityPolicy::ReflectedXSSInvalid;
428429 }
429430 }
430431}

Source/WebCore/platform/network/HTTPParsers.h

3131#ifndef HTTPParsers_h
3232#define HTTPParsers_h
3333
 34#include "ContentSecurityPolicy.h"
3435#include <wtf/Forward.h>
3536#include <wtf/Vector.h>
3637

@@namespace WebCore {
3940class HTTPHeaderMap;
4041class ResourceResponseBase;
4142
42 enum XSSProtectionDisposition {
43  XSSProtectionInvalid,
44  XSSProtectionDisabled,
45  XSSProtectionEnabled,
46  XSSProtectionBlockEnabled
47 };
48 
4943typedef enum {
5044 ContentDispositionNone,
5145 ContentDispositionInline,

@@String filenameFromHTTPContentDisposition(const String&);
6862String extractMIMETypeFromMediaType(const String&);
6963String extractCharsetFromMediaType(const String&);
7064void findCharsetInMediaType(const String& mediaType, unsigned int& charsetPos, unsigned int& charsetLen, unsigned int start = 0);
71 XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL);
 65ContentSecurityPolicy::ReflectedXSSDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL);
7266String extractReasonPhraseFromHTTPStatusLine(const String&);
7367
7468// -1 could be set to one of the return parameters to indicate the value is not specified.

LayoutTests/ChangeLog

 12013-02-13 Mike West <mkwst@chromium.org>
 2
 3 CSP 1.1: Experiment with 'reflected-xss' directive.
 4 https://bugs.webkit.org/show_bug.cgi?id=104479
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-allow-expected.txt: Added.
 9 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-allow.html: Added.
 10 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-allow-expected.txt: Added.
 11 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-allow.html: Added.
 12 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-block-expected.txt: Added.
 13 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-block.html: Added.
 14 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-filter-expected.txt: Added.
 15 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-filter.html: Added.
 16 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-invalid-expected.txt: Added.
 17 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-invalid.html: Added.
 18 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-unset-expected.txt: Added.
 19 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-unset.html: Added.
 20 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-allow-expected.txt: Added.
 21 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-allow.html: Added.
 22 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-block-expected.txt: Added.
 23 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-block.html: Added.
 24 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-filter-expected.txt: Added.
 25 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-filter.html: Added.
 26 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-invalid-expected.txt: Added.
 27 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-invalid.html: Added.
 28 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-unset-expected.txt: Added.
 29 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-unset.html: Added.
 30 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-allow-expected.txt: Added.
 31 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-allow.html: Added.
 32 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-block-expected.txt: Added.
 33 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-block.html: Added.
 34 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-filter-expected.txt: Added.
 35 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-filter.html: Added.
 36 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-invalid-expected.txt: Added.
 37 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-invalid.html: Added.
 38 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-unset-expected.txt: Added.
 39 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-unset.html: Added.
 40 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-allow-expected.txt: Added.
 41 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-allow.html: Added.
 42 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-block-expected.txt: Added.
 43 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-block.html: Added.
 44 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-filter-expected.txt: Added.
 45 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-filter.html: Added.
 46 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-invalid-expected.txt: Added.
 47 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-invalid.html: Added.
 48 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-unset-expected.txt: Added.
 49 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-unset.html: Added.
 50 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-allow-expected.txt: Added.
 51 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-allow.html: Added.
 52 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-block-expected.txt: Added.
 53 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-block.html: Added.
 54 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-filter-expected.txt: Added.
 55 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-filter.html: Added.
 56 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-invalid-expected.txt: Added.
 57 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-invalid.html: Added.
 58 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-unset-expected.txt: Added.
 59 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-unset.html: Added.
 60 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-block-expected.txt: Added.
 61 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-block.html: Added.
 62 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-empty-expected.txt: Added.
 63 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-empty.html: Added.
 64 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-filter-expected.txt: Added.
 65 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-filter.html: Added.
 66 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-invalid-expected.txt: Added.
 67 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-invalid.html: Added.
 68 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-parsing-expected.txt: Added.
 69 * http/tests/security/contentSecurityPolicy/1.1/reflected-xss-parsing.html: Added.
 70 * http/tests/security/contentSecurityPolicy/resources/reflected-xss-and-xss-protection.js: Added.
 71 (testMixedHeader):
 72 (frameLoaded):
 73 (frameErrored):
 74 * http/tests/security/xssAuditor/resources/echo-intertag.pl:
 75
1762013-02-13 Ádám Kallai <kadam@inf.u-szeged.hu>
277
378 [Qt] Unreviewed gardening. Skip failing tests.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-allow-expected.txt

 1ALERT: XSS
 2Tests that 'X-WebKit-CSP: reflected-xss allow;' disables the XSSAuditor. This test passes if an alert is generated, and the script is allowed.
 3
 4

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-allow.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <script>
 5 if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.setXSSAuditorEnabled(true);
 8 }
 9 </script>
 10</head>
 11<body>
 12 <p>Tests that 'X-WebKit-CSP: reflected-xss allow;' disables the XSSAuditor.
 13 This test passes if an alert is generated, and the script is allowed.</p>
 14 <iframe src="http://localhost:8000/security/xssAuditor/resources/echo-intertag.pl?csp=allow&amp;q=<script>alert(String.fromCharCode(0x58,0x53,0x53))</script>"></iframe>
 15</body>
 16</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-allow-expected.txt

 1ALERT: XSS
 2ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=allow&disable-protection=1 into the IFrame.
 3Testing behavior when "reflected-xss" is set to allow, and "X-XSS-Protection" is set to allow.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-allow.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('allow', 'allow');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-block-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to allow, and "X-XSS-Protection" is set to block.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-block.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('allow', 'block');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-filter-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=allow&valid-header=2 into the IFrame.
 4Testing behavior when "reflected-xss" is set to allow, and "X-XSS-Protection" is set to filter.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-filter.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('allow', 'filter');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-invalid-expected.txt

 1CONSOLE MESSAGE: line 1: Error parsing header X-XSS-Protection: 12345678901234567: expected semicolon at character position 2. The default protections will be applied.
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=allow&malformed-header=1 into the IFrame.
 5Testing behavior when "reflected-xss" is set to allow, and "X-XSS-Protection" is set to invalid.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-invalid.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('allow', 'invalid');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-unset-expected.txt

 1ALERT: XSS
 2ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=allow into the IFrame.
 3Testing behavior when "reflected-xss" is set to allow, and "X-XSS-Protection" is set to unset.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-allow-unset.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('allow', 'unset');</script>
 6</body>
 7</html>
 8

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-allow-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to block, and "X-XSS-Protection" is set to allow.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-allow.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('block', 'allow');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-block-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to block, and "X-XSS-Protection" is set to block.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-block.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('block', 'block');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-filter-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to block, and "X-XSS-Protection" is set to filter.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-filter.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('block', 'filter');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-invalid-expected.txt

 1CONSOLE MESSAGE: line 1: Error parsing header X-XSS-Protection: 12345678901234567: expected semicolon at character position 2. The default protections will be applied.
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded about:blank into the IFrame.
 5Testing behavior when "reflected-xss" is set to block, and "X-XSS-Protection" is set to invalid.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-invalid.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('block', 'invalid');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-unset-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to block, and "X-XSS-Protection" is set to unset.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-block-unset.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('block', 'unset');</script>
 6</body>
 7</html>
 8

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-allow-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=filter&disable-protection=1 into the IFrame.
 4Testing behavior when "reflected-xss" is set to filter, and "X-XSS-Protection" is set to allow.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-allow.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('filter', 'allow');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-block-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to filter, and "X-XSS-Protection" is set to block.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-block.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('filter', 'block');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-filter-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=filter&valid-header=2 into the IFrame.
 4Testing behavior when "reflected-xss" is set to filter, and "X-XSS-Protection" is set to filter.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-filter.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('filter', 'filter');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-invalid-expected.txt

 1CONSOLE MESSAGE: line 1: Error parsing header X-XSS-Protection: 12345678901234567: expected semicolon at character position 2. The default protections will be applied.
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=filter&malformed-header=1 into the IFrame.
 5Testing behavior when "reflected-xss" is set to filter, and "X-XSS-Protection" is set to invalid.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-invalid.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('filter', 'invalid');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-unset-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=filter into the IFrame.
 4Testing behavior when "reflected-xss" is set to filter, and "X-XSS-Protection" is set to unset.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-filter-unset.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('filter', 'unset');</script>
 6</body>
 7</html>
 8

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-allow-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "invalid". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=invalid&disable-protection=1 into the IFrame.
 5Testing behavior when "reflected-xss" is set to invalid, and "X-XSS-Protection" is set to allow.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-allow.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('invalid', 'allow');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-block-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "invalid". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded about:blank into the IFrame.
 5Testing behavior when "reflected-xss" is set to invalid, and "X-XSS-Protection" is set to block.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-block.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('invalid', 'block');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-filter-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "invalid". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=invalid&valid-header=2 into the IFrame.
 5Testing behavior when "reflected-xss" is set to invalid, and "X-XSS-Protection" is set to filter.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-filter.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('invalid', 'filter');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-invalid-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "invalid". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 1: Error parsing header X-XSS-Protection: 12345678901234567: expected semicolon at character position 2. The default protections will be applied.
 3CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 4
 5ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=invalid&malformed-header=1 into the IFrame.
 6Testing behavior when "reflected-xss" is set to invalid, and "X-XSS-Protection" is set to invalid.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-invalid.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('invalid', 'invalid');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-unset-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "invalid". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&csp=invalid into the IFrame.
 5Testing behavior when "reflected-xss" is set to invalid, and "X-XSS-Protection" is set to unset.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-invalid-unset.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('invalid', 'unset');</script>
 6</body>
 7</html>
 8

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-allow-expected.txt

 1ALERT: XSS
 2ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&disable-protection=1 into the IFrame.
 3Testing behavior when "reflected-xss" is set to unset, and "X-XSS-Protection" is set to allow.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-allow.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('unset', 'allow');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-block-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded about:blank into the IFrame.
 4Testing behavior when "reflected-xss" is set to unset, and "X-XSS-Protection" is set to block.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-block.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('unset', 'block');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-filter-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&valid-header=2 into the IFrame.
 4Testing behavior when "reflected-xss" is set to unset, and "X-XSS-Protection" is set to filter.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-filter.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('unset', 'filter');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-invalid-expected.txt

 1CONSOLE MESSAGE: line 1: Error parsing header X-XSS-Protection: 12345678901234567: expected semicolon at character position 2. The default protections will be applied.
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E&malformed-header=1 into the IFrame.
 5Testing behavior when "reflected-xss" is set to unset, and "X-XSS-Protection" is set to invalid.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-invalid.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('unset', 'invalid');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-unset-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3ALERT: Loaded http://127.0.0.1:8000/security/xssAuditor/resources/echo-intertag.pl?q=%3Cscript%3Ealert(String.fromCharCode(0x58,0x53,0x53))%3C/script%3E into the IFrame.
 4Testing behavior when "reflected-xss" is set to unset, and "X-XSS-Protection" is set to unset.

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-and-xss-protection-unset-unset.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4 <script src='../resources/reflected-xss-and-xss-protection.js'></script>
 5 <script>testMixedHeader('unset', 'unset');</script>
 6</body>
 7</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-block-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3Tests that 'X-WebKit-CSP: reflected-xss block;' enables the XSSAuditor. This test passes if a console message is generated, and the page is blocked. There should be no content in the IFrame below:
 4
 5
 6
 7--------
 8Frame: 'frame'
 9--------
 10

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-block.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <script src="http://localhost:8000/security/xssAuditor/resources/utilities.js"></script>
 5 <script>
 6 if (window.testRunner) {
 7 testRunner.dumpAsText();
 8 testRunner.dumpChildFramesAsText();
 9 testRunner.waitUntilDone();
 10 testRunner.setXSSAuditorEnabled(true);
 11 }
 12 </script>
 13</head>
 14<body>
 15 <p>Tests that 'X-WebKit-CSP: reflected-xss block;' enables the XSSAuditor.
 16 This test passes if a console message is generated, and the page is blocked.
 17 There should be no content in the IFrame below:</p>
 18 <iframe id="frame"
 19 onload="checkIfFrameLocationMatchesURLAndCallDone('frame', 'about:blank')"
 20 src="http://localhost:8000/security/xssAuditor/resources/echo-intertag.pl?csp=block&amp;q=<script>alert(String.fromCharCode(0x58,0x53,0x53))</script>"></iframe>
 21</body>
 22</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-empty-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4Tests that 'X-WebKit-CSP: reflected-xss' enables the XSSAuditor. This test passes if a console message is generated, and the script is blocked.
 5
 6

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-empty.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <script>
 5 if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.setXSSAuditorEnabled(true);
 8 }
 9 </script>
 10</head>
 11<body>
 12 <p>Tests that 'X-WebKit-CSP: reflected-xss' enables the XSSAuditor.
 13 This test passes if a console message is generated, and the script is blocked.</p>
 14 <iframe src="http://localhost:8000/security/xssAuditor/resources/echo-intertag.pl?csp=_empty_&amp;q=<script>alert(String.fromCharCode(0x58,0x53,0x53))</script>"></iframe>
 15</body>
 16</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-filter-expected.txt

 1CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 2
 3Tests that 'X-WebKit-CSP: reflected-xss filter;' enables the XSSAuditor. This test passes if a console message is generated, and the script is blocked.
 4
 5

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-filter.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <script>
 5 if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.setXSSAuditorEnabled(true);
 8 }
 9 </script>
 10</head>
 11<body>
 12 <p>Tests that 'X-WebKit-CSP: reflected-xss filter;' enables the XSSAuditor.
 13 This test passes if a console message is generated, and the script is blocked.</p>
 14 <iframe src="http://localhost:8000/security/xssAuditor/resources/echo-intertag.pl?csp=filter&amp;q=<script>alert(String.fromCharCode(0x58,0x53,0x53))</script>"></iframe>
 15</body>
 16</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-invalid-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "invalid". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: line 4: Refused to execute a JavaScript script. Source code of script found within request.
 3
 4Tests that 'X-WebKit-CSP: reflected-xss invalid' enables the XSSAuditor. This test passes if a console message is generated, and the script is allowed.
 5
 6

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-invalid.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <script>
 5 if (window.testRunner) {
 6 testRunner.dumpAsText();
 7 testRunner.setXSSAuditorEnabled(true);
 8 }
 9 </script>
 10</head>
 11<body>
 12 <p>Tests that 'X-WebKit-CSP: reflected-xss invalid' enables the XSSAuditor.
 13 This test passes if a console message is generated, and the script is allowed.</p>
 14 <iframe src="http://localhost:8000/security/xssAuditor/resources/echo-intertag.pl?csp=invalid&amp;q=<script>alert(String.fromCharCode(0x58,0x53,0x53))</script>"></iframe>
 15</body>
 16</html>

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-parsing-expected.txt

 1CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "". Value values are "allow", "filter", and "block".
 2CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "blah". Value values are "allow", "filter", and "block".
 3CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "allow blah". Value values are "allow", "filter", and "block".
 4CONSOLE MESSAGE: The 'reflected-xss' Content Security Policy directive has the invalid value "blah allow". Value values are "allow", "filter", and "block".
 5Invalid 'reflected-xss' headers should generate console messages.
 6
 7
 8
 9--------
 10Frame: '<!--framePath //<!--frame0-->-->'
 11--------
 12PASS
 13
 14--------
 15Frame: '<!--framePath //<!--frame1-->-->'
 16--------
 17PASS
 18
 19--------
 20Frame: '<!--framePath //<!--frame2-->-->'
 21--------
 22PASS
 23
 24--------
 25Frame: '<!--framePath //<!--frame3-->-->'
 26--------
 27PASS
 28
 29--------
 30Frame: '<!--framePath //<!--frame4-->-->'
 31--------
 32PASS
 33
 34--------
 35Frame: '<!--framePath //<!--frame5-->-->'
 36--------
 37PASS
 38
 39--------
 40Frame: '<!--framePath //<!--frame6-->-->'
 41--------
 42PASS

LayoutTests/http/tests/security/contentSecurityPolicy/1.1/reflected-xss-parsing.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <script src='../resources/multiple-iframe-test.js'></script>
 5 <script>
 6 var tests = [
 7 ['yes', 'reflected-xss allow', 'resources/script.js'],
 8 ['yes', 'reflected-xss filter', 'resources/script.js'],
 9 ['yes', 'reflected-xss block', 'resources/script.js'],
 10 ['yes', 'reflected-xss', 'resources/script.js'],
 11 ['yes', 'reflected-xss blah', 'resources/script.js'],
 12 ['yes', 'reflected-xss allow blah', 'resources/script.js'],
 13 ['yes', 'reflected-xss blah allow', 'resources/script.js'],
 14 ];
 15 </script>
 16</head>
 17<body onload="testExperimentalPolicy()">
 18 <p>
 19 Invalid 'reflected-xss' headers should generate console messages.
 20 </p>
 21</body>
 22</html>

LayoutTests/http/tests/security/contentSecurityPolicy/resources/reflected-xss-and-xss-protection.js

 1if (window.testRunner) {
 2 testRunner.dumpAsText();
 3 testRunner.setXSSAuditorEnabled(true);
 4 testRunner.waitUntilDone();
 5}
 6
 7function testMixedHeader(csp, xssProtection) {
 8 var params = [
 9 'q=<script>alert(String.fromCharCode(0x58,0x53,0x53))<' + '/script>'
 10 ];
 11 if (csp != 'unset')
 12 params.push('csp='+csp);
 13
 14 if (xssProtection == 'allow')
 15 params.push('disable-protection=1');
 16 if (xssProtection == 'block')
 17 params.push('enable-full-block=1');
 18 if (xssProtection == 'filter')
 19 params.push('valid-header=2');
 20 if (xssProtection == 'invalid')
 21 params.push('malformed-header=1');
 22
 23 var url = '/security/xssAuditor/resources/echo-intertag.pl?';
 24 url += params.join('&amp;');
 25
 26 document.write('<p>Testing behavior when "reflected-xss" is set to ' + csp + ', and "X-XSS-Protection" is set to ' + xssProtection + '.');
 27 document.write('<iframe src="' + url + '" onload="frameLoaded()" onerror="frameErrored()"></iframe>');
 28}
 29
 30function frameLoaded() {
 31 var frame = document.querySelector('iframe');
 32 alert('Loaded ' + frame.contentWindow.location + ' into the IFrame.');
 33 testRunner.notifyDone();
 34}
 35
 36function frameErrored() {
 37 alert('Error loading document into the IFrame.');
 38}

LayoutTests/http/tests/security/xssAuditor/resources/echo-intertag.pl

@@if ($cgi->param('malformed-header') == 9) {
6161 print "X-XSS-Protection: 1; mode=block; report=/fail; report=/fail;\n";
6262}
6363
 64if ($cgi->param('csp') eq '_empty_') {
 65 print "X-WebKit-CSP: reflected-xss\n";
 66} elsif ($cgi->param('csp')) {
 67 print "X-WebKit-CSP: reflected-xss " . $cgi->param('csp') . "\n";
 68}
 69
6470print "Content-Type: text/html; charset=";
6571print $cgi->param('charset') ? $cgi->param('charset') : "UTF-8";
6672print "\n\n";