[Docs] Fix documentation of onclick to make it clear 1) the data is not HTML escaped 2) there is also a href option alternative#117
Conversation
…ot HTML escaped 2) there is also a href option alternative
|
Can you give me a specific example to help me understand what issue may come out of this? |
|
Suppose I have this example: It's not obvious that this code is bugged. It's going to cause invalid output for a whole range of valid inputs. For example, if I enter
Which is a bug but not dangerous. However, I can also enter this: which is an XSS attack
This is a huge footgun and a security issue. In this case, I can only XSS myself but imagine if you could control the toast title or description of a message sent to another user. The security issue might not be immediately caught by developers since it only triggers if you use certain characters in your string. Most other libraries mark APIs that directly assign HTML as dangerous. For example, React has Most template engines automatically escape any strings inserted in HTML by default. Injection attacks are the #5 most common kind of security vulnerability acoring to OWASP Owasp recomends:
I would recommend offering a safe API, at least by default. You could potential offer a mechanic for manually setting the HTML for specialized use cases but in my opinion the default API should be safe and the dangers of any alternative APIs should be well described. |


This should really just be fixed but that would probably break things. For now this updates the documentation to make it clear you need to be super careful using this API.