The vulnerability is a classic link-following issue within the KubeVirt virt-handler component. An attacker with permissions to create/edit virtual machines could exploit this to gain control over the underlying node and potentially the entire cluster.
The root cause lies in how virt-handler connects to virtual machine console sockets. The process involved two key functions:
ConsoleHandler.getUnixSocketPath: This function constructed the path to the console socket file. Critically, it used os.Stat to validate the path. os.Stat follows symbolic links by default, meaning if an attacker replaced the legitimate socket with a symlink pointing to a sensitive host socket (like /var/run/crio/crio.sock), this check would validate the existence of the target file, not the symlink itself.
unixSocketDialer: This function took the path from getUnixSocketPath and used net.Dial("unix", ...) to establish a connection. net.Dial also follows symlinks. Therefore, it would connect to the malicious target specified by the attacker's symlink, but with the high privileges of the virt-handler process.
The patch addresses this by introducing the safepath library. The getUnixSocketPath function was modified to use safepath.AppendAndResolveWithRelativeRoot, which resolves a path without following symlinks. The unixSocketDialer was changed to use safepath.ExecuteNoFollow, ensuring that the dial operation is performed on the legitimate file and not a symlink target. This prevents the symlink from being followed at the time of connection, mitigating the vulnerability.