Enhancing Security in a now.js/socket.io chat

拟墨画扇 提交于 2019-12-04 12:32:53

问题


A chat with nowjs or socket.io is one of the easiest exercises you can perform with them. I want to implement a multi-room chat (with a non-fixed number of rooms and logged users), using nowjs' Group objects.

I've not worked with WebSockets directly, yet, and I want to know what security concerns are there. For example, how often do I have to check for authentication?

Is it possible for an attacker to "hijack" a socket.io connection and how can I prevent it?

What other security traps are there to be concerned?


回答1:


Man-in-the-middle is certainly a consideration. The biggest security issue, though, would be XSS.

This useful SO thread suggests:

  1. socket.io 0.8 has referrer verification built in
  2. if chat is from known origin, block superfluous connections at the firewall

This very informative article suggests:

  1. don't trust the client
  2. use SSL encryption
  3. check the origin
  4. prevent XSS (sanitize client input!)
  5. don't assume it's a browser

This useful thread says to set secure:true on socket.io.connect(...)

I'd recommend taking all those suggestions :)



来源:https://stackoverflow.com/questions/8618448/enhancing-security-in-a-now-js-socket-io-chat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!