Skip to content
Crypto Write-up Advanced

When “Trust On First Use” Trusts the Second Key Too

Ansible's libssh transport passed changed SSH host keys to the same policy hook used for unknown hosts, so with the auto-add option enabled it accepted an attacker's key without warning. An attacker positioned between the controller and a previously contacted host could impersonate that host, receive the login credentials and run the playbook on their own machine.

aleens09 Follow

Published on medium.com

Cybersecurity

Aleens-labs, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

Ansible's libssh transport is the connection path that ansible-pylibssh and the ansible.netcommon libssh connection plugin use to reach managed hosts. The same plugin backs network_cli when that plugin is configured to use libssh.

SSH has no certificate authority by default, so the first connection to a server carries no way to know whether its key is genuine. Trust on first use (TOFU) accepts that risk once: the client saves the key in known_hosts and checks it on every later connection. That leaves a client with three situations to handle:

  • Unknown host. No key on file. TOFU may add it.
  • Known host, same key. Proceed.
  • Known host, different key. Stop. Either the server was reinstalled, or someone is sitting in the middle.

The third case is the whole point of the mechanism. A TOFU mode that also accepts a changed key is not weaker host key checking. It is no host key checking, with an extra file written to disk.

OpenSSH draws this line with StrictHostKeyChecking=accept-new: new keys are added, changed keys are refused. paramiko draws it the same way. Ansible's libssh transport did not.

Setup

All testing was done on one disposable local virtual machine, against servers the researcher ran, with no real target involved.

  • A local OpenSSH server on [redacted]:2222.
  • For run 1 the server presents host key A. For run 2 it is restarted with host key B, standing in for an interceptor.
  • Each scenario starts with a fresh known_hosts.
  • The end-to-end runs use real ansible-playbook against the ansible.netcommon.libssh connection plugin, and network_cli with ssh_type=libssh.

The affected components are ansible-pylibssh and the ansible.netcommon libssh connection plugin, including network_cli when it uses libssh. The weakness class is CWE-322, Key Exchange without Entity Authentication. Red Hat rated it Moderate, CVSS 3.1 score 6.5 (AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N). Default configurations are not affected: with host_key_checking on and host_key_auto_add unset, runs fail closed. No fixed release had been announced at the time of writing.

Finding it

The researcher did not start from Ansible. The starting point was the oss-security mailing list. The weekly routine is to read new advisories and ask of each one: where else does this same mistake live? That week, an advisory described a wrapper around libssh that mishandled host key checking. The bug class was specific: a language binding that exposes libssh's verification states to its callers in a lossy way.

So the next step was to list other libssh bindings and read how each one handles the result of ssh_session_is_known_server(). ansible-pylibssh stood out because of one dictionary.

Root cause

pylibssh maps three different libssh states to messages, then sends all three to one policy hook:

Python
KNOW_HOST_MSG_MAP = {    libssh.SSH_KNOWN_HOSTS_CHANGED: "Host key for server has changed: ",    libssh.SSH_KNOWN_HOSTS_OTHER:   "Host key type for server has changed: ",    libssh.SSH_KNOWN_HOSTS_UNKNOWN: "Host is unknown: "}
Python
def verify_knownhost(self):    state = libssh.ssh_session_is_known_server(self._libssh_session)    if state == libssh.SSH_KNOWN_HOSTS_OK:        return True    ...    self._policy.missing_host_key(self, ..., KNOW_HOST_MSG_MAP[state] + self._hash_py)

The hook is called missing_host_key(). The bundled policy classes are called AutoAddPolicy and RejectPolicy. Those names come from paramiko, and pylibssh adopted them so that code written for paramiko would feel at home.

But in paramiko, missing_host_key() runs only when the host is absent from known_hosts. A mismatched key never reaches a policy. It raises BadHostKeyException first.

pylibssh kept the name and widened the meaning. "Missing" now also covers "present, but different". And the policy receives only a free-text message, not the libssh state, so a policy author cannot tell the two cases apart without parsing English.

