What is the general concept behind XSS?

As the answers on how XSS can be malicious are already given, I’ll only answer the following question left unanswered: how can i prevent XSS from happening on my websites ? As to preventing from XSS, you need to HTML-escape any user-controlled input when they’re about to be redisplayed on the page. This includes request … Read more

What does it mean when they say React is XSS protected?

ReactJS is quite safe by design since String variables in views are escaped automatically With JSX you pass a function as the event handler, rather than a string that can contain malicious code so a typical attack like this will not work const username = “<img onerror=”alert(\”Hacked!\”)” src=”https://stackoverflow.com/questions/33644499/invalid-image” />”; class UserProfilePage extends React.Component { render() … Read more

How do you use window.postMessage across domains?

Here is an example that works on Chrome 5.0.375.125. The page B (iframe content): <html> <head></head> <body> <script> top.postMessage(‘hello’, ‘A’); </script> </body> </html> Note the use of top.postMessage or parent.postMessage not window.postMessage here The page A: <html> <head></head> <body> <iframe src=”B”></iframe> <script> window.addEventListener( “message”, function (e) { if(e.origin !== ‘B’){ return; } alert(e.data); }, false); … Read more