On 05/28/14 23:40, Joonas Lehtonen wrote:
> [ This email was previously send to security@q-o.o on 2014-05-26,
> but joanna agreed that it is not needed to keep the discussion
> behind closed doors. According to the developers, the suggested fix
> is unlikely to be implemented in R2 because it would slowdown dispvm
> startups (sad to see performance win over security - especially in
> this project's context), but "In R3 this is trivial change". Other
> parts (network reachability in offlineVMs) turned out to be actually
> features *sigh* (Marek might resent his email describing the
> use-case?) ]
>
> The actual purpose of this email is to raise awareness and to allow
> people to help themselves (see workarounds).
>
Here forwarding my original reply (from
secu...@qubes-os.org):
On 05/27/14 00:57, Joonas Lehtonen wrote:
> Bypassing Network Restrictions using Disposable VMs
>
>
> Network Connectivity in offlineVMs
>
>
> Network Isolation Expectations about offlineVMs
>
> offlineVMs (aka VMs with netvm set to none), can not communicate or
> attack any other VM on the network layer or exfiltrate secrets to
> the outside world even if the attacker can run arbitrary code within
> the offlineVM and has 0days for TCP/IP stacks.
That's not really true:
http://wiki.qubes-os.org/trac/wiki/DataLeaks
> Malware executed in an offlineVM should not be able to spread
> anywhere via the network layer
Correct.
> and it should not be able to determine where it is running (external
> public IP).
>
Mostly correct, except if it were able to cooperate with malware in some
other AppVM, establish a covert channel, and then somehow together
figure out where are they executing.
> There are two "bugs" that allow an attacker that is able to run
> arbitrary code in an offlineVM to
>
> (1) connect/attack to the default netVM (firewallvm) and (2) in a
> non-default configuration to connect to the internet.
>
> steps to reproduce (1) --------------------------- qvm-create -l
> green offlinevm qvm-prefs -s offlinevm netvm none an attacker can
> launch it's 0days against firewallvm via qvm-run user@offlinevm:
> qvm-run --dispvm <attacks against qubes-gateway>
>
> to be honest the attack surface is rather small but bigger than
> expected
>
> risk: low
>
> steps to reproduce (2) --------------------------- lets temporarily
> give the offlineVM network connectivity except 1.2.3.4 qvm-prefs -s
> offlinevm netvm firewallvm
>
> create a new rule "Allow network access except..." 1.2.3.4
>
> after we are done lets remove network connectivity again (without
> removing the previously created rule) qvm-prefs -s offlinevm netvm
> none **
>
> We do not assume that offlinevm has any network connectivity because
> it has no netvm assigned to it - regardless of any rules in the
> firewall tab.
>
> user@offlinevm $ ping
google.com connect: Network is unreachable //as
> expected
>
> user@offlinevm $ qvm-run --dispvm ping -c 1
google.com ping shows
> network reachability //not expected
>
> **) while writing these steps here I noticed that it is actually
> only reproducible if you perform this step (assignment of the netvm
> to 'none' via the qubes-manager GUI - not the CLI)
>
> risk: medium
>
> --------------
>
> Deanonymizing torvm user
>
>
> Network Isolation and Proxy Obedience Expectations about AppVMs
> running behind torvms
>
> " Our Tor proxy would forward only the Tor traffic, so we don't have
> to fear about some Tor-not-aware applications, or even intentionally
> malicious ones to compromise the privacy of our connection. This is
> because such applications have no way to generate traffic to the
> outside world without going through our Tor proxy (unless they could
> exploit a hypothetical vulnerability in the Tor process running in
> the Tor VM). Also, the applications running in any VM behind the Tor
> proxy are not able to determine any globally identifiable IDs, such
> as the user's external IP address, the real MAC address used by real
> NICs "
>
>
>
http://theinvisiblethings.blogspot.de/2011/09/playing-with-qubes
networking-for-fun.html
>
> From the documentation:
http://qubes-os.org/trac/wiki/UserDoc/TorVM
>
> " (Optional) Modify Qubes policies to prevent accidental clearnet
> leaks from the new AnonVM
>
> /etc/qubes-rpc/policy/qubes.OpenInVM
>
> anon-web $dispvm deny $anyvm $dispvm allow $anyvm $anyvm
> ask
>
> /etc/qubes-rpc/policy/qubes.VMShell
>
> anon-web $dispvm deny "
>
> This should not be "Optional" but mandatory if anonVMs are aiming to
> be (traffic) safe against malicious or vulnerable applications.
>
>
> Workaround (applies to all issues in this email):
> ------------------------------------------------- option #1: remove
> the following line from the policy files $anyvm $dispvm allow
>
> option #2: change the dispvm's default netvm to none
>
> Suggested fix (applies to all issues in this email):
> ----------------------------------------------------- disposable VMs
> should inherit by default the netVM from the AppVM which created it
> (while still being configurable), that would prevent most
> firewall-bypass-via-dvm attacks If the appVM had no netvm the spawned
> dvm shouldn't have one either.
>
> regards, Joonas PS: Please do not mention me in any credits or the
> such.
>
So, there are 3 (somehow) separate problems here:
1) Preventing a compromised, network-isolated VM from being able to
cause damage to the rest of the system (e.g. compromise other VMs).
2) Preventing a compromised VM from being able to communicate with the
outside world or other (compromised) VMs bypassing Qubes policy which
attempts to prevent it (e.g. firewall settings, or netvm-not-having).
3) Preventing a compromised TOR-ified VM (or VPNed in general) from
being able to send out traffic bypassing the TOR-yfing proxy (somehow a
special case of #2 above, although the attack you described doesn't
require having a cooperating VM).
#2 above is generally not addressable on modern multi-core x86 systems
because there always exist a possibility to build covert channels
between _cooperating_ VMs using timings of CPU caches, branch
prediction, etc. We also believe there are many more straightforward
ways to build such cooperative channels between VMs running under a
hypervisor such as Xen, which has not been designed to stop such
communication. Perhaps Xen could be easily patched to eliminate the most
obvious cases (see ticket #817). Perhaps this would be "good enough" as
the timing-based covert channels are generally considered unreliable and
of very narrow bandwidth, especially in a busy desktop system with many
VMs. Nevertheless, from what I understand, they are not possible to
eliminate completely, unless we took drastic measures, such as... allow
execution of only one VM as a time. The user can do that even currently,
of course, but at the price of sacrificing convenience drastically.
#1 and #3 above are of course of much bigger concern. Fortunately these
attacks can be trivially prevented by having the user set a proper
policy, as you outlined above (e.g. set to "deny")[*].
Should we change the default policy for talking to $dispvms to "ask" or
"deny"? I don't think so, because this would hamper usability for all
other cases where dispvms are involved, but which don't fall into the
scenarios of #1 (because the originating VM already has netvm) or #3
(because the originating VM is not to be anonymized).
The solution you proposed with inheriting the netvm setting from the
originating VM is better from the usability point of view, however it
would complicate (make it slower) the startup procedure of the DispVM, I
think. I'm not sure if we would like to introduce such change at this
moment. Especially that, as I understand, in the special cases where #1
and #3 apply, the user can trivially achieve the same level of
protection by editing the policy file, correct? Marek, what do you think?
BTW, I've always thought about network-disconnected VMs as ultimately
trusted ones (last bastion, not reachable even to TCP/IP stack
exploits), rather than ultimately untrusted. In that case #1 and #2
above don't present a real threat, I think.
But I also see that for all the people who use TOR on Qubes, the ticket
#817 is becoming somehow important, as it allows to build a bridge
around TOR.
Whatever we decide to do (leave it up to the user to setup "ask/deny" in
the policy files vs. introduce netvm inheritance), I think we might want
to release a QSB describing all the problems discussed here (as well as
the issue with wrong FORWARD policy discussed a few days ago), at the
very least to attract user's attention to those problems. Especially the
TOR users.
Thanks,
joanna.
[*] Although please note that #3 might still be possible if we assume
there is another compromised VM in the system and the anon VM is
establishing a covert channel with this other one. In this case (i.e.
paired with other compromised appvm) #3 is becoming a special case of #2.