Ansible's own policy shows what happens next. Its docstring says it is "Based on AutoAddPolicy in paramiko", and it was written to paramiko's narrow meaning:

Python
def missing_host_key(self, session, hostname, username, key_type, fingerprint, message):    if all((self._options["host_key_checking"], not self._options["host_key_auto_add"])):        ...      session.hostkey_auto_add(username)

With host_key_auto_add enabled, the prompt is skipped and the key is added. For an unknown host, that is the documented behaviour. For a changed key, it is an attacker's key being written into known_hosts.

There is a second, smaller problem in the same function. In an interactive run, the prompt accepts an empty answer. Pressing Enter counts as "yes", even when the message says the host key has changed.

Exploitation

Reading code gives you a hypothesis. A report needs a run. Each step below was executed on the disposable VM described in Setup.

Step 1: library level, three clients, one changed key

Same server, same key swap, same "auto-add" mode:

  • ansible-pylibssh with AutoAddPolicy: connects and authenticates to key B
  • paramiko with AutoAddPolicy: raises BadHostKeyException
  • OpenSSH with accept-new: refuses the connection

That comparison matters more than any single log. It shows two independent, widely trusted clients rejecting exactly what pylibssh accepts.

Step 2: end to end with ansible.netcommon.libssh

With ANSIBLE_LIBSSH_HOST_KEY_AUTO_ADD=true, run 2 executes the task on the key-B server. No warning is shown. Key B is appended to known_hosts.

Step 3: end to end with network_cli

With ssh_type=libssh and the same setting, run 2 reports ok=1 failed=0. The key-B server's own sshd log records Accepted password for the controller's user.

That sshd log line is the impact in one sentence. The interceptor did not just see a handshake. It received the password.

From the original on medium.com

Step 4: defaults, interactive

The prompt says "Host key for server has changed". Pressing Enter accepts it.

Step 5: defaults, non-interactive

Fails closed, for unknown and for changed keys. known_hosts is untouched.

Is this by design?

This is the question that kills most reports, and it is a fair one. Before writing a word to the vendor, the researcher went looking for evidence that accepting changed keys was the design. Everything pointed the other way:

  • libssh's own tutorial, for the library pylibssh wraps. On SSH_KNOWN_HOSTS_CHANGED it says "For security reasons, connection will be stopped" and returns an error. Only the unknown-host cases may ask the user and save a key.
  • ansible.netcommon's own documentation. host_key_auto_add is described in terms of unknown host keys and the first connection to a new host.
  • paramiko, whose API pylibssh mirrors. The policy is never consulted for a mismatch.
  • OpenSSH accept-new. Adds new keys, refuses changed ones.
  • The pylibssh test suite. No test covers host key policy at all, so nothing pins the current behaviour as intended.
  • The libssh plugin's option docs. The entry for host_key_auto_add reads "TODO: write it".
  • Precedent. CVE-2013-2233 covered Ansible's paramiko connection "effectively disabling host key checking". Same class, already treated as a vulnerability.

That list went into the report as a table, directly under the summary. When the vendor's first question is already answered on page one, triage gets short.

Impact

Overstating a finding is the fastest way to lose a triager's trust. These are the limits, and they were in the report too:

  • Defaults are safe. host_key_checking on and host_key_auto_add unset means non-interactive runs fail closed.
  • Exposure needs the libssh-specific option: ANSIBLE_LIBSSH_HOST_KEY_AUTO_ADD=true, or host_key_auto_add under [libssh_connection].
  • network_cli's same-named option is not forwarded to libssh. In the tests ANSIBLE_HOST_KEY_AUTO_ADD had no effect on the libssh transport. The researcher had assumed otherwise at first, the end-to-end run proved it wrong, and the report was corrected before sending it.
  • The attacker needs a network position between the controller and a host it has contacted before.

Why it still matters: host_key_auto_add is a convenience aimed at network automation, where fleets of devices are onboarded in bulk. And the paramiko transport is deprecated in favour of libssh, so this is the path users are being moved onto.

Fix

The mitigation is straightforward: do not enable host_key_auto_add on the libssh plugin. Pre-populate known_hosts instead.

