9 points · by samwillis · 4y ago · 7 comments
Also, when building with un-curated package managers such as NPM and PyPi, it’s virtually impossible to audit all dependencies. We now regularly hear news of packages being replaced with backdoored versions makes me very nervous. These could make outbound connections to exfiltrate data with not outside input.
I would love it if PAASs (with I prefer) such as Heroku and Fly.io had configurable outbound firewalls. Being able to whitelist what outbound connections were aloud would help enormously, even though it would not solve all potential exploits.
Does anyone know of one (I can’t find one)? Why do PAAS (and to some extent IAAS) not have this functionality built in?
(Obviously with your own infrastructure this is possible with normal firewalls)
It watches your system for new executables that connect to the internet, and notifies you whenever it detects the first connection from one, or when the hash changes for one it has seen before. It can also automatically check the hashes with VirusTotal. And unlike any of the other existing tools (that I know of), it can also properly detect connections from executables inside containers, although the reported exe path may be useless due to namespaces, it will still give you the correct hash.
However, where it is lacking when compared to Little Snitch is that it does not block anything, since I wanted to focus on doing performance and reliability really well, and my time is finite. Although I am open to making it easier to use in conjunction with something like fail2ban or your own custom scripts, modularity is a good thing.
I just recently got this program into a state where I feel it is ready to share, so I'd really appreciate any feedback, and am happy to discuss it further.
Mail server example:
iptables -I OUTPUT -o eth0 -m owner --uid-owner postfix -p tcp --syn --dport 25 -j ACCEPT
To answer your question, here is a desktop firewall for Linux that operates like Little Snitch [1] This is not meant to be used in your server deployments.Could you explain why? Any experience/benchmark to share?
By the way, [1] has a GUI, but you can install only the daemon on the servers.
Limiting to what IPs/domains/ports an application connects to might be useful. But blocking unknown binaries is where this apps really shine (reverse shells, miners...), not because they stop them, but because they'll tell you what app tried to establish a connection, where it is on the disk, etc.
I am not aware of anyone anywhere doing this in production, load testing this application in a way that matches production server traffic or ever having used this outside of a desktop. That is the point really. You would be one of the first to tickle any bugs. If you can find a community of people doing this that could help when you run into problems, then you might not be the first to do this. I am never against bending applications to do something they were not intended, it's in my name.. but I am also very familiar with sitting in front of a room full of executives that want an explanation for why the outage occurred and how to keep it from occurring again.
By the way, [1] has a GUI, but you can install only the daemon on the servers.
Correct it was not intended for servers.
Limiting to what IPs/domains/ports an application connects to might be useful. But blocking unknown binaries is where this apps really shine (reverse shells, miners...), not because they stop them, but because they'll tell you what app tried to establish a connection, where it is on the disk, etc.
This is less of a problem on servers. You would not deploy applications that have not been QA tested, benchmarked, code security reviewed and approved for deployment. If that is happening outside of your control that is an issue that needs to be brought up with the leadership of your development teams. Encourage them to use distroless containers and strip out applications that have not been approved. Your web daemons need to only have access to applications they are approved to use. You can enforce mandatory access controls in AppArmor/SELinux though I acknowledge people get overwhelmed by this and just disable it or use the default targeted rules that come with the OS which is barely useful at all.
I summary, if you want to be one of the first organizations to use this in a production datacenter setting that is great but you will be the first to experience all the "it wasn't supposed to do that" moments. If you do this, please document all the issues that you run into so that others can learn from your experience and go easy on the developers of this code as it was not intended to be used this way.
If you use an outbound http/socks proxy, it's a bit more tenable. You can set rules based on hostnames, but you're also on the hook for running a production proxy cluster. Hopefully you don't need outbound UDP.
It should be possible to build this sort of firewall based on hostnames not IP addresses? Maybe with a custom DNS server? And to be honest I would take the configuration complexity if it made my apps more secure.
There will be apps that talk to more, and as you said use UDP etc. but these will be the minority.
a common attack i see for exfil behind FW is to sign up for a free account on heroku, fastly, cloudflare, etc so that your outbound destination is to a "good" IP. you can resolve api.legitimatecompany.example and then send the actual request to that IP (which is a CDN), with an encrypted Host: header of your own endpoint, for example.