Ios 使用io.sockets.emit的套接字io
我对Socket io的世界还不熟悉,我想知道他们的安全问题是否与此有关: 我也在用咖啡脚本 服务器Ios 使用io.sockets.emit的套接字io,ios,node.js,sockets,coffeescript,Ios,Node.js,Sockets,Coffeescript,我对Socket io的世界还不熟悉,我想知道他们的安全问题是否与此有关: 我也在用咖啡脚本 服务器 io.sockets.emit('UserInfo', {player1: AllData1, player2: AllData2}) AllData1基本上是player1的敏感信息,AllData2是player2的敏感信息 客户 myName = 'snugglePuff' socket.on('UserInfo', (data) -> if data.pl
io.sockets.emit('UserInfo', {player1: AllData1, player2: AllData2})
AllData1基本上是player1的敏感信息,AllData2是player2的敏感信息
客户
myName = 'snugglePuff'
socket.on('UserInfo', (data) ->
if data.player1.name = myName
alert(data.player1.secret)
)
因此,我的问题是:当服务器向连接的每个套接字广播时,“player2”是否会以某种方式使用浏览器查看数据。player1.secret?是的,这是一个巨大的安全问题 每个客户都能看到您广播的任何内容。对于用户来说,在他们的页面版本上编辑脚本并从广播中获取像这样的额外数据是很简单的
如果您必须发送敏感信息,请确保只发送给其所有者。或者,不要发送任何敏感信息,并研究如何将所有敏感信息保存在服务器端(例如,使用安全随机生成的ID识别每个用户的会话)。是的,这是一个巨大的安全问题 每个客户都能看到您广播的任何内容。对于用户来说,在他们的页面版本上编辑脚本并从广播中获取像这样的额外数据是很简单的 如果您必须发送敏感信息,请确保只发送给其所有者。或者,不要发送任何敏感信息,并研究将所有敏感信息保存在服务器端的方法(例如,使用安全随机生成的ID识别每个用户的会话)。 因此,在您的代码中,player2可以看到player1.secret
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
socket.broadcast.to('game').emit('message', 'nice game');
// sending to all clients in 'game' room(channel), include sender
io.in('game').emit('message', 'cool game');
// sending to sender client, only if they are in 'game' room(channel)
socket.to('game').emit('message', 'enjoy the game');
// sending to all clients in namespace 'myNamespace', include sender
io.of('myNamespace').emit('message', 'gg');
// sending to individual socketid
socket.broadcast.to(socketid).emit('message', 'for your eyes only');
,
因此,在您的代码中,player2可以看到player1.secret
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
socket.broadcast.to('game').emit('message', 'nice game');
// sending to all clients in 'game' room(channel), include sender
io.in('game').emit('message', 'cool game');
// sending to sender client, only if they are in 'game' room(channel)
socket.to('game').emit('message', 'enjoy the game');
// sending to all clients in namespace 'myNamespace', include sender
io.of('myNamespace').emit('message', 'gg');
// sending to individual socketid
socket.broadcast.to(socketid).emit('message', 'for your eyes only');
嗯,我想一旦客户端js文件加载,用户就不能用它做很多事情了。他们必须刷新页面,这只会给他们相同的“myName=snugglePuff”变量,不是吗?player2如何在浏览器上访问或查看“data.player1.secret”?当警报仅在与玩家1的名字“snugglePuff”匹配时才会出现?在浏览器中,如果你检查页面,你可以添加一个脚本。用户可以很容易地去掉if语句或修改它以适应它们,然后就可以等待广播。web安全的一个好的经验法则是假设客户端可以绕过客户端安全检查。即使它在外部js文件中?是的,即使它是外部的。尝试检查您的页面(打开开发人员工具)并查看“源”选项卡,它将显示页面使用的所有外部脚本的列表。你会发现你可以在脚本中添加内容。实际上,即使不在脚本中添加任何内容,用户也可以在接收到广播时设置一个断点,然后在空闲时查看数据(例如,Chrome具有此功能)。关键是,有很多方法可以截获数据,所以首先不要广播它。嗯,我认为一旦客户端js文件加载,用户将无法处理它。他们必须刷新页面,这只会给他们相同的“myName=snugglePuff”变量,不是吗?player2如何在浏览器上访问或查看“data.player1.secret”?当警报仅在与玩家1的名字“snugglePuff”匹配时才会出现?在浏览器中,如果你检查页面,你可以添加一个脚本。用户可以很容易地去掉if语句或修改它以适应它们,然后就可以等待广播。web安全的一个好的经验法则是假设客户端可以绕过客户端安全检查。即使它在外部js文件中?是的,即使它是外部的。尝试检查您的页面(打开开发人员工具)并查看“源”选项卡,它将显示页面使用的所有外部脚本的列表。你会发现你可以在脚本中添加内容。实际上,即使不在脚本中添加任何内容,用户也可以在接收到广播时设置一个断点,然后在空闲时查看数据(例如,Chrome具有此功能)。关键是,有很多方法可以截获数据,所以首先不要广播它。