-
Notifications
You must be signed in to change notification settings - Fork 79
How to handle <template>? #42
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
Comments
Related: are there other cases where the type of an element's parent/grandparent affects the security contracts of its contents/attributes? E.g. is it possibly for there to be a tree of nodes underneath a |
There are templating systems that mutate |
Generalizing, yes. As long as the application reads from the DOM, and then makes the security decisions based on the read result, one can have vulnerabilities based on any DOM structure that would match the DOM fetching criteria (a la script gadgets).
Yes, #133 demonstrates this. For JavaScript scripts, only text nodes and only present before a Both |
Closing for now. |
Client-side templating systems (such as polymer, angular, knockoutjs, etc) generally make the assumption that the elements and attributes that make up a template are trustworthy. This is primarily because contents and attributes elements underneath templates may contain template expressions, which are evaluated as code (see e.g., https://angular.io/guide/security#angulars-cross-site-scripting-security-model -- Angular happens to not use
<template>
but is the one template system that actually documents this assumption).Thus, while
el.textContent = untrusted
is generally harmless, it is a potential vulnerability ifel
is a child/grandchild ofHTMLTemplateElement
.It's not clear what set of types make sense for element contents/attributes of children of a
<template>
; I suspect this depends on the semantics of the template system / framework that interprets them. Furthermore, it seems generally undesirable for frameworks/application to rely on runtime-manipulation of templates (it's indicative that many such frameworks suggest use of a compilation step for production deployments, e.g., https://www.polymer-project.org/2.0/toolbox/build-for-production, https://angular.io/guide/security#offline-template-compiler).With that in mind, it might make sense to simply make children/grandchildren of
HTMLTemplateElement
completely unmodifiable?The text was updated successfully, but these errors were encountered: