Jump to content

Can a virus in a Virtual machine get into the host OS?

i want to play around with a pcap file that probably contains malicious objects that can be saved to the pc. i dont want to save it in my OS for obvious reasons but would like to know if i save it in a virtual machine, use it for few hours and delete the VM files will it somehow manage to get into my host OS from the VM?

Link to comment
Share on other sites

Link to post
Share on other sites

This is actually a really good question... I searched it up and came up with this from SuperUser.com

Quote

What every answer has missed so far is that there are more attack vectors than just network connections and file sharing, but with all the other parts of a virtual machine - especially in regards to virtualizing hardware. A good example of this is shown below (ref. 2) where a guest OS can break out of the VMware container using the emulated virtual COM port.

Another attack vector, commonly included and sometimes enabled by default, on almost all modern processors, is x86 virtualization. While you can argue that having networking enabled on a VM is the biggest security risk (and indeed, it is a risk that must be considered), this only stops viruses from being transmitted how they are transmitted on every other computer - over a network. This is what your anti-virus and firewall software is used for. That being said...

There have been outbreaks of viruses which can actually "break out" of virtual machines, which hasbeen documented in the past (see references 1 and 2 below for details/examples). While an arguable solution is to disable x86 virtualization (and take the performance hit running the virtual machine), any modern (decent) anti-virus software should be able to protect you from these viruses within limited reason. Even DEP will provide protection to a certain extent, but nothing more then when the virus would be executed on your actual OS (and not in a VM). Again, noting the references below, there are many other ways malware can break out of a virtual machine aside from network adapters or instruction virtualization/translation (e.g. virtual COM ports, or other emulated hardware drivers).

Even more recently is the addition of I/O MMU Virtualization to most new processors, which allows DMA. It does not take a computer scientist to see the risk of allowing a virtual machine with a virus direct memory and hardware access, in addition to being able to run code directly on the CPU.

I present this answer simply because all of the other ones allude you to believe that you just need to protect yourself from files, but allowing virus code to directly run on your processor is a much bigger risk in my opinion. Some motherboards disable these features by default, but some don't. The best way to mitigate these risks is to disable virtualization unless you actually need it. If you aren't sure if you need it or not, disable it.

While it is true that some viruses can target vulnerabilities in your virtual machine software, the severity of these threats is drastically increased when you take into account processor or hardware virtualization, especially those that require additional host-side emulation.

Unless you're dealing with some hardcore viruses that haven't been discovered yet, you should be good. Just don't go starting the next Wanna Cry:D

Link to comment
Share on other sites

Link to post
Share on other sites

My recommendation would be to disconnect the VM from the internet (remove the virtual network adapter) or put it in a host only network (vmware workstation/player should support this). It can't suddenly attack the host OS if there is nothing connecting the two.

PC Specs - AMD Ryzen 7 5800X3D MSI B550M Mortar - 32GB Corsair Vengeance RGB DDR4-3600 @ CL16 - ASRock RX7800XT 660p 1TBGB & Crucial P5 1TB Fractal Define Mini C CM V750v2 - Windows 11 Pro

 

Link to comment
Share on other sites

Link to post
Share on other sites

Nothing is better than a sandboxed physical machine.  Grab an old laptop, or throw together a desktop out of scrap parts, play with all your malicious code, then format the drives from a Linux Live USB when you're done.  This won't stop BadUSB though, so be sure to quarantine any suspected USB devices afterwards.

 

If you don't have any scrap hardware laying around, then VM is your safest bet, but just like condoms and birth control, nothing is 100% effective when dealing with viruses.

Main Rig:

Case: Lian Li Lancool Mesh RGB

CPU: Ryzen 5 3600 

Cooler: CoolerMaster MasterLiquid 240

MB: MSI B550 Gaming Pro Carbon 

Ram: Gskill DDR4 3600 x 32GB 

GPU: Asus Arez Strix Vega 64 OC

PS: Seasonic FOCUS Gold Plus Series SSR-750FX

SSD1: Crucial P1 1TB NVME

SSD2: Adata SU800 512gb M.2 Sata

HDD: Hitatchi 2tb 7200RPM + 3x 2TB WD Passport USB 3.0

Monitors: AOC C24G1

Keyboard: Cheap Blue Knockoff Mechanical

Mouse: Uhuru Gaming Mouse
OS: Pop! 21.04



Current Vintage Equipment:  Please ask me about it, I love to talk old tech!
IBM Thinkpad 390, IBM Aptiva A12, IBM PS/2 Model 25-004.  Compaq Contura 4/25C, Presario 7596
Asus P5A-B Socket 7 Box, Tandy 1000RLX-HD "B" & 1200-2FD, VIC20, Zenith ZFL-181-93, Packard Bell 300SX.

Apple II/gs, Mac Plus x2, Mac SE x2, Performa 450

Link to comment
Share on other sites

Link to post
Share on other sites

There are sandbox escapes, but to my knowledge those are only really done at hacker conferences as a proof of concept.  I have yet to see one in the wild.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×