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

Sanitizer API #86

Closed
annevk opened this issue Nov 9, 2022 · 5 comments
Closed

Sanitizer API #86

annevk opened this issue Nov 9, 2022 · 5 comments
Assignees
Labels
from: Google Proposed, edited, or co-edited by Google. from: Mozilla Proposed, edited, or co-edited by Mozilla. from: other Proposed, edited, or co-edited by an individual or entity that doesn't have a more specific label. position: support topic: dom Spec relates to DOM (Document Object Model) topic: html Spec relates to HTML (Hypertext Markup Language) venue: WICG Proposal is incubated in the Web Incubator Community Group

Comments

@annevk
Copy link
Contributor

annevk commented Nov 9, 2022

Request for position on an emerging web specification

Information about the spec

Design reviews and vendor positions

Bugs tracking this feature

  • WebKit Bugzilla:
  • Radar:

Anything else we need to know

This was previously raised in https://lists.webkit.org/pipermail/webkit-dev/2021-March/031731.html.

The API offers an innerHTML replacement that is supposed to be safe-by-default.

@annevk annevk added topic: html Spec relates to HTML (Hypertext Markup Language) topic: dom Spec relates to DOM (Document Object Model) venue: WICG Proposal is incubated in the Web Incubator Community Group from: Google Proposed, edited, or co-edited by Google. from: Mozilla Proposed, edited, or co-edited by Mozilla. from: other Proposed, edited, or co-edited by an individual or entity that doesn't have a more specific label. labels Nov 9, 2022
@annevk
Copy link
Contributor Author

annevk commented Nov 9, 2022

I personally think this is a good idea overall and as it gives developers a straightforward tool to combat XSS. Feedback I've given to date focused on simplifying the overall setup and making it better suited as a DOM API (e.g., operating on local names and namespaces rather than qnames).

@rniwa
Copy link
Member

rniwa commented Nov 12, 2022

Yeah, the idea of introducing sanitizer API in the browser doesn't seem like a bad idea. I'm not sure about the exact API shape.

@annevk
Copy link
Contributor Author

annevk commented May 5, 2023

The API shape has been under discussion and WICG/sanitizer-api#193 captures what has some tentative agreement based on the meeting notes at WICG/sanitizer-api#192.

It essentially comes down to new HTML parser APIs that also support XSS filtering (and declarative shadow roots by default, as new HTML parser APIs should):

  • Element.prototype.setHTML(input, { filter }): provides partial innerHTML parity. It parses, filters, and inserts.
  • Document.parseHTML(input, { filter }): provides partial DOMParser parity. It parses, filters, and returns a Document object. (Reportedly an entry point used a lot in existing libraries.)

And then both of these get unsafe variants to achieve almost-full parity. I say almost, because there's currently nothing planned for XML, which seems fine.

Providing replacements for insertAdjacentHTML() is still on the table as well, but probably separately from the Sanitizer API effort.

I'm inclined to endorse this with "position: support", but wanted to give a bit more time for the community to review these changes.

@johnwilander
Copy link

I like this functionality being available to developers.

@annevk
Copy link
Contributor Author

annevk commented Jul 7, 2023

Having discussed this more with colleagues and given the lack of opposing feedback in this issue I suggest we label this as "position: support" one week from now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from: Google Proposed, edited, or co-edited by Google. from: Mozilla Proposed, edited, or co-edited by Mozilla. from: other Proposed, edited, or co-edited by an individual or entity that doesn't have a more specific label. position: support topic: dom Spec relates to DOM (Document Object Model) topic: html Spec relates to HTML (Hypertext Markup Language) venue: WICG Proposal is incubated in the Web Incubator Community Group
Development

No branches or pull requests

3 participants