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

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

Issue 1179633002: Prevent linear-time forcing of tokens by inducing XSSAuditor page blocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Style. 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 0f27adb9a2702709f91855b56171c88164cd807f..a1e1852201d23ac858c3b5065a2e26f52d128f4d 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