Skip to content

Commit 222e0e5

Browse files
author
Jon Gjengset
committed
Disable owner validation for Cargo-as-a-binary
1 parent 30fe22b commit 222e0e5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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)