Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is there no type for style / CSS? #104

Closed
annevk opened this issue Jan 14, 2019 · 6 comments
Closed

Why is there no type for style / CSS? #104

annevk opened this issue Jan 14, 2019 · 6 comments
Labels

Comments

@annevk
Copy link
Member

annevk commented Jan 14, 2019

CSP does consider it problematic and there have been some purely CSS-based exploits.

@koto
Copy link
Member

koto commented Jan 14, 2019

Do you mean the type for:

  • the stylesheet URL (e.g. <link rel=stylesheet href>,
  • stylesheet text (e.g. inline <style> content),
  • the individual CSS properties?

The reason for TT being CSS-agnostic is that we started with something that's limited in scope to prevent DOM XSS, and stylesheets cannot cause that (assuming expression: is not a thing in modern browsers). Indeed the repeated feedback is to add CSS-related types. To start the discussion, which of the above would be useful to authors?

+@sebmarkbage +@xtofian

@sebmarkbage
Copy link

All three would be useful.

The <link> and <style> cases are typically solved by tools today because it is fairly commonly understood that you don't want injection to add additional properties. It would be nice to enforce this.

The individual CSS properties case is trickier because it is not well known outside very specialized circles. There is a lot more ad-hoc code that will deal with raw strings today. This likely means that it is a more difficult upgrade path but also that this is an active vulnerable surface today which would benefit from Trusted Types.

There is some significant overlap with CSS Typed OM ImageValue here is as well. That solves most issues on its own but tying it to a scoped policy might have additional value.

@annevk
Copy link
Member Author

annevk commented Jan 15, 2019

You also need style="" I suspect.

@koto
Copy link
Member

koto commented Jan 17, 2019

<link> is problematic as its href attribute means different things, depending on the value of rel - #6. For now, we just require TrustedURL there.

I'll look into how involved would the style types implementation be.

@koto
Copy link
Member

koto commented Jul 23, 2019

We decided to focus the Trusted Types v1 on DOM XSS only, so protecting against style injections are not in scope for now. We can amend the API in the future revisions.

@koto koto closed this as completed Jul 23, 2019
@koto
Copy link
Member

koto commented Sep 3, 2019

It's possible to add support to custom types and custom sinks to the API like so: https://gist.github.com/koto/1d044f6029ee337beffb4487b80f8b02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants