I have been learning node.js and socket.io lately. My question is how can I protect server against client side attacks?
This is my server code
io.sockets.on('connection', function (socket) {
//users.push(socket);
socket.on('message', function (data) {
socket.on('disconnect', function () { });
socket.on('bcast', function (data) {
socket.emit('news', { 'data': data });
socket.broadcast.emit('news', { 'data': data });
});
socket.on('login', function(data){
socket.emit('login', {'data': [ socket.id, data ] });
});
});
});
For example if a client uses chrome developer tools to do the flowing code
for(var i = 0; i<99999999999; i++)
{
socket.emit('bcast', {data: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'});
}
its going to kill the server.