The vulnerability lies in the ComputeEngineSSHHook class, which by default disables SSH host key verification, making SSH connections to Compute Engine instances vulnerable to Man-in-the-Middle (MitM) attacks. The analysis of the provided patch commit 120dbed3462cedcb980aac022c587ba434249eb1 pinpoints the exact locations of the vulnerability.
-
ComputeEngineSSHHook._connect_to_instance: This is the function where the insecure action occurs. Before the patch, it hardcoded the use of paramiko.AutoAddPolicy(), which instructs the SSH client to automatically trust and add any new host key. This is the core of the vulnerability, as it bypasses the check that ensures the client is connecting to the intended server.
-
ComputeEngineSSHHook.__init__: The class constructor is also identified as a vulnerable function because the patch modifies it to introduce a host_key_policy parameter. Crucially, the default value for this new parameter is set to "auto_add", preserving the previous insecure behavior for backward compatibility. This means that any code that instantiates this hook without explicitly setting a stricter policy (like "reject") remains vulnerable.
During a potential exploit, a runtime profiler on an Airflow worker would show the instantiation of the ComputeEngineSSHHook via its __init__ method, followed by a call to _connect_to_instance to establish the SSH connection. It is within _connect_to_instance that the disabled host key verification would allow an attacker to intercept and manipulate the SSH session.