RESOLVED FIXED 190947
Post too much text to iFrame could crash webkit
https://bugs.webkit.org/show_bug.cgi?id=190947
Summary Post too much text to iFrame could crash webkit
Kyle
Reported 2018-10-26 01:39:35 PDT
Created attachment 353164 [details] bug demo Sending too much data to iFrame could crash webkit on all iOS. Reproducation Steps: 1. A form with the field which is assigned much text (~250KB). 2. Set the target of the form to an iframe 3. Submit the form Reproduction page: http://adeline.cc/fe/test/post-to-iframe.html HD Demo Videos: https://1drv.ms/f/s!Aq4mpP6jpjzKjqYdjanmchdTycD_HA
Attachments
bug demo (956.59 KB, video/mp4)
2018-10-26 01:39 PDT, Kyle
no flags
Patch (9.00 KB, patch)
2018-11-06 16:36 PST, Chris Dumez
no flags
Alexey Proskuryakov
Comment 1 2018-10-29 17:49:44 PDT
I can reproduce this. It appears to be a jetsam, and it's quite curious indeed. I wonder if it's actually about laying out this text, not form submission.
Radar WebKit Bug Importer
Comment 2 2018-10-30 13:14:40 PDT
Chris Dumez
Comment 3 2018-11-06 13:08:59 PST
Looking at a trace of the WebContent process shortly before the crash we can see it spends a lot of time under: Sample Count, Samples %, CPU %, Symbol 936, 21.8%, 3.4%, WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode) (in WebCore) 936, 21.8%, 3.4%, WebCore::XSSAuditor::init(WebCore::Document*, WebCore::XSSAuditorDelegate*) (in WebCore) 606, 14.1%, 2.2%, WebCore::SuffixTree<WebCore::ASCIICodebook>::build(WTF::String const&) (in WebCore) If I disable XSSAuditor (which is a needed for security) via WebPreferences, the example in question no longer jetsams. I therefore believe it is caused by the XSSAuditor somehow. I have no reason to believe this is a reason regression.
Chris Dumez
Comment 4 2018-11-06 13:12:09 PST
Relevant code: RefPtr<FormData> httpBody = documentLoader->originalRequest().httpBody(); if (httpBody && !httpBody->isEmpty()) { httpBodyAsString = httpBody->flattenToString(); if (!httpBodyAsString.isEmpty()) { m_decodedHTTPBody = canonicalize(httpBodyAsString, TruncationStyle::None); if (m_decodedHTTPBody.find(isRequiredForInjection) == notFound) m_decodedHTTPBody = String(); if (m_decodedHTTPBody.length() >= minimumLengthForSuffixTree) m_decodedHTTPBodySuffixTree = std::make_unique<SuffixTree<ASCIICodebook>>(m_decodedHTTPBody, suffixTreeDepth); } }
Chris Dumez
Comment 5 2018-11-06 13:20:45 PST
Adding Daniel Bates in cc as he is likely more familiar with XSS auditing code.
Chris Dumez
Comment 6 2018-11-06 13:23:30 PST
m_decodedHTTPBodySuffixTree seems to be used as an optimization inside XSSAuditor::isContainedInRequest(). If m_decodedHTTPBodySuffixTree is not initialized then we end up doing the search like so: m_decodedHTTPBody.containsIgnoringASCIICase(decodedSnippet) I have verified that if we do not initialize m_decodedHTTPBodySuffixTree then its does not jetsam. So the issue seems to be that m_decodedHTTPBodySuffixTree may end up being extremely big and cause jetsams (not to mention that constructing it can be very slow).
Chris Dumez
Comment 7 2018-11-06 16:09:12 PST
I will upload a patch shortly.
Chris Dumez
Comment 8 2018-11-06 16:36:12 PST
Geoffrey Garen
Comment 9 2018-11-06 17:06:44 PST
Comment on attachment 354028 [details] Patch r=me
WebKit Commit Bot
Comment 10 2018-11-06 19:12:29 PST
Comment on attachment 354028 [details] Patch Clearing flags on attachment: 354028 Committed r237909: <https://trac.webkit.org/changeset/237909>
WebKit Commit Bot
Comment 11 2018-11-06 19:12:31 PST
All reviewed patches have been landed. Closing bug.
Saam Barati
Comment 12 2018-11-08 15:16:46 PST
Could this change have a performance impact? It's in the range where we have a 1-1.5% speedometer 2 regression on iOS. It seems like the most likely candidate just by glancing at this range: https://trac.webkit.org/log/webkit/trunk?verbose=on&rev=237910&stop_rev=237896
Chris Dumez
Comment 13 2018-11-08 15:19:39 PST
(In reply to Saam Barati from comment #12) > Could this change have a performance impact? It's in the range where we have > a 1-1.5% speedometer 2 regression on iOS. It seems like the most likely > candidate just by glancing at this range: > > https://trac.webkit.org/log/webkit/ > trunk?verbose=on&rev=237910&stop_rev=237896 It could have a performance impact, yes. I am a bit surprised Speedometer is submitting forms though.
Chris Dumez
Comment 14 2018-11-08 15:23:15 PST
(In reply to Chris Dumez from comment #13) > (In reply to Saam Barati from comment #12) > > Could this change have a performance impact? It's in the range where we have > > a 1-1.5% speedometer 2 regression on iOS. It seems like the most likely > > candidate just by glancing at this range: > > > > https://trac.webkit.org/log/webkit/ > > trunk?verbose=on&rev=237910&stop_rev=237896 > > It could have a performance impact, yes. I am a bit surprised Speedometer is > submitting forms though. I have just run Speedometer 2.0 locally and did not see it build any SuffixTree. I would therefore be surprised if the regression was caused by this change.
Chris Dumez
Comment 15 2018-11-08 15:24:13 PST
(In reply to Chris Dumez from comment #14) > (In reply to Chris Dumez from comment #13) > > (In reply to Saam Barati from comment #12) > > > Could this change have a performance impact? It's in the range where we have > > > a 1-1.5% speedometer 2 regression on iOS. It seems like the most likely > > > candidate just by glancing at this range: > > > > > > https://trac.webkit.org/log/webkit/ > > > trunk?verbose=on&rev=237910&stop_rev=237896 > > > > It could have a performance impact, yes. I am a bit surprised Speedometer is > > submitting forms though. > > I have just run Speedometer 2.0 locally and did not see it build any > SuffixTree. I would therefore be surprised if the regression was caused by > this change. Ditto for Speedometer 1.0
Chris Dumez
Comment 16 2018-11-08 15:28:41 PST
(In reply to Chris Dumez from comment #15) > (In reply to Chris Dumez from comment #14) > > (In reply to Chris Dumez from comment #13) > > > (In reply to Saam Barati from comment #12) > > > > Could this change have a performance impact? It's in the range where we have > > > > a 1-1.5% speedometer 2 regression on iOS. It seems like the most likely > > > > candidate just by glancing at this range: > > > > > > > > https://trac.webkit.org/log/webkit/ > > > > trunk?verbose=on&rev=237910&stop_rev=237896 > > > > > > It could have a performance impact, yes. I am a bit surprised Speedometer is > > > submitting forms though. > > > > I have just run Speedometer 2.0 locally and did not see it build any > > SuffixTree. I would therefore be surprised if the regression was caused by > > this change. > > Ditto for Speedometer 1.0 Besides my change, https://trac.webkit.org/changeset/237903/webkit could also have perf impact I believe in the range you provided.
Saam Barati
Comment 17 2018-11-08 15:30:01 PST
(In reply to Chris Dumez from comment #16) > (In reply to Chris Dumez from comment #15) > > (In reply to Chris Dumez from comment #14) > > > (In reply to Chris Dumez from comment #13) > > > > (In reply to Saam Barati from comment #12) > > > > > Could this change have a performance impact? It's in the range where we have > > > > > a 1-1.5% speedometer 2 regression on iOS. It seems like the most likely > > > > > candidate just by glancing at this range: > > > > > > > > > > https://trac.webkit.org/log/webkit/ > > > > > trunk?verbose=on&rev=237910&stop_rev=237896 > > > > > > > > It could have a performance impact, yes. I am a bit surprised Speedometer is > > > > submitting forms though. > > > > > > I have just run Speedometer 2.0 locally and did not see it build any > > > SuffixTree. I would therefore be surprised if the regression was caused by > > > this change. > > > > Ditto for Speedometer 1.0 > > Besides my change, https://trac.webkit.org/changeset/237903/webkit could > also have perf impact I believe in the range you provided. Thanks for looking into this Chris. I'll post on that bug.
Note You need to log in before you can comment on or make changes to this bug.