The concrete steps given are:

  • Do not enable host_key_auto_add for the libssh connection plugin, and do not use AutoAddPolicy with pylibssh.
  • Pre-populate known_hosts over a trusted path, for example with ssh-keyscan from a management network.
  • Keep host_key_checking enabled.
  • At an interactive host key prompt, never answer with a bare Enter.

The suggested code fix, in pylibssh, is to fail closed before any policy runs:

Python
if state in (libssh.SSH_KNOWN_HOSTS_CHANGED, libssh.SSH_KNOWN_HOSTS_OTHER):    raise LibsshSessionException(KNOW_HOST_MSG_MAP[state] + self._hash_py)

Then consult missing_host_key() only for SSH_KNOWN_HOSTS_UNKNOWN. In ansible.netcommon, the policy should refuse changed keys on its own, and stop treating an empty answer as consent.

Disclosure timeline

Both projects' SECURITY.md files require reports by email to [redacted], not through public issues. The researcher followed that, with Red Hat Product Security in copy as the CVE Numbering Authority.

  • 2026-10-22. Found during the variant hunt. PoC, end-to-end runs and by-design review completed the same day. Report sent with a setup script, the harness, raw logs and terminal screenshots.
  • 2026-11-11. Red Hat confirms the issue, agrees that defaults are not affected, rates it Moderate (CVSS 6.5) and assigns CVE-2026-126641.
  • 2026-11-12. Red Hat lifts the embargo because the issue is rated Moderate. The CVE record is published.

The researcher proposed 7.4 with integrity impact High. Red Hat scored integrity Low, which gives 6.5. For an opt-in setting that is a reasonable call, and it was not contested.

The triage note said the scenario matrix and the reproducible PoC "made triage straightforward". There is no bounty for this one; Red Hat does not run a paid programme for it. The outcome is a CVE, a credit line, and a clear path to a fix for the people who use the software.

Variants to test

The lessons from this report translate into concrete checks on other targets:

  1. Look for APIs that copy a name but not the semantics. A library that borrows another library's class and method names inherits its users' assumptions. If the meaning is wider, every caller written to the original meaning is exposed. A docstring that says "Based on X in Y" is a lead worth following.
  2. Hunt variants, not targets. A public advisory is a description of a mistake someone has already proven is easy to make. Asking where else it lives is cheaper than starting cold, and fewer people are looking in the same place.
  3. Answer "is it by design?" before the vendor asks. Collect the vendor's documentation, the upstream library's guidance, comparable implementations, the test suite and a precedent CVE. If they all support the behaviour, you have a hardening note, not a vulnerability.
  4. Compare against a baseline. One log proves that something happened. The same scenario run against two trusted implementations that refuse proves that it should not have.
  5. Run it end to end. The first draft claimed that migrating from paramiko silently changed the meaning of a setting. The real ansible-playbook run showed that claim was wrong.
  6. Say what is not affected. The default configuration is safe, and the report said so in its first paragraph. Red Hat's confirmation explicitly agreed with it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 19 min read.

What happened, in plain words

A tool called Ansible has a feature that is meant to make connecting to servers more convenient. When you connect to a server for the first time, Ansible can save that server's identity so it recognises it next time. That is a normal and useful idea.

The problem is that the feature went one step too far. It also accepted a different identity from a server it had already met before, without warning anyone. If someone managed to sit between your computer and that server, Ansible would happily talk to the impostor, run your tasks there, and save the impostor's identity as if it were the real server's. In one of the tests, the impostor server's own log recorded an accepted password for the controller's user.

Red Hat, the company that looks after the security of this software, confirmed the issue and gave it an official tracking number: CVE-2026-126641. A CVE is a public label for a known security flaw, so people can look it up and follow the fix.

The short summary of the finding:

  • Affected: ansible-pylibssh and the ansible.netcommon libssh connection plugin, including network_cli when it uses libssh
  • Class: CWE-322, Key Exchange without Entity Authentication
  • Severity: Moderate, CVSS 3.1 score 6.5 (AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N)
  • Not affected: default configurations. With host_key_checking on and host_key_auto_add unset, runs fail closed.
  • Fix: no fixed release announced at the time of writing. Mitigation is below.

