Skip to content

Commit e5ec3a8

Browse files
committed
Auto merge of #11004 - jonhoo:bump-git2, r=weihanglo
Bump git2 to 0.15 and libgit2-sys to 0.14 This will allow cargo to avoid vendored builds of git2 in up-to-date environments going forward, and brings in the [libgit2 1.4.4 CVE fix]. [libgit2 1.4.4 CVE fix]: https://github.com/libgit2/libgit2/releases/tag/v1.4.4
2 parents bcf18e5 + 222e0e5 commit e5ec3a8

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pretty_env_logger = { version = "0.4", optional = true }
2828
anyhow = "1.0"
2929
filetime = "0.2.9"
3030
flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] }
31-
git2 = "0.14.2"
32-
git2-curl = "0.15.0"
31+
git2 = "0.15.0"
32+
git2-curl = "0.16.0"
3333
glob = "0.3.0"
3434
hex = "0.4"
3535
home = "0.5"
@@ -41,7 +41,7 @@ jobserver = "0.1.24"
4141
lazycell = "1.2.0"
4242
libc = "0.2"
4343
log = "0.4.6"
44-
libgit2-sys = "0.13.2"
44+
libgit2-sys = "0.14.0"
4545
memchr = "2.1.3"
4646
opener = "0.5"
4747
os_info = "3.5.0"

crates/cargo-test-support/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cargo-util = { path = "../cargo-util" }
1414
snapbox = { version = "0.3.0", features = ["diff", "path"] }
1515
filetime = "0.2"
1616
flate2 = { version = "1.0", default-features = false, features = ["zlib"] }
17-
git2 = "0.14.2"
17+
git2 = "0.15.0"
1818
glob = "0.3"
1919
itertools = "0.10.0"
2020
lazy_static = "1.0"

src/bin/cargo/main.rs

+23
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,27 @@ fn init_git_transports(config: &Config) {
255255
unsafe {
256256
git2_curl::register(handle);
257257
}
258+
259+
// Disabling the owner validation in git can, in theory, lead to code execution
260+
// vulnerabilities. However, libgit2 does not launch executables, which is the foundation of
261+
// the original security issue. Meanwhile, issues with refusing to load git repos in
262+
// `CARGO_HOME` for example will likely be very frustrating for users. So, we disable the
263+
// validation.
264+
//
265+
// For further discussion of Cargo's current interactions with git, see
266+
//
267+
// https://github.com/rust-lang/rfcs/pull/3279
268+
//
269+
// and in particular the subsection on "Git support".
270+
//
271+
// Note that we only disable this when Cargo is run as a binary. If Cargo is used as a library,
272+
// this code won't be invoked. Instead, developers will need to explicitly disable the
273+
// validation in their code. This is inconvenient, but won't accidentally open consuming
274+
// applications up to security issues if they use git2 to open repositories elsewhere in their
275+
// code.
276+
unsafe {
277+
if git2::opts::set_verify_owner_validation(false).is_err() {
278+
return;
279+
}
280+
}
258281
}

0 commit comments

Comments
 (0)