-
Notifications
You must be signed in to change notification settings - Fork 76
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
Consider enforcing TT for custom attributes. #288
Comments
I didn't get the benefit of having TT enforcement on these attributes. If anything from custom attribute would end up in innerHTML, then TT check would happen at that point, and it wouldn't make much difference if we do this earlier or later? Could you elaborate bit more on benefits of having this? |
The examples in the original comment seem like cases in which TT enforcement would be helpful. Adding attributes to an element directly can result in script execution when the element is attached to the page. Some attributes (like Standardizing on a naming convention would also make crafting a TT policy simpler for the |
Shouldn't this be a concern of the framework/library? |
Let's postpone this until there's broader community requests to make sure we understand the use case more. |
Many modern frameworks use
data-
attributes for a number of purposes, up to and including script execution (see Script Gadgets for some examples). While the browser understands the purpose of built-in attributes, and can bind them to a Trusted Type for enforcement insetAttribute(...)
, et al, we can't do the same fordata-
attributes, as we don't understand their purpose.In other parts of the platform, we've established naming conventions that we then imbue with meaning (e.g.
__Secure-
and__Host-
cookie name prefixes). Perhaps doing the same here could be helpful. For example, we could extend thedata-
prefix to include type information (data-html-
,data-script-
,data-script-url-
), and establish the same protections for those attributes as we would for their built-in equivalents (srcdoc
,onclick
,src
). To spell this out a bit:The information contained in this encoding might also be useful in other contexts. Sanitizers, for instance, could make different decisions about these attributes. See WICG/sanitizer-api#20 (comment), for instance.
Note: The prefix model proposed above is one spelling that makes sense to me. You could also imagine
data-trustedhtml-
ordata-danger!!!-
. Or suffixes! Or any other spelling that makes you happier. :)The text was updated successfully, but these errors were encountered: