Whonix Wiki Download Docs News Support Tips Issues Contribute DONATE

Whonix KVM dnsmasq - listen port on host operating system - attack surface reduction

dnsmasq on the host operating system is increasing the attack surface.

How did I find that out?

  1. Install Debian.

  2. Check open ports and write them to a file.

    sudo netstat -tulpen > old

  3. Install packages required for Whonix KVM according to Whonix KVM documentation.

  4. Check open ports again and write them to a different file.

    sudo netstat -tulpen > new

  5. Use any (graphical) diff viewer of your choice.

    meld old new

  6. Result:

dnsmasq opens a listen port on the host operating system that is reachable from LAN and from the Internet (if not using a NAT router or host operating system firewall)

tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 0 19969 1975/dnsmasq

tcp6 0 0 :::53 :::* LISTEN 0 19971 1975/dnsmasq

Whonix KVM TODO: Include instructions how to configure dnsmasq to listen on localhost only (if no way to get rid of it completely).


NOTE: I am not a maintainer of Whonix KVM.

Forum moderation:

Linking to footnotes is confusing because the numbering and therefore links to footnotes will change over time when new footnotes are added.

It gets more confusing due to oneboxing. → Kicksecure ™ Forums Usage Instructions, Best Practices and FAQ chapter Avoid Oneboxing for Anchored Links in Kicksecure wiki


Content:

Copying that footnote here for further discussion.

So I can see an open TCP port. However it responds as if it’s “tcpwrapped”. That implies if you connect over a different interface from virbr0 , dnsmasq closes the connection without reading any data. So data you send to it doesn’t matter; it can’t e.g. exploit a classic buffer overflow.

I think it’s needed. More on tcpwrapped:

Specifically, it means that a full TCP handshake was completed, but the remote host closed the connection without receiving any data.

So two things here:

  • We still don’t want a TCP handshake to be completed because unsolicited incoming connections have a higher attack surface than not allowing unsolicited incoming connections.
  • Even the information “port 53 tcpwrapped” should not be leaked over the LAN or internet. Could even be deducted “Maybe it’s a Whonix KVM user”.

related:
A writeup on “unsolicited incoming connections” → Ports - Whonix.

I don’t know which one would be applicable here, but here’s a long list of dnsmasq CVEs to review:

Potential solution, untested:

1 Like

Note this is not specific to Whonix and could be interpreted as Linux host running libvirt, This is already discoverable and hard to hide the type of OS running on a network because of the different ways they react.

Binding to localhost would break it because the whole point is to have it listening on whatever arbitrary internal LAN IP ranges libvirt binds it to on the fly. OP can go ahead and try to uninstall it and deal with the fallout, but as a default option this is unworkable.

Does ufwall change nmap results? or is it using raw ports?

1 Like

Try?
Probably I think.

Maybe Whonix ™ for KVM should advice to setup a host firewall beforehand.

I doubt that. Raw ports is mostly only a DHCP thing. But this is DNS. Not DHCP.

1 Like

I see your point of view but I agree with @Patrick on this one.
Your point heavily assumes “Linux machine running a KVM machine is not that suspicious” is entirely in context of specific countries in specific times.

Some tight dictatorship countries, especially during times of unrest will arrest you incase they suspect even slightest of “above average technical ability” e.g. running Linux host and running virtual machines on it.

Their mindset would be “this person or group is running Linux, people run Linux because they have something to hide! oh and on top of that he is running a virtual machine! what is he scared of so much”

This sounds comical but There are countless arrests or interrogations based solely on this “logic” and I should mention that “arrests” in those countries means torture to death

A more tangible issue for other countries is fingerprinting. They don’t have to be sure that a Whonix VM was started or is installed, they just have to know that a VM is there and it is enough to narrow down the search considerably

Do not undermine value of metadata, a lot of people die every day because of it. We kill people based on metadata

So, optimally the host should not leak information on whether or not they have VMs/dnsmasq or anything out of ordinary

1 Like

I hate to be the bearer of bad news, but our security choices and improvements do have a unique fingerprint on the network for those who want to look. The fact we disable TCP timestamps and remove TCP ISNs is readily apparent. Rather than stick to the less secure defaults that can endanger users in other ways, we have chosen to move ahead and adopt these improvements.
.
If having a firewall solves this - which I think Patrick said, then the solution is easy enough to apply and I hope satisfactory

2 Likes

That is in the VMs and not the host (dnsmasq fingerprinting) correct?

The TCP timestamps being disabled is only inside of the VM, however the dnsmasq is on the host so it should still be considered. Just because Whonix has some obvious fingerprint able properties in exchange for security, does not mean you should allow more fingerprints, especially ones that are unnecessary like in this case of dnsmasq exposing it’s self on the host.


This is interesting because AFAIK Whonix disables these in linux-harden kernel which I thought is in use only in Workstation and not Gateway and I assumed that means no fingerprint (at least outside of tor) or does Gateway and workstation both use same kernel with same options? if so that could be an improvement to disable some hardening kernel features in Gateway, no?

Forum moderation:

You’re raising the fingerprinting point here already:

Please do not duplicate the same discussion in multiple forum threads.

Unfortunately I have to raise one point here. We could make a meaningful distinction between:

  • A) ISP level network fingerprint analysis versus leaking “user of dnsmasq or something similar, maybe a Whonix user?” versus,
  • B) Leaking that information to anyone who can use a port scanner over LAN (if using a WiFi hotspot or big LAN or LAN based ISP) or even over WAN (if not using a NAT router and/or compromised NAT router).

We cannot do anything about A) (as per TCP linux-hardened fingerprinting) but B) is avoidable. For that, either

  • 1) dnsmasq would need to be avoided, or
  • 2) Whonix KVM documentation could include instructions on how to setup a host firewall since specifically important due to dnsmasq.

Whonix-Gateway requires neither

  • X) DHCP, nor
  • Y) DNS.

DHCP:
DHCP isn’t needed by Whonix-Gateway because whonix-gw-network-conf/30_non-qubes-whonix at master · Whonix/whonix-gw-network-conf · GitHub is using static networking - no DHCP needed since many Whonix versions.

DNS:
DNS isn’t needed by Whonix-Gateway because Tor does not require DNS.
(Except perhaps for some pluggable transports
Related: Whonix-Gateway System DNS - Whonix

So I don’t understand why Whonix KVM requires dnsmasq.

KVM needs it by default. not really a Whonix thing. We already recommend installing a firewall in the host hardening guide. I’m not sure that requiring users to take extra steps on their hosts is conducive to a good first time user experience nor scaring them away by saying the hypervisor installs unsafe packages (which it isn’t from a security perspective because no one can connect to it) makes any sense. Putting a dozen caveats and warnings on a download page will make people ignore the project and leave.

I saw some instructions for running a Debian host with KVM and a Debian guest inside a KVM VM. And some of these instructions didn’t require dnsmasq.

Maybe dnsmasq is required as per, quote Libvirtd and dnsmasq - Libvirt Wiki

On linux host servers, libvirtd uses dnsmasq to service the virtual networks, such as the default network. A new instance of dnsmasq is started for each virtual network, only accessible to guests in that specific network.

But that doesn’t sound like the host dnsmasq systemd unit is required. Could you test please to disable the host dnsmasq systemd unit? (The package dnsmasq can remain being installed.)

Check if running:

sudo systemctl status dnsmasq

Then stop it.

sudo systemctl stop dnsmasq

Does that break Whonix-Gateway connectivity?
Does that break Whonix-Workstation connectivity?