Suppose I'm using the postMessage() API to communicate between frames on different domains. The standard security check in the receiving frame is to verify the origin property of the message event like:
if ( messageEvent.origin !== "http://www.mydomain.com" ) {
console.log( "Message received from unexpected domain!" );
return;
}
But what if someone used the debugger/inspector in their browser to set the source for the sending frame to a malicious URL that included Javascript to send messages that requested sensitive data or did other bad things. Then couldn't they edit the code above in the browser's inspector and change the origin being checked to the malicious URL? Now, they initiate a message event in the sending frame that has the malicious code and the receiving frame happily accepts the malicious message . . .
Why is this not a huge security hole for postMessage?