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 vulnerable #5

Closed
adamchainz opened this issue Apr 1, 2021 · 4 comments
Closed

XSS vulnerable #5

adamchainz opened this issue Apr 1, 2021 · 4 comments
Assignees

Comments

@adamchainz
Copy link

The code in renderers.py uses f-strings to template HTML with HTML-escaping incoming strings. This means user content being used in a response could be reflected and rendered in the browser.

@danjac
Copy link
Collaborator

danjac commented Apr 1, 2021

Good point, let's fix that.

@adamchainz
Copy link
Author

You can do this by rendering via Django templates, jinja2, or html.escape().

@danjac
Copy link
Collaborator

danjac commented Apr 1, 2021

The TurboStream and TurboFrame classes already have template classes/methods for handling template-based content, so you would likely do something like:

TurboStream("target").append.template("tmpl.html", {}).render()

So rendering in such cases is fine, as the HTML string is already handled with a Django templates. In such cases we can pass this content through mark_safe as it can be assumed to have already been handled by the Django template engine.

@danjac danjac self-assigned this Apr 1, 2021
@danjac
Copy link
Collaborator

danjac commented Apr 2, 2021

Fixed in 0.0.39.

@danjac danjac closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants