Prevent all outgoing requests from NodeJS server?

纵然是瞬间 提交于 2021-02-08 10:59:36

问题


Is there any existing technique or npm package that can prevent all outgoing requests from a NodeJS server, allowing only responses to incoming requests? This could prevent phone-home type attacks in deep dependencies missed in security audits.


回答1:


A firewall.

That's truly the only way. Remember though that there is nothing stopping some code from accepting commands from clients connecting to it.




回答2:


Have a look at

  • http://www.cyberciti.biz/tips/block-outgoing-network-access-for-a-single-user-from-my-server-using-iptables.html
  • https://superuser.com/questions/95963/lightweight-solution-to-block-outbound-connections-from-a-specific-app

The first link shows a firewall rule bound to a particular user. Easy and simple. Why use another npm module with deep dependencies you don't want to trust ;-)




回答3:


If you're looking for pure node.js solution, you can do something like that.

Using some module like mockery you can limit what calls your javascript module can do to node.js core. For example, if you override require('net').connect, it'll make harder for malicious code to execute something.

I don't know of any existing solutions, but it's definitely possible, and I'd really like to see one.


That said, the generic approaches to this problem are completely outside of node.js scope:

  1. firewall
  2. apparmor


来源:https://stackoverflow.com/questions/22026824/prevent-all-outgoing-requests-from-nodejs-server

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