Re: [HTML imports]: Imports and Content Security Policy

Hi Frederik,
Thanks for bringing it up!

As you pointed out, CSP of imported documents essentially extends the
set of allowed domains. I thought I was useful for component authors to
specify their own domains, like one of their own CDN.

I'm not sure how it is threatening because components won't have any
sensitive state in it
because HTML Imports doesn't have any isolation mechanism after all. It
however might be an optimistic view.

Being conservative, it could be better to apply master document's CSP to
whole import tree
and ignore CSPs on imports. It is less flexible and page authors need to
list all domains for
possibly imported resources, but this flat model looks what Web is relying

I'd appreciate any feedback and/or suggestions here. It seems there is some
progress on CSP side.
It would be great if there is some new mechanism to handle CSP of
Things like ES6 modules might get benefit from it as well.

On Fri, Jan 10, 2014 at 12:19 AM, Frederik Braun <> wrote:

> Hi,
> I have subscribed to this list because my colleague Gabor (CC) and I
> found a few issues with Content Security Policies applied to HTML imports.
> The current draft
> (, Jan
> 9) suggests that import loading is restricted through a script-src
> attribute, which is probably fine.
> Our issue, however is with the next layer: "Each import is restricted by
> its own Content Security Policy".
> Let's discuss how this could work: The document subtree of the imported
> document has its own CSP, just like the parent document. Hence, there
> are two CSPs guarding one browsing context (i.e. the window object).
> This brings the issue that a restricted imported document can ask the
> non-restricted parent document to do its dirty work:
> Imagine a CSP on the parent document ( that only allows
> and The CSP on allows only
> ('self'). The imported document could easily contain a
> script that attaches a script node to the parent document's body (other
> subtree) which loads further resources from The restriction
> against has been subverted, hasn't it?
> If we interpreted this more freely, we could also consider combining the
> two CSPs somehow, let's see how this could work:
> Scenario A) The CSP of the main and the imported document are loosely
> combined, i.e. the union set is built. The whole document that formerly
> had a policy of "default-src:" gets a new policy of
> "default-src:", because the import has this policy specified.
> This case brings multiple issues: Allowing resource loads
> depends on whether the web server at serves its http
> response quickly. This issue is only getting worse with nested imports
> in which imported documents A and B both import another document C -
> which chain up to the parent is the correct one? Via A or B?
> Scenario B) The CSP of the main and the imported document are forming a
> strict combination (intersection): The CSP on the imported document
> ( would then have to explicitly allow,
> otherwise including it would break the importing site. This is unlikely
> to be intended. The previous example with imported documents A and B
> that both import C applies makes it impossible to solve.
> Now, what seems to make sense instead is that the CSP of the imported
> website is completely *disregarded*. This would lead to the sad fact
> that the importer ( cannot treat entirely as a
> black box, as it has to inspect which resources it intends to load and
> selectively allow them in their own CSP. On the other hand, this
> wouldn't bring any of the previously mentioned side-effects. The actual
> owner of the document is fully in charge.
> What do you think?
> Frederik


Received on Friday, 10 January 2014 02:52:30 UTC