HistoryEditJSON (OSV)

RUSTSEC-2023-0002

git2 Rust package suppresses ssh host key checking


This advisory has been withdrawn and should be ignored. It is kept only for reference.


Reported
Issued
Package
git2 (crates.io)
Type
Vulnerability
Categories
Keywords
#cargo #ssh #mitm
References
Patched
  • >=0.16.0

Description

By default, when accessing an ssh repository (ie via an ssh: git repository url) the git2 Rust package does not do any host key checking.

Additionally, the provided API is not sufficient for a an application to do meaningful checking itself.

Impact

When connecting to an ssh repository, and when an attacker can redirect the connection (performing a malice-in-the-middle attack) an affected application might:

Technical details

The git2 Rust package (henceforth, git2-rs) unconditionally calls the underlying C libgit2 functions to set an ssh certificate check callback. The Rust package uses this to offer the ability for the application to set a callback to a Rust function.

The C-level callback function provided by git2-rs 0.15.0 and earlier:

Resolution

Upgrade to git2-rs 0.16.x.

The default behaviour in 0.16.x is to honour libgit2's validity determination.

Note that adding this previously skipped check may cause existing setups to stop working.

Relationship to CVE-2022-46176

This bug manifested in cargo where it was assigned CVE-2022-46176.

The same bug exists in other applications which use affected versions of git2-rs unless they never try to access git repositories with ssh: urls.

Advisory available under CC0-1.0 license.