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

Xss fix #40136

Closed
wants to merge 1 commit into from
Closed

Xss fix #40136

wants to merge 1 commit into from

Commits on Dec 15, 2020

  1. fix(core): fix possible XSS attack in development through SSR.

    Escape the content of the strings so that it can be safely inserted into a comment node.
    The issue is that HTML does not specify any way to escape comment end text inside the comment.
    `<!-- The way you close a comment is with "-->". -->`. Above the `"-->"` is meant to be text
    not an end to the comment. This can be created programmatically through DOM APIs.
    
    ```
    div.innerHTML = div.innerHTML
    ```
    One would expect that the above code would be safe to do, but it turns out that because comment
    text is not escaped, the comment may contain text which will prematurely close the comment
    opening up the application for XSS attack. (In SSR we programmatically create comment nodes which
    may contain such text and expect them to be safe.)
    This function escapes the comment text by looking for the closing char sequence `-->` and replace
    it with `-_-_>` where the `_` is a zero width space `\u200B`. The result is that if a comment
    contains `-->` text it will render normally but it will not cause the HTML parser to close the
    comment.
    mhevery committed Dec 15, 2020
    Copy the full SHA
    894286d View commit details
    Browse the repository at this point in the history