Can a keylogger in a virtual machine (guest OS) capture keystrokes in host OS? Is there any way to do it?
2 Answers
No, not unless there were a critical VM-escape vulnerability in the VM hypervisor.
-
-
1A shared network does not send keystroke information, so no. You'd have to compromise the host through the shared network (VM escape) like the answer states.– userAug 26, 2019 at 16:02
Are there ways to capture host keystrokes from a guest? Sure, but only in the case of a critical vulnerability or perhaps a misconfiguration.
Here's an example: a user running a GNU/Linux host wants to run some untrusted applications in a VM. They want to share files between host and guest, so they decide to pass /tmp
to the guest. Problem is, the host is running an X11 display server, which doesn't offer isolation between applications, and has a socket file in /tmp/.X11-unix
. Assuming the guest has the ability to write to the file, it can log all keystrokes from the host user's X session using the method outlined here.
While this configuration is unlikely, it does indicate that it is possible to do this given the right circumstances.