-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sim is vulnerable to xss #3
Comments
It's passing a string directly to |
We could replace with SubSupText. But why is this not a general vulnerability for any sim that uses HTMLText? |
It's very much a general vulnerability if you pass a translated string (i.e. a string that can be controlled by query parameters) to an HTMLText. That's one of the primary reasons for the stringTest=xss testing. We really need more rich-text support, whether that parses it and uses Text nodes (so it could be rendered in WebGL/etc.), or whether it's validation-based and uses HTMLText (which would reject or reform strings that could be potential exploits). |
Rather than replace HTMText with SubSupText in the chains example, it would preferable to fix the vulnerability in HTMLText. Also noting that that chains should include a SubSupText example, and it currently does not, see #4. |
It's not a vulnerability in HTMLText directly, as it's designed to allow arbitrary content. I'm looking into things like https://github.com/ecto/bleach for the browser, which would sanitize the incoming string to remove anything not on a whitelist. If we have a list of desired rich-text support, it may be more beneficial to extend/generalize SubSupText. |
Best solution so far looks to find an HTML parser (e.g. https://github.com/andrejewski/himalaya) and then either construct white-listed HTML from it (rendered with HTMLText), or to use that parsing to do the equivalent of a more-structured SubSupText that handles more markup with Text nodes. e.g.: himalaya.parse( '<b>boo <i>who</i></b><sup>2</sup>' );
// gives
[
{
"type": "Element",
"tagName": "b",
"attributes": {},
"children": [
{
"type": "Text",
"content": "boo "
},
{
"type": "Element",
"tagName": "i",
"attributes": {},
"children": [
{
"type": "Text",
"content": "who"
}
]
}
]
},
{
"type": "Element",
"tagName": "sup",
"attributes": {},
"children": [
{
"type": "Text",
"content": "2"
}
]
}
] tagging for developer meeting discussion (I'll be able to describe the different approaches and their drawbacks). |
Documentation on RichText (for discussion during developer meeting): Displays rich text with HTML-style tags by splitting it into multiple (child) Text nodes. It should be a close to drop-in replacement for SubSupText, and supports the following markup and features:
Examples from the scenery-phet demo:
|
In #3 (comment), it looks like @jonathanolson has created something new, |
I have moved discussion of RichText to phetsims/scenery-phet#300. |
@jonathanolson is this still a problem? Ready to close? |
Run the sim with
?stringTest=xss
to be redirected. Running on current master (4/4 1:30 PM).The text was updated successfully, but these errors were encountered: