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

[Security] XSS issue when rendering article content and comments using markdown library #144

Closed
ashleybroughton opened this issue Jun 25, 2018 · 8 comments
Labels
bug Something isn't working

Comments

@ashleybroughton
Copy link
Contributor

This could lead to some nefarious edits.

image

image

@ashleybroughton
Copy link
Contributor Author

This should be fixed in most browsers by CSP when this is fully implemented. As for older browsers, we should be encoding the user input when saving it to the database and / or displaying the content.

@ashleybroughton ashleybroughton changed the title [Security] Editing articles allows CSS [Security] HTML should be encoded properly Jun 26, 2018
@ashleybroughton
Copy link
Contributor Author

ashleybroughton commented Jun 26, 2018

In addition to the above example, tags appear to be allowed which could allow someone to embed a remote image and track the users of the site.

Again, this will likely be fixed when we implement CSP fully, but ideally we should be encoding HTML, or implementing a markdown style syntax.

image

@ashleybroughton ashleybroughton changed the title [Security] HTML should be encoded properly [Security] User input should be encoded when saved or being displayed Jun 26, 2018
@ashleybroughton
Copy link
Contributor Author

ashleybroughton commented Jun 26, 2018

Another example that could be abused for persistent xss

image

image

@ashleybroughton
Copy link
Contributor Author

I just noticed that we appear to be using the Westwind.AspNetCore.Markdown package and the <markdown .. /> tag for rendering the comments and article content.

Is this perhaps a bug in that framework?

@ashleybroughton
Copy link
Contributor Author

@ashleybroughton ashleybroughton changed the title [Security] User input should be encoded when saved or being displayed [Security] XSS issue when rendering article content and comments using markdown library Jun 26, 2018
@essenbee
Copy link
Contributor

essenbee commented Jun 26, 2018

Our team has used HtmlSanitizer in the past. I will did out the code from another project, because you do have to be aware of nefarious people "encoding/ escaping" script tags and suchlike, which means you may have to run the sanitizer several times against the content. not sure.

@essenbee
Copy link
Contributor

Hi @ashleybroughton , I think Mr Strahl’s response to the issue you raised is rather naive. We need a better solution.

@ashleybroughton
Copy link
Contributor Author

ashleybroughton commented Jun 27, 2018

Hi @essenbee . I did try HtmlSanitizer quickly, but I don't have much experience with it. It just seemed to turn the resulting markdown HTML into encoded tags, which means we don't get any of the markdown benefits.

This is definitely something we need to find a good solution for.

Edit:

This is how I was using it

image

It turns this

image

into this

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants