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

Unified Diff: Source/core/html/parser/XSSAuditor.cpp

Issue 1190433008: Prevent linear-time forcing of tokens by inducing XSSAuditor page blocks. (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2403
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/security/xssAuditor/resources/echo-form-action.pl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/XSSAuditor.cpp
diff --git a/Source/core/html/parser/XSSAuditor.cpp b/Source/core/html/parser/XSSAuditor.cpp
index a4876ec71f558c8a103f6590f09de34ba0e9ee6f..a847f39bd26091f3bbd3cb84f0ffb90b92ca3bc7 100644
--- a/Source/core/html/parser/XSSAuditor.cpp
+++ b/Source/core/html/parser/XSSAuditor.cpp
@@ -710,7 +710,14 @@ String XSSAuditor::canonicalize(String snippet, TruncationKind treatment)
String decodedSnippet = fullyDecodeString(snippet, m_encoding);
if (treatment != NoTruncation) {
- decodedSnippet.truncate(kMaximumFragmentLengthTarget);
+ if (decodedSnippet.length() > kMaximumFragmentLengthTarget) {
+ // Let the page influence the stopping point to avoid disclosing leading fragments.
+ // Stop when we hit whitespace, since that is unlikely to be part a leading fragment.
+ size_t position = kMaximumFragmentLengthTarget;
+ while (position < decodedSnippet.length() && !isHTMLSpace(decodedSnippet[position]))
+ ++position;
+ decodedSnippet.truncate(position);
+ }
if (treatment == SrcLikeAttributeTruncation)
truncateForSrcLikeAttribute(decodedSnippet);
else if (treatment == ScriptLikeAttributeTruncation)
« no previous file with comments | « LayoutTests/http/tests/security/xssAuditor/resources/echo-form-action.pl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698