Bug 153160 - CSP: Don't inherit parent's CSP in PluginDocuments
Summary: CSP: Don't inherit parent's CSP in PluginDocuments
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: BlinkMergeCandidate, InRadar
Depends on:
Blocks:
 
Reported: 2016-01-15 15:12 PST by Daniel Bates
Modified: 2022-10-20 09:40 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2016-01-15 15:12:39 PST
We should merge <https://src.chromium.org/viewvc/blink?view=rev&revision=191037>.

Don't inherit parent's CSP in PluginDocuments

Inheriting the CSP in a PluginDocument causes <iframe src="foo.pdf"> to
be blocked if the parent's CSP forbids <embed src="foo.pdf">, as the
iframe turns into a PluginDocument with an <embed> tag inside it.

The only exception is that the plugin-types directive is still inherited from a parent document to a child PluginDocument, which preserves the current behavior and is required by the CSP spec.
Comment 1 Radar WebKit Bug Importer 2016-01-27 20:49:05 PST
<rdar://problem/24383285>
Comment 2 Ryan Reno 2022-10-20 09:35:35 PDT
I can't reproduce the bug this Blink revision fixed.

index.html:
-----------
<!DOCTYPE html>
<iframe src="plugin-test.html"></iframe>

plugin-test.html:
----------------
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="object-src 'none'">
<iframe src="foo.pdf"></iframe>

The above example displays the PDF as expected.

Another attempt I made was to simulate what the tests in that revision simulated with a python server which responds to any GET request with

Content-Type: application/x-webkit-netscape-test
Content-Security-Policy: object-src 'none'

<h2>test</h2>

This causes WebKit to initiate a download of a plain text file containing the text "test"

At no point does CSP block anything.
Comment 3 Ryan Reno 2022-10-20 09:39:50 PDT
Additionally, this example also displays the PDF as expected.

<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="object-src 'none'">
<iframe src="foo.pdf"></iframe>
Comment 4 Ryan Reno 2022-10-20 09:40:53 PDT
(In reply to Ryan Reno from comment #3)
> Additionally, this example also displays the PDF as expected.
> 
> <!DOCTYPE html>
> <meta http-equiv="Content-Security-Policy" content="object-src 'none'">
> <iframe src="foo.pdf"></iframe>

actually I don't know if that's expected or not? Maybe that's a separate issue.