Can a keylogger in a virtual machine (guest OS) capture keystrokes in host OS? Is there any way to do it?
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.