根据10.4 跨文档消息传递:domainA.com 可以使用跨文档消息传递向 domainB.com 发送消息,以防止在验证来源和数据时进行跨站点脚本攻击。
问题:考虑 domainA.com 被攻破,攻击者注入了一个有效载荷来跟踪 domainA.com 和 domainB.com 之间的消息,这可能吗?
为了更好地理解:它可以通过更改原始 Web Socket 对象来嗅探 Web Socket 流量,工作示例解释在这里,我提取了这部分:
if (captureWebsocket && window.WebSocket) {
// add logging onmessage listener
function captureRecv(ws) {
if (typeof ws.captured == 'undefined') {
ws.addEventListener('message', function(e) {
var event = {
event: 'websocket_recv',
from: location,
data: e.data,
url: e.target.URL
}
log(event);
});
ws.captured = true;
}
}
// capture sending
var captureSend = this.contentWindow.WebSocket.prototype.send = function() {
captureRecv(this); // in case socket contruction was before constructor switching
var event = {
event: 'websocket_send',
from: location,
data: arguments[0],
url: this.URL
};
log(event);
return window.WebSocket.prototype.send.apply(this, arguments);
}
// capture constructor
this.contentWindow.WebSocket = function(a,b) {
var base;
base = (typeof b !== "undefined") ? new WebSocket(a,b) : new WebSocket(a);
captureRecv(base);
base.send = captureSend;
this.__proto__ = WebSocket.constructor;
return base;
}
}
});