File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -255,4 +255,27 @@ fn init_git_transports(config: &Config) {
255
255
unsafe {
256
256
git2_curl:: register ( handle) ;
257
257
}
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
+ }
258
281
}
You can’t perform that action at this time.
0 commit comments