Open ghost opened 6 years ago
But when using the same "tcpdump trick" as above inside this firejail guest, we see that it tries to use, same as the host, 127.0.1.1 as DNS server.
We reuse the host DNS configuration inside the sandbox. In your case it was 127.0.1.1 on the host, but inside the sandbox nobody is listening on 127.0.1,1, so you need to send it somewhere else using --dns=... command.
why wouldn't it issue a plain regular DHCP request instead of trying to "guess" things?
Running a DHCP client inside the sandbox has some security implications. The DHCP server has to much control over your sandbox: it can decide to change you IP address, your DNS settings, and so on.
Thanks for your response.
The security implications running a DHCP are perfectly clear!
I was just wondering, since setting DNS inside the sandbox to 127.0.1.1 is obviously useless, whether the DNS "guess" couldn't be better. In my setting, since there is a listener on the network (vnet0) we put the sandbox on, this ip address (172.16.0.1) belonging to the network could be elected as better suited than 127.0.1.1 that leads nowhere.
I agree though, that since 127.0.1.1 gives the user a DNS that does not work, it will make him think of what proper DNS it can offer according to the security he has in mind.
I still think that it could be best documented (for example in the --dns option) so that the user does not search for hours what he did wrong and knows immediately he must provide a working dns.
So, suggestions, based on your response:
Thanks.
I changed the first post accordingly to: Documentation Enhancement Request.
(Instead of: Enhancement Request)
Yes, we have to document it!
@netblue30 Have we documented this now?
[Documentation Enhancement Request]
Using firejail in the context of TorMiddlebox, I ran into this issue.
Pointers : https://github.com/Bylon/TOR_Middlebox/wiki/Firefox---Middlebox-tricks Bylon/TOR_Middlebox#4
From my investigations, contrary to a VM that does a regular DHCP and gets all the correct network settings, firejail tries to "guess" things and the result is not working.
To summarize the TorMiddlebox settings, we have a bridged interface, vnet0 declared as such
In the Ubuntu setting, we have NetworkManager that uses dnsmasq-base which gets the additional parameters as such:
dnsmasq is then listening to the above interface (vnet0) in addition to the loopback address, as we see here:
All is well, dnsmasq serves both DNS requests (53) and DCHP requests (67)
In fact, there is an "upstream" DNS obviously, which in my configuration is given by my ISP's box, as we see with nmcli.
This is where dnsmasq gets the DNS resolution and caches it.
If we use the "tcpdump trick" described in this post: https://askubuntu.com/questions/637893/how-to-know-what-dns-am-i-using-in-ubuntu-from-14-04-onwards/637894#637894
from our host, we see that DNS are served by 127.0.1.1,which is where dnsmasq caches DNS requests for our host, and then if you analyse traffic on the ethernet outgoing connection to the ISP you see the actual DNS requests.
For our middlebox, we obviously have iptables rules both for DHCP and DNS. Here is out it looks like:
We redirect UDP-53 from vnet0 to port 60, that is where Tor is listening to resolve DNS requests.
So, now lets look at how VirtualBox does things when we start a VM attached to our vnet0 interface.
Once the guest starts, it issues a DHCP Discover (broadcast). Since we have dnsmasq listening for DHCP on vnet0, we get a DHCP Offer with the right parameters: the offer is made by 172.16.0.1 (where dnsmasq listens) that also sets itself as the gateway and the DNS server (plus the usual IPV4 address, lease renewal, rebiding, etc...)
Then, when the VM guests wants to resolve a host name, it issues a DNS request on 172.16.0.1, which will go through tor in our configuration (but could also be served by our ISP's box in a "regular" setting).
Now let's look at what firejail does when attached to the same vnet0 bridged interface. Start wireshark filtering UDP on that interface, then:
firejail --net=vnet0 --noprofile
As you can see, unlike VirtualBox, there is no DHCP request at all showing on wireshark. Doing an ifconfig inside this new shell shows that it managed to get an IPV4 address:
But when using the same "tcpdump trick" as above inside this firejail guest, we see that it tries to use, same as the host, 127.0.1.1 as DNS server.
This obviously is a nonsense since we are in a network sandbox, nobody is responding to UDP-53 on 127.0.1.1 inside the sandbox, hence DNS fail from the sandbox.
Workaround: As described in the ticket on TorMiddlebox in introduction, the workaround is easy. Since firejail makes a "guess" that does not work on what is the real DNS server, we just need to add a parameter to force the right value, which is then:
firejail --net=vnet0 --dns=172.16.0.1
Enhancement: Not sure whether that would be possible (I have not investigated) but since firejail creates a new network environment (when instructed to), why wouldn't it issue a plain regular DHCP request instead of trying to "guess" things? Or maybe add an option that instructs to issue a DHCP instead of the current way of setting the network configuration?
Note: I have also tried with the last firejail version from this github, instead of the LTS we have in 16.04, it does not change anything about this enhancement request.