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

Symbol Tagging for dangerouslySetInnerHTML to Help Prevent XSS #10506

sebmarkbage opened this Issue Aug 22, 2017 · 0 comments


None yet
2 participants

sebmarkbage commented Aug 22, 2017

If you're spreading props from a user provided source we have a XSS. E.g.

var data = JSON.parse(decodeURI(;

function Foo(props) {
  return <div><div {...props} /><span>{props.content}</span></div>;

ReactDOM.render(<Foo {} />, container);

That's already true today because this URL is now an XSS hole:


This is very uncommon. There are many different ways to screw up getting user data. However doing that + also spreading is unusual. We decided in #3473 that React should add an extra layer of protection for these types of mistakes. This one is much more uncommon than the one in #3473 though.

You should already have a pretty centralized way of sanitizing these objects so it seems to me that adding a Symbol to this object shouldn't be that big of a deal though.


{ $$typeof:Symbol.for('react.rawhtml'), __html: myHTML }


{ [Symbol.for('react.rawhtml')]: myHTML }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment