5.3medium
libgit2 fails to verify SSH keys by default
- Severity
- 5.3medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.63% (higher than 51% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-m4ch-rfv5-x5g3GHSA-8643-3wh5-rmjqRUSTSEC-2023-0003
Description
libgit2 is a cross-platform, linkable library implementation of Git. When using an SSH remote with the optional libssh2 backend, libgit2 does not perform certificate checking by default. Prior versions of libgit2 require the caller to set the `certificate_check` field of libgit2's `git_remote_callbacks` structure - if a certificate check callback is not set, libgit2 does not perform any certificate checking. This means that by default - without configuring a certificate check callback, clients will not perform validation on the server SSH keys and may be subject to a man-in-the-middle attack. Users are encouraged to upgrade to v1.4.5 or v1.5.1. Users unable to upgrade should ensure that all relevant certificates are manually checked.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| libgit2 libgit2 | < 1.4.5, = 1.5.0, before 1.4.5, 1.5.0 | CVE List, NVD |
| libgit2-sys (crates.io) | from 0.14.0 before 0.14.2, before 0.13.5, from 0.0.0-0 before 0.13.5 | GitHub Advisory Database, RustSec Advisory Database |
| git2 (crates.io) | before 0.16.1 | GitHub Advisory Database |
All scores
| GitHub_M | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N |
| GitHub | 6.8medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N |
| NVD | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
libgit2 is a cross-platform, linkable library implementation of Git. When using an SSH remote with the optional libssh2 backend, libgit2 does not perform certificate checking by default. Prior versions of libgit2 require the caller to set the `certificate_check` field of libgit2's `git_remote_callbacks` structure - if a certificate check callback is not set, libgit2 does not perform any certificate checking. This means that by default - without configuring a certificate check callback, clients will not perform validation on the server SSH keys and may be subject to a man-in-the-middle attack. Users are encouraged to upgrade to v1.4.5 or v1.5.1. Users unable to upgrade should ensure that all relevant certificates are manually checked.
GitHub Advisory Database
The git2 and libgit2-sys crates are Rust wrappers around the libgit2 C library. It was discovered that libgit2 1.5.0 and below did not verify SSH host keys when establishing an SSH connection, exposing users of the library to Man-In-the-Middle attacks.
The libgit2 team assigned CVE-2023-22742 to this vulnerability. The following versions of the libgit2-sys Rust crate have been released:
- libgit2-sys 0.14.2, updating the underlying libgit2 C library to version 1.5.1.
- libgit2-sys 0.13.5, updating the underlying libgit2 C library to version 1.4.5.
A new git2 crate version has also been released, 0.16.1. This version only bumps its libgit2-sys dependency to ensure no vulnerable libgit2-sys versions are used, but contains no code changes: if you update the libgit2-sys version there is no need to also update the git2 crate version.
You can learn more about this vulnerability in libgit2's advisory
RustSec Advisory Database
The git2 and libgit2-sys crates are Rust wrappers around the libgit2 C library. It was discovered that libgit2 1.5.0 and below did not verify SSH host keys when establishing an SSH connection, exposing users of the library to Man-In-the-Middle attacks.
The libgit2 team assigned CVE-2023-22742 to this vulnerability. The following versions of the libgit2-sys Rust crate have been released:
- libgit2-sys 0.14.2, updating the underlying libgit2 C library to version 1.5.1.
- libgit2-sys 0.13.5, updating the underlying libgit2 C library to version 1.4.5.
A new git2 crate version has also been released, 0.16.1. This version only bumps its libgit2-sys dependency to ensure no vulnerable libgit2-sys versions are used, but contains no code changes: if you update the libgit2-sys version there is no need to also update the git2 crate version.
You can learn more about this vulnerability in libgit2's advisory
NVD (es)
libgit2 es una implementación de librería vinculable y multiplataforma de Git. Cuando se utiliza un control remoto SSH con el backend libssh2 opcional, libgit2 no realiza la verificación de certificados de forma predeterminada. Las versiones anteriores de libgit2 requieren que la persona que llama establezca el campo `certificate_check` de la estructura `git_remote_callbacks` de libgit2; si no se establece una devolución de llamada de verificación de certificado, libgit2 no realiza ninguna verificación de certificado. Esto significa que, de forma predeterminada, sin configurar una devolución de llamada de verificación de certificado, los clientes no realizarán la validación de las claves SSH del servidor y pueden estar sujetos a un ataque de intermediario. Se anima a los usuarios a actualizar a v1.4.5 o v1.5.1. Los usuarios que no puedan actualizar deben asegurarse de que todos los certificados relevantes se verifiquen manualmente.
References
| https://github.com/libgit2/libgit2/security/advisories/GHSA-8643-3wh5-rmjq | third-party-advisory, web | |
| https://github.com/libgit2/libgit2/commit/42e5db98b963ae503229c63e44e06e439df50e56 | patch, third-party-advisory | |
| https://github.com/libgit2/libgit2/commit/cd6f679af401eda1f172402006ef8265f8bd58ea | patch, third-party-advisory | |
| https://github.com/libgit2/libgit2/releases/tag/v1.4.5 | release-notes, third-party-advisory | |
| https://github.com/libgit2/libgit2/releases/tag/v1.5.1 | release-notes, third-party-advisory | |
| https://www.libssh2.org | third-party-advisory | |
| http://www.openwall.com/lists/oss-security/2023/11/06/5 | ||
| https://github.com/rust-lang/git2-rs/security/advisories/GHSA-m4ch-rfv5-x5g3 | web | |
| https://nvd.nist.gov/vuln/detail/CVE-2023-22742 | advisory | |
| https://github.com/rust-lang/git2-rs/commit/87934f87d36753ed702792ec063be7246444a8e1 | web | |
| https://github.com/rust-lang/git2-rs | package | |
| https://rustsec.org/advisories/RUSTSEC-2023-0003.html | advisory, web | |
| https://crates.io/crates/libgit2-sys | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2023-22742 changed 2025-03-10 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-m4ch-rfv5-x5g3 changed 2026-10-14 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2023-0003 changed 2026-10-12 | CC0-1.0 |
| NVD | CVE-2023-22742 changed 2026-06-17 | Public domain |