Bug 205979 - REGRESSION (r253662): Large Data URLs are not being handled properly
Summary: REGRESSION (r253662): Large Data URLs are not being handled properly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on: 203825
Blocks:
  Show dependency treegraph
 
Reported: 2020-01-08 17:49 PST by Brent Fulgham
Modified: 2020-01-10 09:29 PST (History)
10 users (show)

See Also:


Attachments
Patch (1.29 KB, patch)
2020-01-08 17:58 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch for landing (3.37 KB, patch)
2020-01-09 11:33 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2020-01-08 17:49:04 PST
The changes in Bug 203825 restricted the size of URLs too much. We need to allow reasonably sized data and other URLs.
Comment 1 Brent Fulgham 2020-01-08 17:56:48 PST
<rdar://problem/58346124>
Comment 2 Brent Fulgham 2020-01-08 17:58:51 PST
Created attachment 387173 [details]
Patch
Comment 3 Simon Fraser (smfr) 2020-01-08 18:00:26 PST
Comment on attachment 387173 [details]
Patch

How do we know what a "reasonable" data URI size is?
Comment 4 Simon Fraser (smfr) 2020-01-08 18:00:55 PST
Also having values in hex isn't very helpful.
Comment 5 Brent Fulgham 2020-01-08 18:05:37 PST
According to <https://bugs.chromium.org/p/chromium/issues/detail?id=44820#c1>, Chrome limits data URI's to 2 MB.

This patch uses 64 MB, which if anything might be a bit large.
Comment 6 Brent Fulgham 2020-01-08 18:06:53 PST
@Alex Christensen: Does the URL Parser process all of the contents of a data URL? Could I just exclude data URIs from the test?
Comment 7 Brent Fulgham 2020-01-08 18:08:07 PST
Comment on attachment 387173 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=387173&action=review

> Source/WebCore/page/SecurityOrigin.cpp:49
> +constexpr unsigned maximumURLSize = 0x04000000;

This changes from 32 KB to 64 MB, which might be too big for memory-constrained devices. Might be good to keep the limit and just skip the check for data URIs?

Or bump the standard URL limit, but have a much larger limit for data URIs only?
Comment 8 Brent Fulgham 2020-01-09 09:20:36 PST
(In reply to Brent Fulgham from comment #6)
> @Alex Christensen: Does the URL Parser process all of the contents of a data
> URL? Could I just exclude data URIs from the test?

I created a test case, and confirmed that data URLs are processed the same way, and can run up against this problem too.
Comment 9 youenn fablet 2020-01-09 09:53:57 PST
Comment on attachment 387173 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=387173&action=review

>> Source/WebCore/page/SecurityOrigin.cpp:49
>> +constexpr unsigned maximumURLSize = 0x04000000;
> 
> This changes from 32 KB to 64 MB, which might be too big for memory-constrained devices. Might be good to keep the limit and just skip the check for data URIs?

Should we add a 32KB+1 data URL test?
 
> Or bump the standard URL limit, but have a much larger limit for data URIs only?

I think it might be best to bump to 64 MB.
We do not know what happens for custom schemes for instance.
Also, javascript scheme should probably have the same constraint has data URL.

We could also decide to decrease specific schemes like HTTP/HTTPS/FTP URLs back to 0x8000 if that is adding some kind of protection.
Comment 10 Brent Fulgham 2020-01-09 11:33:59 PST
Created attachment 387249 [details]
Patch for landing
Comment 11 Alex Christensen 2020-01-09 12:04:04 PST
(In reply to Brent Fulgham from comment #6)
> @Alex Christensen: Does the URL Parser process all of the contents of a data URL?
It does.
Comment 12 WebKit Commit Bot 2020-01-09 13:22:58 PST
The commit-queue encountered the following flaky tests while processing attachment 387249 [details]:

storage/indexeddb/detached-iframe.html bug 206028 (author: achristensen@apple.com)
The commit-queue is continuing to process your patch.
Comment 13 WebKit Commit Bot 2020-01-09 13:23:04 PST
The commit-queue encountered the following flaky tests while processing attachment 387249 [details]:

imported/w3c/web-platform-tests/content-security-policy/script-src/scriptnonce-changed-1.html bug 206029 (author: psaavedra@igalia.com)
The commit-queue is continuing to process your patch.
Comment 14 WebKit Commit Bot 2020-01-09 14:41:36 PST
Comment on attachment 387249 [details]
Patch for landing

Clearing flags on attachment: 387249

Committed r254301: <https://trac.webkit.org/changeset/254301>
Comment 15 WebKit Commit Bot 2020-01-09 14:41:38 PST
All reviewed patches have been landed.  Closing bug.
Comment 16 Darin Adler 2020-01-09 17:17:42 PST
Comment on attachment 387249 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=387249&action=review

> Source/WebCore/page/SecurityOrigin.cpp:49
> +constexpr unsigned maximumURLSize = 0x04000000;

Could we put a comment here explaining the rationale behind this maximum? For example, I know it needs to be "big enough for reasonable data URI sizes" but not how we decided what is reasonable. And I don’t know why it shouldn’t be even bigger. We should just "show our work" here so someone later can make a smart decision about changing this or not changing it.
Comment 17 Brent Fulgham 2020-01-10 09:29:55 PST
(In reply to Darin Adler from comment #16)
> Comment on attachment 387249 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=387249&action=review
> 
> > Source/WebCore/page/SecurityOrigin.cpp:49
> > +constexpr unsigned maximumURLSize = 0x04000000;
> 
> Could we put a comment here explaining the rationale behind this maximum?
> For example, I know it needs to be "big enough for reasonable data URI
> sizes" but not how we decided what is reasonable. And I don’t know why it
> shouldn’t be even bigger. We should just "show our work" here so someone
> later can make a smart decision about changing this or not changing it.

Sure -- I'll add a comment in a follow-up.