If you only want the practical advice: do not turn on host_key_auto_add on the libssh plugin. Fill in the list of known servers yourself instead.

Before going further, a few words on the pieces involved, because the rest of the story depends on them.

Ansible is a program that automates work on other computers. You write a list of tasks (a "playbook"), and Ansible connects to each machine in turn and carries them out. Think of it as a manager who phones each branch office and reads out instructions.

SSH is the secure way one computer logs in to another. It is the phone line in that comparison. When your computer connects to a server over SSH, the server proves its identity with a host key, which is a long string of characters unique to that server, a bit like a passport number.

libssh is a piece of software that implements SSH, so other programs can use SSH without writing it all themselves. pylibssh is a wrapper that lets programs written in the Python language use libssh. A wrapper like this is often called a binding: it is an adapter between one language and a library written in another.

paramiko is a different, older Python SSH library. Many people already used it, so pylibssh borrowed some of its names to feel familiar. Keep that in mind, because the borrowed names are at the heart of the bug.

known_hosts is a small file on your computer that stores the host keys of servers you have connected to before. It is your personal address book of trusted servers.

Trust on first use (TOFU) is the rule that says: the first time you meet a server, accept its key and write it down; from then on, check that the key has not changed. It is like accepting a new colleague's phone number the first time they give it to you, then being suspicious if someone calls from that number and sounds like a different person.

Trust on first use, and the one event it exists to catch

SSH has no central authority that hands out certified identities by default. The first time you connect to a server, you have no way to know its key is genuine. Trust on first use accepts that risk once: the client saves the key in known_hosts and checks it on every later connection.

That gives a client three situations to handle:

  • Unknown host. No key on file. TOFU may add it.
  • Known host, same key. Proceed.
  • Known host, different key. Stop. Either the server was reinstalled, or someone is sitting in the middle.

The third case is the whole point of the mechanism. A TOFU mode that also accepts a changed key is not weaker host key checking. It is no host key checking, with an extra file written to disk.

In everyday terms: the whole reason you write a number down is so you can notice when it changes. If you accept a changed number without a word, the address book was pointless.

OpenSSH, the most common SSH program, draws this line with a setting called StrictHostKeyChecking=accept-new: new keys are added, changed keys are refused. paramiko draws it the same way. Ansible's libssh transport did not.

How the researcher found it: looking for the same mistake elsewhere

The researcher did not start from Ansible. The starting point was the oss-security mailing list, a public email list where security problems in open-source software are announced.

The weekly routine is to read new advisories and ask of each one: where else does this same mistake live? This is called variant hunting: instead of picking a target and staring at it, you take a mistake someone has already found and proven easy to make, and look for other places where the same pattern appears. It is cheaper than starting cold, and fewer people are looking in the same place.

That week, an advisory described a wrapper around libssh that mishandled host key checking. The bug class was specific: a language binding that exposes libssh's verification states to its callers in a lossy way. "Lossy" here means information gets thrown away on the way through, like a translator who turns three distinct words into one vague word.

So the next step was to list other libssh bindings and read how each one handles the result of ssh_session_is_known_server(). That function is the moment of truth: it asks libssh "do I know this server?" and returns an answer. ansible-pylibssh stood out because of one dictionary.

The root cause: same name, wider meaning

A dictionary in Python is a lookup table: you give it a key, it gives you back a value. Here, pylibssh uses one to turn libssh's answers into human-readable messages.

Python
KNOW_HOST_MSG_MAP = {    libssh.SSH_KNOWN_HOSTS_CHANGED: "Host key for server has changed: ",    libssh.SSH_KNOWN_HOSTS_OTHER:   "Host key type for server has changed: ",    libssh.SSH_KNOWN_HOSTS_UNKNOWN: "Host is unknown: "}

