New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 686516 link

Starred by 11 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Media Source URL defined in iframe sandbox being blocked

Reported by fwy1...@gmail.com, Jan 29 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

Steps to reproduce the problem:
1. Code: https://gist.github.com/anonymous/b016c856b9f667112cdc3b90fed5a0ad
2. python -m SimpleHTTPServer

visit http://127.0.0.1:8000/out.html

What is the expected behavior?
[inside sandbox] Source Created!  in.html:23:9

What went wrong?
Chrome blocks the script from accessing that mediasource URL.
Not allowed to load local resource: blob:null/a8c584d3-bcd1-4c5a-8d4a-f912a4f1a0c6

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 55.0.2883.87  Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: Shockwave Flash 24.0 r0

Hello!

I am writing a JavaScript program that runs in an iframe sandbox. It creates a Media Source (via Media Source Extensions API) inside the iframe, and tries to append data to its buffer.

Code: https://gist.github.com/anonymous/b016c856b9f667112cdc3b90fed5a0ad

$ python -m SimpleHTTPServer

http://127.0.0.1:8000/out.html

Chrome blocks the script from accessing that mediasource URL.

```
Not allowed to load local resource: blob:null/a8c584d3-bcd1-4c5a-8d4a-f912a4f1a0c6
```

but Firefox does not block it.

```
[inside sandbox] Source Created!  in.html:23:9
```

Then I closed Chrome, restarted it with `google-chrome --allow-file-access-from-files`, but I had the same problem. It didn't help.

Since the iframe is sandboxed, the mediasource URL starts with `blob:null/`, but after all the script inside the iframe is creating a mediasource URL inside the iframe. It does not induce any network traffic. It does not try to access any resources outside the iframe. I believe it should not considered as a cross-origin request.

A [relevant issue](https://bugs.chromium.org/p/chromium/issues/detail?id=379206) was opened two years ago, but was closed due to lack of response from the bug reporter.

This sandbox configuration is actually from [ZeroNet](https://zeronet.io). WebTorrent is [affected](https://github.com/feross/webtorrent/issues/783) by this Chrome bug.

Best,
[ZeroMux](mai1to ZeroMux__at__tuta dot io) dev
 
Components: Blink>Loader Internals>Media>Source Blink>HTML>IFrame Blink>FileAPI Blink>SecurityFeature
Status: Untriaged (was: Unconfirmed)
Confirmed on Windows 7 and Chrome 55.

An online reproduction URL -
http://run.plnkr.co/ytCzm2GfUt9Cdbvl/

If it shows an error 404 or something, go to this URL -
http://plnkr.co/edit/vZIXkFcsFEScKYm5KPNt?p=preview
And click on the little blue go-full-screen button at the top right.
(And then copy the URL of the annoying popup window into a full blown tab or use the show as tab option)

Comment 2 Deleted

Ack, posted my comment to the wrong bug. No idea on this one at the moment.
I defer to the security experts on this one. It looks like the canDisplay(url) check in https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp?rcl=a51779b5e41d1d8e1498e8dc10d4795b5988515f&l=1339 is saying "no" (from log on a local repro:)

selectMediaResource(...)
MDW frame=(non-null) document().getSecurityOrigin()->canDisplay(url)=0
isSafeToLoadURL(..., "blob:null/65298a9f-5dfa-4be8-8a9a-cb4c77b34957") -> FALSE rejected by SecurityOrigin
noneSupported(...)

Cc: mlamouri@chromium.org
Cc: mkwst@chromium.org jsb...@chromium.org
Mike, thoughts on this, c#4? Could one of the teams triage this and update the right component?
Components: -Blink>HTML>IFrame -Blink>SecurityFeature -Blink>FileAPI -Blink>Loader
Internals>Media>Source looks correct. Dropping the others.
Cc: -jsb...@chromium.org
mkwst: Can you please check my interpretation of the specs below?

The Media Source Extensions spec defers to the File API spec for URL.createObjectURL() [1].
Blob URLs must be created with the same origin as the incumbent settings object [2, 3]. This should actually read the "current settings object" [4]. This ends up being the document's settings object (mild handwaving here), which contains an unique opaque origin [5]. This origin is then serialized as "null" when forming the blob's URL.

Superficially, it seems like this issue is an undesirable effect of the blob's origin having to round-trip through URL serialization before the security checks are performed. However, the URL spec states that when parsing blob: URLs, we should use the blob ID in the path to look up the Blob in the registry, and return a structured clone of the blob URL stored there [6]. This would mean the unique opaque origin compares equal to the request's current origin in step 11 of a main fetch, as specified in the Fetch spec [7].

Long story short, we seem to be in the wrong here.

[1] https://w3c.github.io/media-source/#url
[2] https://w3c.github.io/FileAPI/#originOfBlobURL
[3] https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
[4] https://github.com/w3c/FileAPI/issues/60
[5] https://html.spec.whatwg.org/multipage/browsers.html#concept-origin
[6] https://url.spec.whatwg.org/#url-parsing
[7] https://fetch.spec.whatwg.org/#main-fetch
Owner: wolenetz@chromium.org
Status: Assigned (was: Untriaged)
matt, can you take a look c#9?
Actually, it seems to me that we're doing the right thing at the File API level. Blob URLs are read correctly even in sandboxed iframes.

WPT test CL: http://crrev.com/2678223002

This makes me guess that the bug lies in MediaSource code.

Sign in to add a comment