# CVE-2026-126641: Ansible-pylibssh: accepts a changed ssh host key when host_key_auto_add is enabled

> A machine-in-the-middle attacker can impersonate hosts to Ansible when host_key_auto_add is enabled, since changed host keys are accepted without warning.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Harmful if only installed:** No
- **Needs a specific call:** Yes (`Session.verify_knownhost()`, `AutoAddPolicy`)
- **Fix available:** No
- **Published:** 12 Nov 2026
- **Updated:** 12 Nov 2026
- **Also known as:** GHSA-qvc6-2r95-pxqv

## What is CVE-2026-126641?

CVE-2026-126641 is a medium-severity security feature bypass vulnerability in Red Hat Ansible Automation Platform 2, published on 12 Nov 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

A host key verification flaw was found in ansible-pylibssh and in the ansible.netcommon libssh connection plugin. When trust-on-first-use is enabled (host_key_auto_add on the libssh connection plugin, or AutoAddPolicy in ansible-pylibssh), a host that is already present in known_hosts but now presents a different key is accepted without warning. The pylibssh Session.verify_knownhost() method passes the SSH_KNOWN_HOSTS_CHANGED and SSH_KNOWN_HOSTS_OTHER states to the same missing_host_key() policy hook used for unknown hosts, and the bundled AutoAddPolicy/RejectPolicy classes (as well as ansible.netcommon's MyAddPolicy, which is modeled on paramiko's AutoAddPolicy) therefore add the changed key and continue the connection rather than aborting as paramiko's BadHostKeyException path would. As a result the controller authenticates to the substitute host, runs the play there, and appends the new key to known_hosts, which can disclose connection credentials to an attacker performing a machine-in-the-middle attack. Default configurations (host_key_checking enabled, host_key_auto_add unset) are not affected; non-interactive runs fail closed.

Weakness: CWE-322 (Key Exchange without Entity Authentication)

## Which versions are affected by CVE-2026-126641?

An affected version is only exploitable if your software calls Session.verify_knownhost() or AutoAddPolicy. Many projects that include it are not exposed.


## How do I fix CVE-2026-126641?

No fix has been published for CVE-2026-126641 yet. Limit exposure of the affected software until one is available.

## Is CVE-2026-126641 being exploited?

There is no known exploitation of CVE-2026-126641 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-126641 and fix it if it is affected.

What it is: CVE-2026-126641 is a medium-severity security feature bypass vulnerability in Red Hat Ansible Automation Platform 2, published on 12 Nov 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-126641 in the wild and no public exploit code.
Exposure: An affected version is only exploitable if your software calls Session.verify_knownhost() or AutoAddPolicy. Many projects that include it are not exposed.

Affected product: Red Hat Ansible Automation Platform 2. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
   If an affected version is present, also search the code for calls to Session.verify_knownhost() or AutoAddPolicy and report whether any exist.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-126641/ (Markdown: https://insights.sbomify.com/CVE-2026-126641/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-126641
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-126641
- OSV: https://osv.dev/vulnerability/CVE-2026-126641

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-126641/
Summaries are generated and may contain mistakes; the official description above is the record.
