-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider support for Android VMs #2233
Comments
Did someone try to create an android-x86 VM on qubes? I was planning on doing it myself in the near future. (by the way: the stable Marshmallow release is out now) |
I tried running RemixOS, but without success. There might be a general problem of running Android as a guest in a Xen hypervisor. |
@andrewdavidwong can you reference to those mailing list entries? |
@Jeeppler: This is based on my memory of the mailing lists over the years, so I don't have an exhaustive list. However, here are some examples: |
According to the posts, people want to run Android x86 to do application development. However, it seems the Android emulator uses the CPU virtualization extension. The problem could also be solved by using nested virtualization on Xen. |
Cross-linking new discussion thread: https://groups.google.com/d/topic/qubes-users/frK8xaBh9pI/discussion |
@grote I have not had any issues running RemixOS under Qubes. But it suffers from the same Android-x86 mouse issue mentioned in the thread that Andrew just linked. Qubes is actually a convenient platform for running Android emulators because most of them don't allow static IP addresses. Qubes' mini-DHCP server works just fine. |
@3n7r0p1 which version did you use? Could you send me the link to the download? Please also let me know if you find a solution for the mouse issue. |
I used an older version of RemixOS so I checked again with the latest release and it also installs and boots fine. version: 3.0.206, 64-bit when booting iso, add Confirmed mouse behavior hasn't changed. Not all functionality can be replicated from keyboard. Unusable without mouse fix. IMO, RemixOS is more resource-heavy than Android-x86 (especially graphics). |
👍 yes, please |
I just tried android-x86 in an HVM, and it actually works great (the only change I had to do was increase the RAM -- I'm using 4GB, but it probably will work with less). It doesn't have the same mouse issues as RemixOS (which, as of today, is a discontinued project). I downloaded an Android 4.4.4 iso from https://sourceforge.net/projects/android-x86/ -- but the more I look into it, it appears there are later versions of android-x86 available, including 7.1: http://www.android-x86.org/releases/releasenote-7-1-rc1 |
It would be cool to make an Android template. I'm not quite sure how the partitioning could work so that android-x86 AppVMs could have private images though. |
Update: I tried installing android-x86 7.1 in an HVM, and it doesn't work nearly as well as 4.4.4. I could boot in live mode, but I had the same mouse issues that exist in RemixOS, and when I install to the hard disk and try booting, it never finishes. |
@micahflee How did you get an AndroidVM to work in Qubes? Currently trying to figure out how to use the Android-x86 vm to do the same. |
I push the topic gently upwards, an android HVM in qubes would be great! Unfortunately it's very painful to get Android x86 running, but I'm going to test a bit by myself and share results. |
So hows going with android vm ? My testing results on qubes r4.0-current-testing are that none of android works so far. But i remember it was working on qubes 3.2, cant remember what android did i run but probably it was remixOS, when i was testing this like a year ago or so. It was install-able but did not boot from installation, had to use iso and all the changes were gone. The performance was really choppy and i gave up, that probably was because of SLAT feature missing on previous laptop. PS: was not editing grub entries at all, only tested different VESA modes when available Hint: try to test preinstalled android VM images and just put them in /var/lib/qubes . Personally i couldnt get this method to work, first have to convert given preinstalled images to qcow RAW format |
@micahflee can't seem to make it boot/install (tried Android 4.4.4 and later) |
Hello, |
Hello, Here are my limited success to deal with an Android HVM in Qubes R4: Here are the issues I'm also facing:
|
Someone got it installed: https://groups.google.com/forum/#!topic/qubes-users/JGDqzuf1dS0 |
Thanks for the pointer. By the way, people are talking about problems with networking, but networking works out of the box in my case. |
ptitdoc, what version of android did you try? I think I shot myself in the foot with 7.1.2, as might have a bug with ethernet and dhcp. I did the following 2 changes:
|
A bit of a time passed, and on the sideline I have a config with which the mouse is a mouse, but you have two pointers. If you change the cursor to large, you can get used to it. Network configuration is stil manual and a pain. Once you build android with that you get a CD (The best if you use the android common build environment... it took me days to get a build on 16G with qubes... but can be done). If that is too much, I can provide you the CD somehow (but why would you trust someone to provide you a CD ... but if in that VM, you have nothing to loose, you do not risk too much :-) ). Create a new HVM. Boot a recent linux CD/DVD/thumbdrive (I was using the openly available, but unannounced knoppix 8,2). boot your VM from the linux CD. Create an EXT2 partition to boot (50 or 500 megs? do not remember). install the bootloader from the cd. Shutdown linux. Boot android. Install Android to the free space, creating a new partition "ext4". reboot. Boot linux again. Mount both partitions, copy kernel and inititial ramdisk, into the boot directory. Do NOT use the same name as what the android-x86 install created on the EXT4 partition. google: update grub/menu.lst according to the instructions found, modify directory name. reboot end enjoy if you can without a network. If you need networking, google android-x86 static ip.Use the IP quebes allocated your vm. Or find instructions on how to setup dhcp from the command line - I did not figure that. I have no clue why it does not autodetect. If some succeeds, please post detailed instructions and CD. I posted this without the actual system at hand, so steps are as I remember from top of my head from many weeks ago. Please post if you fail as well, when I'll check here (maybe soon, maybe a few month) if there are failure reports I'll try to post a detailed instructions with the system at hand. |
The behaviour of the mouse in qubes 4 appears to come from: /usr/share/qubes/templates/libvirt/xen.xml Replace the word " tablet " with " mouse ", and mouse will become an emulated mouse in the HVMs. You get two mouse pointers - but if you change the size (I set it to max of 48) of your desktop mouse (Dom0 - system tools - settings manager - Mouse and touchpad - Theme) so the two can be distinguished, it is usable. This allowed me to run a BSD gui environment in a HWM. I'll see how this changes things for Android. |
Not sure if this is still an issue, but there are instructions on how to set up templates which use sway with waydroid for an android vm. This'll probably get easier as qubes moves to wayland, maybe a waydroid session template (https://docs.waydro.id/faq/setting-up-waydroid-only-sessions) after the migration? |
I did, in fact, get waydroid working inside an Ubuntu HVM. This is from my personal notes from a few years ago
But it's buggy as hell and, most importantly, waydroid contributors said that waydroid shouldn't be used for anything sensitive since it's horribly insecure. I've been monitoring this thread specifically because I was hoping to find a way to run an Android VM in Qubes that's actually secure (eg for extremely compartimentalized banking apps locked inside Qubes, not on my everyday personal phone) The devs ITT above pointed me to BlissOS, but I didn't look into using it in Qubes yet |
(as a note, that prop doesn't stop the screen from rotating, it enables "seamless" mode. Apps will still try to rotate if you have a device with an accelerometer, it'll just break them when they do. You can run "wm set-fix-to-user-rotation disabled" to forcibly disable autorotate) The security issues with waydroid are the same ones we deal with in other linux apps. They're ostensibly worse on qubes, as we give the user account passwordless root. That said, I'd say it's no more insecure than running any other code in a qube, as all applications could grab root immediately and effortlessly with sudo, if they wanted to. It'd still be contained by the qube itself. |
My biggest concern in these Android Emualtors is the supply chain and the risk of obtaining inauthentic code that's been maliciously modified. I'm not worried about my banking app taking over the host AndroidVM that was created just for the purpose of running this one "trusted" app. I am worried about downloading a malicious copy of an Android Emulator that has spyware that can see what I'm doing in my banking app or, worse, steal my credentials or preform actions to my banking accounts on my behalf. Most Android ROMs don't even sign their releases (LOS refused to sign their releases with PGP), and their build chains often include fetching unsigned code (anything with pip is a red flag, for example) so they're a target for watering hole attacks. |
Wouldn't we have that issue regardless of what solution we go with? Short of building android locally on our own device (which we CAN do, and waydroid will run the image), there aren't any solutions which require signed images, and nowhere really releases them. Unless you're referring to trusting the Qubes project to verify the android they ship in a template. Android doesn't really run natively, it's already in a simulated environment. The only difference between Waydroid, Anbox, Android-x86, and my phone, is what interface layer everything's being virtualized in, and you'd need to pick one regardless. |
I think that would be the best-case for the UX. I would love for Qubes to ship with an "Android Template" along-side the "Fedora Template" and "Debian Template" and "Whonix Template" As more-and-more identity providers go with Phone-only apps (I'm looking at banking apps and also the EU's eID legislation that is targeting making eID roll-out mandatory in EU Member States in 2026), I think this will be very important for many users -- being able to lock their banking and eID private keys inside their Qubes laptop instead of exposing it to their phones that are secured with shitty passwords (tapped-out in public dozens of times per day) and are easy to physically break & loose.
Do you have a guide to do this, but which focuses on security -- so we can actually verify the cryptographic signature of all the sourcecode (and all dependencies) that's downloaded before building? |
On at least Pixels, eID is in part handled by dedicated code running in the secure element chip. |
If those are specifically your use cases, most secure android apps are reliant on google Safetynet, which we can neither pass nor spoof on pc. Heck, the days of phones spoofing that are long since over.
Unfortunately, no. That's not something I've ever worried about when building android roms (i'm not overly concerned with a hostile party finding out how bad I am at fruit ninja, for instance, That's what I use waydroid for, gaming and entertainment) |
You could use extrepo like that:
|
Waydroid is based on an insecure fork of Android 11 and has most of the security model disabled. It doesn't have app sandboxing intact and doesn't protect the kernel from apps as Android does. It doesn't have SELinux support which is a major part of the Android application sandbox and the overall security model/approach including kernel attack surface reduction. Android depends on SELinux for the basic privacy and security properties to be intact. The main issue is lack of ongoing maintenance and security patches. Only Android 14 gets full security support, but they could at least be shipping the monthly security backports of High/Critical severity vulnerabilities for Android 11 and using AOSP instead of LineageOS. |
I don't think this will matter much for the default use case as AppVM in Qubes OS with only a single app per AppVM and not using multiple apps in the same AppVM.
This one is an issue for sure. |
It means that a compromise in normally heavily sandboxed OS components is often going to be a compromise of the whole OS including the app. You may not care about the OS being secure from the app if the app sandbox is a VM but you should still care about the OS security. Being on Android 11 is bad enough due to years of missing Low/Moderate severity patches and security improvements but not having the monthly backports of High/Critical severity patches delivered in practice is much worse. |
Maybe you're right. I'm not knowledgeable in how android works so I can only guess some things. I have only WhatsApp installed in android. |
If it's opened in another app or handled with OS media handling, sure, that's how it works. WhatsApp likely handles a lot of the media handling with in-process libraries and it's up to them to do it in an isolatedProcess which they probably don't currently do even though it's very easy. None of the OS sandboxing including isolatedProcess is going to work properly without SELinux. SELinux is not an additional layer but rather a huge part of the basic privacy/security model in Android. It's used much differently from how desktop OSes use it. |
Is it? Using the IsolatedProcess API might well be easy, but replacing code that runs in-process with an IPC call is not generally easy. Is there something specific about Android that makes it possible to wrap a general media decoding API this way? If so, would it be better for this to be done by Android automatically, rather than each app writer having to do this manually? |
It's easy because it's all abstracted and uses the same API for communicating as a non-isolatedProcess service which are heavily used by apps already. Developers already have to deal with moving things to run in the background and this doesn't change much about it. The main portion of the app runs in a sandbox too and it's not that much different. |
Just as a note: waydroid uses lineageos-based images, which DO receive security updates, and the waydroid updater does receive weekly update images |
Android 11 support ended after February. Prior to that, Android 11 only received backports of the High/Critical severity vulnerabilities and only the subset deemed to be part of the standard Android security patches. It doesn't include the Low/Moderate severity patches including most privacy fixes, etc. LineageOS only provides a subset of that subset of standard security patches particularly since they make changes incompatible with security features which would be considered security vulnerabilities. Android doesn't have an actively developed LTS branch for 12, 13 and 14 for use as a mobile OS but rather monthly security backports vendors are meant to apply to their forks. They stopped backporting most Moderate and Low severity patches and stopped assigning them a CVE. If you want all the patches, you need the April monthly release of Android 14 QPR2. For a while, they were listing all of the Low and Moderate severity AOSP patches as part of the Pixel bulletins but since they apply to all devices rather than only Pixels that was weird and they stopped listing them there so they aren't publicly listed beyond the commits now. Waydroid loses not just a set of assorted security features like LineageOS but rather most of the userspace security model through having SELinux disabled. That includes not just the app sandbox but sandboxing throughout the OS and kernel attack surface reduction. It's not just most of the app sandbox but how media handling, HALs and everything else gets sandboxed within the OS. In the Android 4 and Android 5 era, it was an additional layer of security but it gradually became the main way low-level privacy and security controls are implemented including doing userspace-based enforcement of access to services based on SELinux. For example, without SELinux, any app can connect to the update_engine service since that kind of low-level IPC is controlled via userspace. LineageOS disables downgrade protection, so that's quite noteworthy. In terms of kernel attack surface reduction, SELinux is how Android restricts access to eBPF to only bpfloader which only netd can use, how it restricts access to io_uring to fastbootd/snapuserd, how it does ioctl command filtering, etc. Additionally, a lot of the kernel options that are enabled by regular distributions including user namespaces, etc. are not allowed by Android and open up major new attack surfaces. Also, the whole issue of building and distributing updates insecurely without proper signing and downgrade protection. |
How useful will Android VMs be in practice? So far, I have seen two uses:
It might be possible to replace the Android emulator for development, though without the integrations that the Android emulator has. However, I am seriously unsure if it will be possible to use Android VMs to run third-party apps, mostly because Qubes OS only supports x86 whereas third-party apps will be compiled for Arm. Yes, Android apps are mostly written in JVM languages, but the NDK exists and real apps do use it. Also, any app that relies on hardware security features (like attestation, StrongBox, or Protected Confirmation) will find them unavailble. |
Houdini and libndk are both extremely performant libraries for arm to x86 translation, so this isn't much of an issue in practice |
I kind of think it would be actually pretty useful given a lot of "fancier" messengers out there are mobile-first nowadays, and quite a bit of general purpose computer stuff has better UX on mobile I think loss of hardware-backed security features is mostly acceptable here, worst case scenario a "QubesDroid" would be as safe as other qubes VM which is reasonably secure (users would just have to update their posture accordingly) It would certainly be a niche thing (a niche thing I like and desire hard enough to be subscribed to this discussion on-and-off from seemingly its very beginning) but I do think it will find "useful usecases" among Qubes users. |
It's possible to make a software-emulated implementation of the hardware security features where within the context of the VM they're enforced despite not having actual hardware backing outside of it. |
That is very much true. To use a trivial example, “The OS can only boot from this disk image, which it doesn’t have write access to,” is a valid verified boot implementation! It isn’t interesting on real hardware because it doesn’t allow updates, but in Qubes OS updates are handled out of band. Similarly, a separate VM running cryptographic software counts as a TEE where Android is concerned. @thestinger: How bad would it be to allow all third-party applications (
The only information I can find about houdini is that it is a closed-source interpreter, which I would not consider performant. qemu-user would likely be much faster if NDK support was added. |
In a sense, yeah, although it would need a different attestation root and it's not clear if it should really pretend that it's hardware backed but that might be required for app compatibility.
They can already normally do that but the JIT would presumably be external to the VM if not using an x86_64 Android OS. It would be too much work to make it possible to run arm64 apps on an x86_64 OS.
Wouldn't this just be done externally? Modifying the OS to have multiple architectures complicates things a lot. A lot of apps do run on x86 since the developers test in the x86 emulator but not all. |
QEMU full system emulation is far too slow and is also completely unsupported security-wise. I don’t consider it a feasible option except for testing or demonstration uses.
android-x86 and Waydroid already support it using the aforementioned interpreter.
Google’s emulator images come with this support (source: https://chgans.design.blog/2021/05/23/adding-arm-native-bridge-to-the-aosp11-x86-emulator/). The question is how to provide an open source implementation that can be used here. |
On Sat, Mar 30, 2024 at 10:08:00AM -0700, Daniel Micay wrote:
[quote]
Waydroid is based on an insecure fork of Android 11 and has most of the security model disabled. It doesn't have app sandboxing intact and doesn't protect the kernel from apps as Android does. It doesn't have SELinux support which is a major part of the Android application sandbox and the overall security model/approach including kernel attack surface reduction. Android depends on SELinux for the basic privacy and security properties to be intact. The main issue is lack of ongoing maintenance and security patches. Only Android 14 gets full security support, but they could at least be shipping the monthly security backports of High/Critical severity vulnerabilities for Android 11 and using AOSP instead of LineageOS.
[/quote]
Daniel - is there any thing you *would* recommend in place of Waydroid
for use in Qubes?
|
For context: I think it is reasonable to assume that the apps being run are not trusted, and that each app is in a separate VM. |
A more recent discussion which referenced the current issue: |
Over the years, many Qubes users on the mailing lists have expressed the desire to be able to run some kind of Android VM (e.g., HVM) under Qubes OS.
The text was updated successfully, but these errors were encountered: