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: templates are vulnerable to XSS #91

Open
empijei opened this issue May 10, 2022 · 0 comments
Open

Security: templates are vulnerable to XSS #91

empijei opened this issue May 10, 2022 · 0 comments

Comments

@empijei
Copy link

empijei commented May 10, 2022

Escaping is intentionally not contextual. As the security section states the only supported automatic escaping is HTML-based (link). This means that any use of this template that interpolates user-controlled data in a different context is vulnerable to XSS.

Here is one example:

<img onclick="{{interpolating action}}">

If the interpolating action outputs something like "javascript:alert(1)" the code will be executed.

Please add a section to the security paragraph of the README documenting that quicktemplate is not secure to use. As far as in understand this package only supports manual escaping, and only for specific kinds of escaping, and this leads to vulnerable templates.

As an alternative, implement contextual autoescaping. As a reference for autoescaping and documentation on how it works you can take a look at the standard library security model: https://pkg.go.dev/html/template#hdr-Security_Model. Disclaimer: this is not easy to do and I think it is beyond the scope of this package.

Please let me know if you need any assistance or explanation about the threats and potential dangers of using this library as it is today, I'd be happy to help :)

@empijei empijei changed the title Security: Document that templates are vulnerable to XSS Security: templates are vulnerable to XSS May 10, 2022
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

1 participant