0

So, I am writing learning app in react, I want simulate xss attack.

The problem is, that react automatically escapes everything for me.

Example:

var htmlString = '<img src="javascript:alert('XSS!')" />';
.
.
.
render() {
    return (
        <div>{htmlString}</div>
    );
}

All is ok, no xss :-)

But I want enable xss, is there any way how to 'do it'?

nope123
  • 349
  • 2
  • 6
  • 13
  • Possible duplicate of [What does it mean when they say React is XSS protected?](https://stackoverflow.com/questions/33644499/what-does-it-mean-when-they-say-react-is-xss-protected) – XCS Jan 29 '18 at 22:40

1 Answers1

2

You could use dangerouslysetinnerhtml

mu_sa
  • 2,685
  • 10
  • 39
  • 58