sandia-minimega / minimega

minimega
GNU General Public License v3.0
148 stars 66 forks source link

Feature Request: Change default behavior of dnsmasq to prevent dns leakage #1421

Closed mkunz7 closed 2 years ago

mkunz7 commented 4 years ago

Describe your environment

  1. minimega version latest
  2. Linux distro/version Ubuntu 18.04 Server
  3. Go compiler version 1.12
  4. VM types Any

Describe the bug The default configuration for dnsmasq is insecure and will bleed dns. I brought this up before and was told it works as intended and is not an issue.

To Reproduce Start Minimega

vm config net 1000
vm config cdrom /root/tinycore.iso
vm config memory 256
vm launch kvm tiny
vm start tiny
tap create 1000 ip 1.0.0.1/24
dnsmasq start 1.0.0.1 1.0.0.2 1.0.0.254

This should launch a VM on mega_bridge vlan 1000 and assign an ip address in 1.0.0.0/24 from the dnsmasq service running on a tap in vlan 1000.

Now hop on the VM, open a terminal and ping google.com you'll see an ip address resolve, but the ping fails.

This is a problem. The only way it could know an ip address is if it somehow reached out to the internet and got a response back. This virtual network may seem isolated from the internet, but is clearly not.

Yes it is very bad practice to add this tap and not understand what it is doing. The better solution is to make sure to start dns using a vm or container in the experiment. But far too many people incorrectly assume dnsmasq is running in an isolated network because when they try and access the internet they see the internet fails.

Run tcpdump on the server and you'll see the domain traffic going outbound.

tcpdump -i eth0 port 53 -vv

Take a look at ps aux and you'll see dnsmasq is running with the -o option.

root@ubuntu:~# ps aux  |grep dnsmasq
root       9663  0.0  0.0  59980  3992 pts/2    S+   14:51   0:00 /usr/sbin/dnsmasq -u root --pid-file=/tmp/minimega/dnsmasq_645651131/dnsmasq.pid -o -k --hostsdir=/tmp/minimega/dnsmasq_645651131/hostdir --dhcp-hostsdir=/tmp/minimega/dnsmasq_645651131/dhcpdir --dhcp-optsdir=/tmp/minimega/dnsmasq_645651131/dhcpoptsdir --except-interface lo --listen-address 1.0.0.1 --bind-interfaces --dhcp-range 1.0.0.2,1.0.0.254 --dhcp-leasefile=/tmp/minimega/dnsmasq_645651131/dnsmasq.leases --dhcp-lease-max=4294967295

From the man page

-o, --strict-order
By default, dnsmasq will send queries to any of the upstream servers it knows about and tries to favour servers that are known to be up. Setting this flag forces dnsmasq to try each query with each server strictly in the order they appear in /etc/resolv.conf

The default configuration of dnsmasq will resolve domains. This needs to be changed.

Expected behavior We shouldn't use -o and -R should be enabled by default in dnsmasq.go. We should make a dnsmasq configure command to enable upstream resolving for when someone wants to use iptables forwarding.