Line by line:

  • KNOW_HOST_MSG_MAP = { starts a dictionary called KNOW_HOST_MSG_MAP.
  • libssh.SSH_KNOWN_HOSTS_CHANGED: "Host key for server has changed: " says: when libssh reports that the server's key has changed, use the message "Host key for server has changed: ".
  • libssh.SSH_KNOWN_HOSTS_OTHER: "Host key type for server has changed: " says: when the type of key has changed, use that message.
  • libssh.SSH_KNOWN_HOSTS_UNKNOWN: "Host is unknown: " says: when the server is not in the address book at all, use that message.

So far, so clear: three different situations, three different messages. The trouble starts in the next function, which sends all three to the same place.

Python
def verify_knownhost(self):    state = libssh.ssh_session_is_known_server(self._libssh_session)    if state == libssh.SSH_KNOWN_HOSTS_OK:        return True    ...    self._policy.missing_host_key(self, ..., KNOW_HOST_MSG_MAP[state] + self._hash_py)

Line by line:

  • def verify_knownhost(self): defines a function called verify_knownhost, whose job is to check whether the server is known.
  • state = libssh.ssh_session_is_known_server(self._libssh_session) asks libssh about the current connection and stores the answer in a variable called state.
  • if state == libssh.SSH_KNOWN_HOSTS_OK: checks whether the answer is "all good, known server, same key".
  • return True means: if so, carry on, nothing more to do.
  • ... stands for code left out of the excerpt.
  • self._policy.missing_host_key(self, ..., KNOW_HOST_MSG_MAP[state] + self._hash_py) is the important line. For every other answer (changed key, changed key type, unknown host), it calls a single hook called missing_host_key(), handing it only a text message built from the dictionary plus a fingerprint.

A hook here is a function that the library calls so that the surrounding program can decide what to do. It is like a receptionist who passes your call to a manager: the library hands the decision to the policy.

The hook is called missing_host_key(). The bundled policy classes are called AutoAddPolicy and RejectPolicy. A policy is simply a rule for what to do in a given situation. Those names come from paramiko, and pylibssh adopted them so that code written for paramiko would feel at home.

But in paramiko, missing_host_key() runs only when the host is absent from known_hosts. A mismatched key never reaches a policy. It raises BadHostKeyException first, which is an error that stops everything.

pylibssh kept the name and widened the meaning. "Missing" now also covers "present, but different". And the policy receives only a free-text message, not the libssh state, so a policy author cannot tell the two cases apart without parsing English. Parsing English means reading the sentence and guessing from its wording, which is fragile: change a word and the logic breaks.

Ansible's own policy shows what happens next. Its docstring (a short explanatory note attached to the code) says it is "Based on AutoAddPolicy in paramiko", and it was written to paramiko's narrow meaning:

Python
def missing_host_key(self, session, hostname, username, key_type, fingerprint, message):    if all((self._options["host_key_checking"], not self._options["host_key_auto_add"])):        ...      session.hostkey_auto_add(username)

Line by line:

  • def missing_host_key(self, session, hostname, username, key_type, fingerprint, message): defines the policy's reaction, receiving details about the connection and the message from the dictionary.
  • if all((self._options["host_key_checking"], not self._options["host_key_auto_add"])): checks two settings at once: is host key checking switched on, and is auto-add switched off? all(...) means both must be true.
  • ... stands for code left out of the excerpt.
  • session.hostkey_auto_add(username) adds the key to known_hosts automatically.

With host_key_auto_add enabled, the prompt is skipped and the key is added. For an unknown host, that is the documented behaviour. For a changed key, it is an attacker's key being written into known_hosts.

There is a second, smaller problem in the same function. In an interactive run, the prompt accepts an empty answer. Pressing Enter counts as "yes", even when the message says the host key has changed. That is like a bank teller asking "this signature looks different, do you approve?" and treating silence as approval.

Proving it

Reading code gives you a hypothesis. A report needs a run. A proof of concept (PoC) is a concrete demonstration that the problem is real, not just suspected. Everything below was done on one disposable virtual machine, with no real target involved. A virtual machine is a computer simulated inside your own computer, so you can break it freely and throw it away.

The setup. A local OpenSSH server on [redacted]:2222. [redacted] is the address a computer uses to talk to itself, and 2222 is a port, which is like a door number on that address. For run 1 the server presents host key A. For run 2 it is restarted with host key B, standing in for an interceptor. Each scenario starts with a fresh known_hosts.

Step 1: library level, three clients, one changed key

Same server, same key swap, same "auto-add" mode:

  • ansible-pylibssh with AutoAddPolicy: connects and authenticates to key B
  • paramiko with AutoAddPolicy: raises BadHostKeyException
  • OpenSSH with accept-new: refuses the connection

That comparison matters more than any single log. It shows two independent, widely trusted clients rejecting exactly what pylibssh accepts. A baseline is a known-good reference you compare against: if two careful programs refuse and one accepts, the odd one out is the suspect.

Step 2: end to end with ansible.netcommon.libssh

With ANSIBLE_LIBSSH_HOST_KEY_AUTO_ADD=true, run 2 executes the task on the key-B server. No warning is shown. Key B is appended to known_hosts.

"End to end" means running the real tool the way a user would, not just poking at the library in isolation. ANSIBLE_LIBSSH_HOST_KEY_AUTO_ADD=true is an environment variable: a setting you give a program before it starts, like a note pinned to its desk.

Step 3: end to end with network_cli

With ssh_type=libssh and the same setting, run 2 reports ok=1 failed=0. The key-B server's own sshd log records Accepted password for the controller's user.

network_cli is an Ansible plugin for talking to network devices. sshd is the SSH server program, and its log is its diary of what happened. ok=1 failed=0 means one task succeeded and none failed, which looks like a perfectly normal run.

That sshd log line is the impact in one sentence. The interceptor did not just see a handshake. It received the password.

From the original on medium.com

Step 4: defaults, interactive

The prompt says "Host key for server has changed". Pressing Enter accepts it. An interactive run is one where a person is sitting there and can answer questions.

Step 5: defaults, non-interactive

Fails closed, for unknown and for changed keys. known_hosts is untouched. "Fails closed" means that when in doubt, it stops rather than continues, like a door that locks when the power goes out. A non-interactive run is one with nobody there to answer prompts, such as a scheduled job.

"Is this by design?"

This is the question that kills most reports, and it is a fair one. A vendor can always reply "that is how we meant it to work", and then there is no bug to fix. Before writing a word to the vendor, the researcher went looking for evidence that accepting changed keys was the design. Everything pointed the other way:

  • libssh's own tutorial, for the library pylibssh wraps. On SSH_KNOWN_HOSTS_CHANGED it says "For security reasons, connection will be stopped" and returns an error. Only the unknown-host cases may ask the user and save a key.
  • ansible.netcommon's own documentation. host_key_auto_add is described in terms of unknown host keys and the first connection to a new host.
  • paramiko, whose API pylibssh mirrors. The policy is never consulted for a mismatch. An API is the set of names and rules one piece of software offers to another, like the menu in a restaurant: it tells you what you can order and what you will get.
  • OpenSSH accept-new. Adds new keys, refuses changed ones.
  • The pylibssh test suite. No test covers host key policy at all, so nothing pins the current behaviour as intended.
  • The libssh plugin's option docs. The entry for host_key_auto_add reads "TODO: write it".
  • Precedent. CVE-2013-2233 covered Ansible's paramiko connection "effectively disabling host key checking". Same class, already treated as a vulnerability. A precedent is an earlier case handled the same way, which makes it harder to argue the new case is fine.

That list went into the report as a table, directly under the summary. When the vendor's first question is already answered on page one, triage gets short. Triage is the first pass a vendor makes over a report to decide whether it is real and how serious it is.

Who is exposed, stated plainly

Overstating a finding is the fastest way to lose a triager's trust. These are the limits, and they were in the report too:

  • Defaults are safe. host_key_checking on and host_key_auto_add unset means non-interactive runs fail closed.
  • Exposure needs the libssh-specific option: ANSIBLE_LIBSSH_HOST_KEY_AUTO_ADD=true, or host_key_auto_add under [libssh_connection].
  • network_cli's same-named option is not forwarded to libssh. In the tests ANSIBLE_HOST_KEY_AUTO_ADD had no effect on the libssh transport. The researcher had assumed otherwise at first, the end-to-end run proved it wrong, and the report was corrected before sending it.
  • The attacker needs a network position between the controller and a host it has contacted before. In other words, someone has to be able to intercept the traffic, for example on a shared network.

Why it still matters: host_key_auto_add is a convenience aimed at network automation, where fleets of devices are onboarded in bulk. And the paramiko transport is deprecated in favour of libssh, so this is the path users are being moved onto. Deprecated means the makers have signalled it is on its way out and you should move to the replacement.

What to do now

No fixed release had been announced at the time of writing. The mitigation is straightforward: do not enable host_key_auto_add on the libssh plugin. Pre-populate known_hosts instead.

The concrete steps given are:

  • Do not enable host_key_auto_add for the libssh connection plugin, and do not use AutoAddPolicy with pylibssh.
  • Pre-populate known_hosts over a trusted path, for example with ssh-keyscan from a management network. ssh-keyscan is a tool that asks a server for its key so you can record it in advance.
  • Keep host_key_checking enabled.
  • At an interactive host key prompt, never answer with a bare Enter.

The fix the researcher suggested

The suggested code fix, in pylibssh, is to fail closed before any policy runs:

Python
if state in (libssh.SSH_KNOWN_HOSTS_CHANGED, libssh.SSH_KNOWN_HOSTS_OTHER):    raise LibsshSessionException(KNOW_HOST_MSG_MAP[state] + self._hash_py)

Line by line:

  • if state in (libssh.SSH_KNOWN_HOSTS_CHANGED, libssh.SSH_KNOWN_HOSTS_OTHER): checks whether libssh's answer is either "key changed" or "key type changed".
  • raise LibsshSessionException(KNOW_HOST_MSG_MAP[state] + self._hash_py) stops immediately with an error, carrying the matching message and the fingerprint. raise means "abandon this and report a failure".

Then consult missing_host_key() only for SSH_KNOWN_HOSTS_UNKNOWN. In ansible.netcommon, the policy should refuse changed keys on its own, and stop treating an empty answer as consent.

Disclosure timeline

Both projects' SECURITY.md files require reports by email to [redacted], not through public issues. The researcher followed that, with Red Hat Product Security in copy as the CVE Numbering Authority. A CVE Numbering Authority is an organisation allowed to assign CVE labels. Disclosure is the process of telling the vendor privately, then the world publicly. An embargo is a short period where the details stay private so a fix can be prepared.

  • 2026-10-22. Found during the variant hunt. PoC, end-to-end runs and by-design review completed the same day. Report sent with a setup script, the harness, raw logs and terminal screenshots. A harness is the set of scripts that set up and run the test automatically.
  • 2026-11-11. Red Hat confirms the issue, agrees that defaults are not affected, rates it Moderate (CVSS 6.5) and assigns CVE-2026-126641. CVSS is a standard scoring system for the severity of a flaw, from 0 to 10.
  • 2026-11-12. Red Hat lifts the embargo because the issue is rated Moderate. The CVE record is published.

The researcher proposed 7.4 with integrity impact High. Red Hat scored integrity Low, which gives 6.5. For an opt-in setting that is a reasonable call, and it was not contested. Integrity here means whether data could be altered without detection.

The triage note said the scenario matrix and the reproducible PoC "made triage straightforward". There is no bounty for this one; Red Hat does not run a paid programme for it. A bounty is a reward paid for finding and reporting a flaw. The outcome is a CVE, a credit line, and a clear path to a fix for the people who use the software.

What the researcher is taking from this

  1. Look for APIs that copy a name but not the semantics. A library that borrows another library's class and method names inherits its users' assumptions. If the meaning is wider, every caller written to the original meaning is exposed. A docstring that says "Based on X in Y" is a lead worth following.
  2. Hunt variants, not targets. A public advisory is a description of a mistake someone has already proven is easy to make. Asking where else it lives is cheaper than starting cold, and fewer people are looking in the same place.
  3. Answer "is it by design?" before the vendor asks. Collect the vendor's documentation, the upstream library's guidance, comparable implementations, the test suite and a precedent CVE. If they all support the behaviour, you have a hardening note, not a vulnerability.
  4. Compare against a baseline. One log proves that something happened. The same scenario run against two trusted implementations that refuse proves that it should not have.
  5. Run it end to end. The first draft claimed that migrating from paramiko silently changed the meaning of a setting. The real ansible-playbook run showed that claim was wrong.
  6. Say what is not affected. The default configuration is safe, and the report said so in its first paragraph. Red Hat's confirmation explicitly agreed with it.

Glossary

  • Ansible: a program that automates tasks on many computers by connecting to each one and running a playbook.
  • API: the set of names and rules one piece of software offers to another, like a menu of what you can ask for.
  • Baseline: a known-good reference used for comparison, so you can tell whether a result is normal or odd.
  • Binding: an adapter that lets programs in one language use a library written in another.
  • Bounty: a reward paid for finding and reporting a security flaw.
  • CVE: a public label for a known security flaw, so people can look it up and follow the fix.
  • CVE Numbering Authority: an organisation authorised to assign CVE labels.
  • CVSS: a standard scoring system for the severity of a flaw, from 0 to 10.
  • CWE-322: the official name for the class of flaw here, key exchange without entity authentication, meaning a connection is set up without properly proving who the other side is.
  • Deprecated: marked as on its way out, with users expected to move to a replacement.
  • Dictionary: in Python, a lookup table that maps keys to values.
  • Disclosure: the process of telling the vendor privately, then the public, about a flaw.
  • Docstring: a short explanatory note attached to a piece of code.
  • Embargo: a short period where details stay private so a fix can be prepared.
  • End to end: running the real tool the way a user would, rather than testing a piece in isolation.
  • Environment variable: a setting given to a program before it starts, like a note pinned to its desk.
  • Fails closed: when in doubt, stops rather than continues, like a door that locks when the power goes out.
  • Harness: the set of scripts that set up and run a test automatically.
  • Hook: a function the library calls so the surrounding program can decide what to do.
  • Host key: a long string of characters unique to a server, used to prove its identity, like a passport number.
  • Integrity: whether data could be altered without detection.
  • Interactive: a run where a person is present and can answer questions.
  • known_hosts: a file on your computer storing the host keys of servers you have connected to before, your address book of trusted servers.
  • libssh: a piece of software that implements SSH so other programs can use it.
  • Lossy: information gets thrown away on the way through, like a translator turning three distinct words into one vague word.
  • network_cli: an Ansible plugin for talking to network devices.
  • Non-interactive: a run with nobody present to answer prompts, such as a scheduled job.
  • paramiko: an older Python SSH library whose names pylibssh borrowed.
  • Playbook: a list of tasks Ansible carries out on other computers.
  • Policy: a rule for what to do in a given situation.
  • Port: a door number on a network address, so one computer can run several services.
  • Precedent: an earlier case handled the same way, which makes it harder to argue the new case is fine.
  • Proof of concept (PoC): a concrete demonstration that a problem is real, not just suspected.
  • pylibssh: a wrapper that lets Python programs use libssh.
  • SSH: the secure way one computer logs in to another.
  • sshd: the SSH server program, whose log is its diary of what happened.
  • ssh-keyscan: a tool that asks a server for its key so you can record it in advance.
  • TOFU (trust on first use): accept a server's key the first time you meet it and write it down, then check it has not changed.
  • Triage: the first pass a vendor makes over a report to decide whether it is real and how serious it is.
  • Variant hunting: taking a mistake someone has already found and proven easy to make, and looking for other places where the same pattern appears.
  • Virtual machine: a computer simulated inside your own computer, so you can break it freely and throw it away.

More by aleens09

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.