How do you avoid receiving postMessages from attackers?

Posted by Andre Scott | Updated on

Since the listener listens for any message, an attacker can trick the application by sending a message from the attacker’s origin, which gives an impression that the receiver received the message from the actual sender’s window.

You can avoid this issue by validating the origin of the message on the receiver’s end using the “message.origin” attribute. For examples, let’s check the sender’s origin http://www.some-sender.com on receiver side www.some-receiver.com,


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers