Can a keylogger in a virtual machine (guest OS) capture keystrokes in host OS? Is there any way to do it?

2 Answers 2


No, not unless there were a critical VM-escape vulnerability in the VM hypervisor.

  • Not even through the shared network?
    – mustang
    Commented Aug 26, 2019 at 15:41
  • 1
    A 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.
    – user
    Commented Aug 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .