Douane: Linux personal firewall with per application rule controls
douaneapp.com
douaneapp.com
A fork seems to be relatively alive [2] and I use it personally -- it works well, but is a bit of a PITA to build. Time to buy the devs a coffee...
[1] https://github.com/evilsocket/opensnitch [2] https://github.com/gustavo-iniguez-goya/opensnitch
> You can follow the bug resolution from this issue. Have a look at the Roadmap [1] to see when this issue should be fixed!
> The current version is 0.8.2
This does not seem to be the fastest of projects... The bug was reported 6 years ago.
From the bug report (6 months ago):
> So, could a noob use it already without breaking the computer?
> No, not yet
Here's an example that prevents atom from leaking telemetry.
# add group atomblind
sudo groupadd atomblind
# add your username to atomblind group
sudo usermod -a -G atomblind <username>
# do not allow outbound traffic from group atomblind
sudo iptables -I OUTPUT -m owner --gid-owner atomblind -j DROP
# overwrite atom binary with a hook
# atom_binary is absolute path to your atom binary
echo "#!/bin/bash" > atom_hook
echo "sg atomblind -c 'atom_binary'" >> atom_hook
chmod +x atom_hook
./atom_hookNot everyone is comfortable running random github code as root.
I really hope Linux gets a viable alternative to Little Snitch, such as this Douane, or OpenSnitch.
Dockerizing every GUI app I run is going to be a pain, otherwise.
Here are two workarounds:
Install Little Snitch 4.6 instead of 5: https://www.obdev.at/support/littlesnitch/245913651253917
Hacky method to disable Apple's exceptions: https://tinyapps.org/blog/202010210700_whose_computer_is_it....
Will 4.x be installable on ARM? I imagine the kernel extension needs to match the arch of the kernel, and because ARM macs don't run anything before Big Sur, I imagine only 5.x has ARM builds available?
Any application that doesn't have a specific policy written for it will either inherit the domain that spawned it (in this case, `unconfined_u:unconfined_r:unconfined_t:s0:c0.c1023`) or receive some default domain (e.g., `system_u:system_r:unconfined_service_t` for systemd services, `initrc_t` for init daemons, etc.)
Because of this, most applications will end up inheriting the user's domain, which again is `unconfined_t` by default under the targeted policy.
Lots of common applications have policies so that they transition to their own domain and then execute under customized policy, but it's less common for user applications (and especially user applications that are not system tools) than for daemons so it's not generally safe to assume you're protected by selinux when going about typical user tasks.
However, writing SELinux policy isn't that hard (although it's a bit harder than just `audit2allow` to do it well) and it's a perfectly reasonable project for an afternoon to write a policy for an unconfined application you use, if you're willing to spend some time up front learning about SELinux policy language.
SELinux provides all the tools we need to implement the guarantees, just Linux distros don't currently have a stance on how they want to expose such a policy option.
Honestly I feed my macos box through a web proxy (currently privoxy) and block the crap out of everything.
struct network_activity * activity = NLMSG_DATA(nlh);
<untrusted data from the netlink socket>
append_rule(activity->process_path, (activity->allowed == 1));
...append_rule: // Don't do anything if the process_path length is > PATH_LENGTH if (strlen(process_path) > PATH_LENGTH) return;
But nobody enforces the process_path has a terminating 0 byte, so likely it can be abused for all kinds of attacks on the kernel. Better don't run it anywhere you care about security.
I found this from about 2 minutes code reading, so likely there wasn't any code audit done ever.
Avoid...
i used bpftrace instead of ftrace to get the process metadata, but eventually removed it after frustration building bpftrace.
currently it is a global inbound/outbound firewall with ui prompts.
i’ve recently had success running archlinux packaged bpftrace in a privileged container, so will be adding process metadata back in soon.
There is a lot of expertise floating around in the ~30ish years of netfilter so that is a ton of momentum in terms of the personal expertise of more experienced devs as well as the blogs/tutorials available when you search for “network filtering Linux”.
The default of kubernetes is still huge iptables chains and the only realistic ebpf alternative is mainly driven by a currently unsustainable startup (Cilium). The maturity just isn’t there yet.
Can you link to something with minimal working "mark and block" examples?
This is true, but I was referring more to the underlying architecture of Douane: kernel module + daemon + dialog UI + configurator app. Is a kernel module less scary for mere mortals? Because the downsides of that path are stated in the banner on the main page which says about kernel panic.
> Can you link to something with minimal working "mark and block" examples?
I'm not aware of any myself, but like I said, I was mostly referring to implementation. I also don't quite get the threat/defense model here. It looks like the idea is to replicate something similar to iOS/Androind permissions ("do you allow this app to access the camera?") but for network this seems to be a bit weird. Making such decision for each application would be quite annoying, so you'd like like to have some defaults in this regard, which again is easier solved by two predefined selinux contexts (with/without networking) and some UI for the user to move apps between them.
But then again, if we decide not to ask for confirmation for each app at exactly the first moment it tries to access the network, we have access to a variety of tools to provide access control to the network. For example, we could use separate network namespaces for different processes, some of which wouldn't have access to networking. This has additional benefit of fine-grained control: "allow chrome to only access my.secure.server.com on port 433".
In fact, it goes beyond that: we can have different routing tables per app, we can setup traffic shaping between the apps ("put traffic from qBittorrent into low-priority queue"), we can bridge and mirror the traffic from an app, etc. This is for example what firejail does [1] and it has a UI as well [2]. This doesn't require any kernel modules or even selinux policies and doesn't bug the user 10 times a day.
[1] https://firejail.wordpress.com/documentation-2/basic-usage/#... [2] https://github.com/netblue30/firetools
And if you need to do real-time, specific packet validation, interface state, route change, just go full netlink. Not sure why more in-kernel code might help. There's already so much stuff available. Not often well documented but so much powerful stuff! Recently I wanted better control over bonds, and I discovered teams. How the hell did I not find them when I was looking for ways to control bonds from userland. And when I wanted bonds in network namespaces...
To understand it, though, you need to understand at least a little bit about type enforcement, which is a somewhat steep learning curve to get over.
If you have nftables (replaces iptables, default back-end to firewalld in RHEL 8), you might consult /usr/share/doc/nftables/examples/secmark.nft but again, this requires some background on nftables (or iptables—they're both just front-ends to the kernel netfilter module) and are pretty similar.
However it's also worth noting that most one could also stand to learn a thing or two about netfilter if this is a topic they're interested in. For example, netfilter allows you to filter packets based on the user, group, or pid of the process.
I found this page [2] quite helpful, and especially the packet flow diagram contained within it.
[1]: https://www.linux.com/training-tutorials/using-selinux-and-i...
[2]: https://www.booleanworld.com/depth-guide-iptables-linux-fire...
SELinux itself is not aware of pid/user/group.
I'd like to find a real-world project to play with netfilter directly. Maybe when transitioning to 200GbE... Is it just for 'complex and numerous filtering rules' or are there other 'killer use cases' for using nftables directly?
RHEL 8 uses the nftables back end for firewalld by default.
The main difference that I have noticed is that writing configuration files for nftables is considerably more ergonomic than the iptables files which are essentially just unstructured lists of iptables commands.
Generally things like UFW or firewalld are sufficient for host firewalls, but they fall short for routing applications where it is more appropriate to use nftables (or historically, iptables) directly.
Kubernetes and docker both currently use iptables for their routing and will likely migrate to nftables. If/then those projects migrate to nftables I suspect it would also solve the issue where docker port mappings have the ability to unilaterally punch holes in host firewalls, e.g., UFW, because under nftables, tables are just namespaces for chains (with configurable priority) while on iptables the different tables meant specific things and docker made decisions in a branch off of the PREROUTING chain in the nat table, which was encountered before the FORWARD or INPUT chains on the filter table. In this way nftables makes certain expressions more ergonomic than iptables.
Why? What does JavaScript have to do with a personal firewall?