Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp

Issue 2619783002: CSP: Strip the fragment from reported URLs. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/report-strips-fragment.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google, Inc. All rights reserved. 2 * Copyright (C) 2011 Google, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 const String& header, 1040 const String& header,
1041 RedirectStatus redirectStatus, 1041 RedirectStatus redirectStatus,
1042 ContentSecurityPolicyHeaderType headerType, 1042 ContentSecurityPolicyHeaderType headerType,
1043 ContentSecurityPolicy::ViolationType violationType, 1043 ContentSecurityPolicy::ViolationType violationType,
1044 int contextLine, 1044 int contextLine,
1045 const String& scriptSource) { 1045 const String& scriptSource) {
1046 if (effectiveType == ContentSecurityPolicy::DirectiveType::FrameAncestors) { 1046 if (effectiveType == ContentSecurityPolicy::DirectiveType::FrameAncestors) {
1047 // If this load was blocked via 'frame-ancestors', then the URL of 1047 // If this load was blocked via 'frame-ancestors', then the URL of
1048 // |document| has not yet been initialized. In this case, we'll set both 1048 // |document| has not yet been initialized. In this case, we'll set both
1049 // 'documentURI' and 'blockedURI' to the blocked document's URL. 1049 // 'documentURI' and 'blockedURI' to the blocked document's URL.
1050 init.setDocumentURI(blockedURL.getString()); 1050 String strippedURL = stripURLForUseInReport(
1051 init.setBlockedURI(blockedURL.getString()); 1051 context, blockedURL, RedirectStatus::NoRedirect,
1052 ContentSecurityPolicy::DirectiveType::DefaultSrc);
1053 init.setDocumentURI(strippedURL);
1054 init.setBlockedURI(strippedURL);
1052 } else { 1055 } else {
1053 init.setDocumentURI(context->url().getString()); 1056 String strippedURL = stripURLForUseInReport(
1057 context, context->url(), RedirectStatus::NoRedirect,
1058 ContentSecurityPolicy::DirectiveType::DefaultSrc);
1059 init.setDocumentURI(strippedURL);
1054 switch (violationType) { 1060 switch (violationType) {
1055 case ContentSecurityPolicy::InlineViolation: 1061 case ContentSecurityPolicy::InlineViolation:
1056 init.setBlockedURI("inline"); 1062 init.setBlockedURI("inline");
1057 break; 1063 break;
1058 case ContentSecurityPolicy::EvalViolation: 1064 case ContentSecurityPolicy::EvalViolation:
1059 init.setBlockedURI("eval"); 1065 init.setBlockedURI("eval");
1060 break; 1066 break;
1061 case ContentSecurityPolicy::URLViolation: 1067 case ContentSecurityPolicy::URLViolation:
1062 init.setBlockedURI(stripURLForUseInReport( 1068 init.setBlockedURI(stripURLForUseInReport(
1063 context, blockedURL, redirectStatus, effectiveType)); 1069 context, blockedURL, redirectStatus, effectiveType));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1182
1177 // We need to be careful here when deciding what information to send to the 1183 // We need to be careful here when deciding what information to send to the
1178 // report-uri. Currently, we send only the current document's URL and the 1184 // report-uri. Currently, we send only the current document's URL and the
1179 // directive that was violated. The document's URL is safe to send because 1185 // directive that was violated. The document's URL is safe to send because
1180 // it's the document itself that's requesting that it be sent. You could 1186 // it's the document itself that's requesting that it be sent. You could
1181 // make an argument that we shouldn't send HTTPS document URLs to HTTP 1187 // make an argument that we shouldn't send HTTPS document URLs to HTTP
1182 // report-uris (for the same reasons that we supress the Referer in that 1188 // report-uris (for the same reasons that we supress the Referer in that
1183 // case), but the Referer is sent implicitly whereas this request is only 1189 // case), but the Referer is sent implicitly whereas this request is only
1184 // sent explicitly. As for which directive was violated, that's pretty 1190 // sent explicitly. As for which directive was violated, that's pretty
1185 // harmless information. 1191 // harmless information.
1192 //
1193 // TODO(mkwst): This justification is BS. Insecure reports are mixed content,
1194 // let's kill them. https://crbug.com/695363
1186 1195
1187 std::unique_ptr<JSONObject> cspReport = JSONObject::create(); 1196 std::unique_ptr<JSONObject> cspReport = JSONObject::create();
1188 cspReport->setString("document-uri", violationData.documentURI()); 1197 cspReport->setString("document-uri", violationData.documentURI());
1189 cspReport->setString("referrer", violationData.referrer()); 1198 cspReport->setString("referrer", violationData.referrer());
1190 cspReport->setString("violated-directive", violationData.violatedDirective()); 1199 cspReport->setString("violated-directive", violationData.violatedDirective());
1191 cspReport->setString("effective-directive", 1200 cspReport->setString("effective-directive",
1192 violationData.effectiveDirective()); 1201 violationData.effectiveDirective());
1193 cspReport->setString("original-policy", violationData.originalPolicy()); 1202 cspReport->setString("original-policy", violationData.originalPolicy());
1194 cspReport->setString("disposition", violationData.disposition()); 1203 cspReport->setString("disposition", violationData.disposition());
1195 cspReport->setString("blocked-uri", violationData.blockedURI()); 1204 cspReport->setString("blocked-uri", violationData.blockedURI());
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 if (SecurityOrigin::shouldUseInnerURL(url)) { 1644 if (SecurityOrigin::shouldUseInnerURL(url)) {
1636 return SchemeRegistry::schemeShouldBypassContentSecurityPolicy( 1645 return SchemeRegistry::schemeShouldBypassContentSecurityPolicy(
1637 SecurityOrigin::extractInnerURL(url).protocol(), area); 1646 SecurityOrigin::extractInnerURL(url).protocol(), area);
1638 } else { 1647 } else {
1639 return SchemeRegistry::schemeShouldBypassContentSecurityPolicy( 1648 return SchemeRegistry::schemeShouldBypassContentSecurityPolicy(
1640 url.protocol(), area); 1649 url.protocol(), area);
1641 } 1650 }
1642 } 1651 }
1643 1652
1644 } // namespace blink 1653 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/report-strips-fragment.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698