summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAudun V. Nes <audun.nes@gmail.com>2022-07-27 21:01:41 +0200
committerGitHub <noreply@github.com>2022-07-27 15:01:41 -0400
commitd9298647d91c52e1ee9ac448e43a7fea1c69bdbe (patch)
tree7f96264e4bea45b03f1a8c97410919a7dc84ad96
parentbb40ba051fc67605d5c9e7fd1eb5f9aa3e0fb501 (diff)
downloaddocker-py-d9298647d91c52e1ee9ac448e43a7fea1c69bdbe.tar.gz
ssh: reject unknown host keys when using Python SSH impl (#2932)
In the Secure Shell (SSH) protocol, host keys are used to verify the identity of remote hosts. Accepting unknown host keys may leave the connection open to man-in-the-middle attacks. Do not accept unknown host keys. In particular, do not set the default missing host key policy for the Paramiko library to either AutoAddPolicy or WarningPolicy. Both of these policies continue even when the host key is unknown. The default setting of RejectPolicy is secure because it throws an exception when it encounters an unknown host key. Reference: https://cwe.mitre.org/data/definitions/295.html NOTE: This only affects SSH connections using the native Python SSH implementation (Paramiko), when `use_ssh_client=False` (default). If using the system SSH client (`use_ssh_client=True`), the host configuration (e.g. `~/.ssh/config`) will apply. Signed-off-by: Audun Nes <audun.nes@gmail.com>
-rw-r--r--docker/transport/sshconn.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/docker/transport/sshconn.py b/docker/transport/sshconn.py
index ba8c11d..4f748f7 100644
--- a/docker/transport/sshconn.py
+++ b/docker/transport/sshconn.py
@@ -215,7 +215,7 @@ class SSHHTTPAdapter(BaseHTTPAdapter):
self.ssh_params['key_filename'] = host_config['identityfile']
self.ssh_client.load_system_host_keys()
- self.ssh_client.set_missing_host_key_policy(paramiko.WarningPolicy())
+ self.ssh_client.set_missing_host_key_policy(paramiko.RejectPolicy())
def _connect(self):
if self.ssh_client: