Skip to content

Commit

Permalink
Merge tag 'v2.39.2.windows.1' into vfs-2.39.2
Browse files Browse the repository at this point in the history
Git for Windows v2.39.2

Creating /dev/shm directory failed.
POSIX semaphores and POSIX shared memory will not work

Creating /dev/mqueue directory failed.
POSIX message queues will not work

'C:\Windows\system32\drivers\etc\hosts' -> '/etc/hosts'
'C:\Windows\system32\drivers\etc\protocol' -> '/etc/protocols'
'C:\Windows\system32\drivers\etc\services' -> '/etc/services'
'C:\Windows\system32\drivers\etc\networks' -> '/etc/networks'

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
  • Loading branch information
derrickstolee committed Feb 14, 2023
2 parents 01f2b6e + a82fa99 commit e7fd49f
Show file tree
Hide file tree
Showing 22 changed files with 489 additions and 12 deletions.
52 changes: 52 additions & 0 deletions Documentation/RelNotes/2.30.8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Git v2.30.8 Release Notes
=========================

This release addresses the security issues CVE-2023-22490 and
CVE-2023-23946.


Fixes since v2.30.7
-------------------

* CVE-2023-22490:

Using a specially-crafted repository, Git can be tricked into using
its local clone optimization even when using a non-local transport.
Though Git will abort local clones whose source $GIT_DIR/objects
directory contains symbolic links (c.f., CVE-2022-39253), the objects
directory itself may still be a symbolic link.

These two may be combined to include arbitrary files based on known
paths on the victim's filesystem within the malicious repository's
working copy, allowing for data exfiltration in a similar manner as
CVE-2022-39253.

* CVE-2023-23946:

By feeding a crafted input to "git apply", a path outside the
working tree can be overwritten as the user who is running "git
apply".

* A mismatched type in `attr.c::read_attr_from_index()` which could
cause Git to errantly reject attributes on Windows and 32-bit Linux
has been corrected.

Credit for finding CVE-2023-22490 goes to yvvdwf, and the fix was
developed by Taylor Blau, with additional help from others on the
Git security mailing list.

Credit for finding CVE-2023-23946 goes to Joern Schneeweisz, and the
fix was developed by Patrick Steinhardt.


Johannes Schindelin (1):
attr: adjust a mismatched data type

Patrick Steinhardt (1):
apply: fix writing behind newly created symbolic links

Taylor Blau (3):
t5619: demonstrate clone_local() with ambiguous transport
clone: delay picking a transport until after get_repo_path()
dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS

6 changes: 6 additions & 0 deletions Documentation/RelNotes/2.31.7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Git v2.31.7 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8 to
address the security issues CVE-2023-22490 and CVE-2023-23946;
see the release notes for that version for details.
6 changes: 6 additions & 0 deletions Documentation/RelNotes/2.32.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Git v2.32.6 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8 and v2.31.7
to address the security issues CVE-2023-22490 and CVE-2023-23946;
see the release notes for these versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.33.7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.33.7 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7
and v2.32.6 to address the security issues CVE-2023-22490 and
CVE-2023-23946; see the release notes for these versions for
details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.34.7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.34.7 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7,
v2.32.6 and v2.33.7 to address the security issues CVE-2023-22490
and CVE-2023-23946; see the release notes for these versions
for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.35.7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.35.7 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7,
v2.32.6, v2.33.7 and v2.34.7 to address the security issues
CVE-2023-22490 and CVE-2023-23946; see the release notes for
these versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.36.5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.36.5 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7,
v2.32.6, v2.33.7, v2.34.7 and v2.35.7 to address the security
issues CVE-2023-22490 and CVE-2023-23946; see the release notes
for these versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.37.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.37.6 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7,
v2.32.6, v2.33.7, v2.34.7, v2.35.7 and v2.36.5 to address the
security issues CVE-2023-22490 and CVE-2023-23946; see the release
notes for these versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.38.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.38.4 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7,
v2.32.6, v2.33.7, v2.34.7, v2.35.7, v2.36.5 and v2.37.6 to
address the security issues CVE-2023-22490 and CVE-2023-23946;
see the release notes for these versions for details.
7 changes: 7 additions & 0 deletions Documentation/RelNotes/2.39.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Git v2.39.2 Release Notes
=========================

This release merges up the fixes that appear in v2.30.8, v2.31.7,
v2.32.6, v2.33.7, v2.34.7, v2.35.7, v2.36.5, v2.37.6 and v2.38.4
to address the security issues CVE-2023-22490 and CVE-2023-23946;
see the release notes for these versions for details.
2 changes: 1 addition & 1 deletion GIT-VERSION-GEN
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

GVF=GIT-VERSION-FILE
DEF_VER=v2.39.1.vfs.0.0
DEF_VER=v2.39.2.vfs.0.0

LF='
'
Expand Down
2 changes: 1 addition & 1 deletion RelNotes
27 changes: 27 additions & 0 deletions apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -4436,6 +4436,33 @@ static int create_one_file(struct apply_state *state,
if (state->cached)
return 0;

/*
* We already try to detect whether files are beyond a symlink in our
* up-front checks. But in the case where symlinks are created by any
* of the intermediate hunks it can happen that our up-front checks
* didn't yet see the symlink, but at the point of arriving here there
* in fact is one. We thus repeat the check for symlinks here.
*
* Note that this does not make the up-front check obsolete as the
* failure mode is different:
*
* - The up-front checks cause us to abort before we have written
* anything into the working directory. So when we exit this way the
* working directory remains clean.
*
* - The checks here happen in the middle of the action where we have
* already started to apply the patch. The end result will be a dirty
* working directory.
*
* Ideally, we should update the up-front checks to catch what would
* happen when we apply the patch before we damage the working tree.
* We have all the information necessary to do so. But for now, as a
* part of embargoed security work, having this check would serve as a
* reasonable first step.
*/
if (path_is_beyond_symlink(state, path))
return error(_("affected file '%s' is beyond a symbolic link"), path);

res = try_create_file(state, path, mode, buf, size);
if (res < 0)
return -1;
Expand Down
8 changes: 4 additions & 4 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,10 +1170,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
refspec_appendf(&remote->fetch, "+%s*:%s*", src_ref_prefix,
branch_top.buf);

transport = transport_get(remote, remote->url[0]);
transport_set_verbosity(transport, option_verbosity, option_progress);
transport->family = family;

path = get_repo_path(remote->url[0], &is_bundle);
is_local = option_local != 0 && path && !is_bundle;
if (is_local) {
Expand All @@ -1195,6 +1191,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
if (option_local > 0 && !is_local)
warning(_("--local is ignored"));

transport = transport_get(remote, path ? path : remote->url[0]);
transport_set_verbosity(transport, option_verbosity, option_progress);
transport->family = family;
transport->cloning = 1;

if (is_bundle) {
Expand Down
13 changes: 9 additions & 4 deletions dir-iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct dir_iterator *dir_iterator_begin(const char *path, unsigned int flags)
{
struct dir_iterator_int *iter = xcalloc(1, sizeof(*iter));
struct dir_iterator *dir_iterator = &iter->base;
int saved_errno;
int saved_errno, err;

strbuf_init(&iter->base.path, PATH_MAX);
strbuf_addstr(&iter->base.path, path);
Expand All @@ -213,10 +213,15 @@ struct dir_iterator *dir_iterator_begin(const char *path, unsigned int flags)
iter->flags = flags;

/*
* Note: stat already checks for NULL or empty strings and
* inexistent paths.
* Note: stat/lstat already checks for NULL or empty strings and
* nonexistent paths.
*/
if (stat(iter->base.path.buf, &iter->base.st) < 0) {
if (iter->flags & DIR_ITERATOR_FOLLOW_SYMLINKS)
err = stat(iter->base.path.buf, &iter->base.st);
else
err = lstat(iter->base.path.buf, &iter->base.st);

if (err < 0) {
saved_errno = errno;
goto error_out;
}
Expand Down
5 changes: 5 additions & 0 deletions dir-iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
* not the symlinks themselves, which is the default behavior. Broken
* symlinks are ignored.
*
* Note: setting DIR_ITERATOR_FOLLOW_SYMLINKS affects resolving the
* starting path as well (e.g., attempting to iterate starting at a
* symbolic link pointing to a directory without FOLLOW_SYMLINKS will
* result in an error).
*
* Warning: circular symlinks are also followed when
* DIR_ITERATOR_FOLLOW_SYMLINKS is set. The iteration may end up with
* an ELOOP if they happen and DIR_ITERATOR_PEDANTIC is set.
Expand Down
2 changes: 1 addition & 1 deletion git-curl-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
#endif

/*
/**
* CURLSSLOPT_AUTO_CLIENT_CERT was added in 7.77.0, released in May
* 2021.
*/
Expand Down
135 changes: 135 additions & 0 deletions gitk-git/gitk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,141 @@ exec wish "$0" -- "$@"

package require Tk

######################################################################
##
## Enabling platform-specific code paths

proc is_MacOSX {} {
if {[tk windowingsystem] eq {aqua}} {
return 1
}
return 0
}

proc is_Windows {} {
if {$::tcl_platform(platform) eq {windows}} {
return 1
}
return 0
}

set _iscygwin {}
proc is_Cygwin {} {
global _iscygwin
if {$_iscygwin eq {}} {
if {[string match "CYGWIN_*" $::tcl_platform(os)]} {
set _iscygwin 1
} else {
set _iscygwin 0
}
}
return $_iscygwin
}

######################################################################
##
## PATH lookup

set _search_path {}
proc _which {what args} {
global env _search_exe _search_path

if {$_search_path eq {}} {
if {[is_Cygwin] && [regexp {^(/|\.:)} $env(PATH)]} {
set _search_path [split [exec cygpath \
--windows \
--path \
--absolute \
$env(PATH)] {;}]
set _search_exe .exe
} elseif {[is_Windows]} {
set gitguidir [file dirname [info script]]
regsub -all ";" $gitguidir "\\;" gitguidir
set env(PATH) "$gitguidir;$env(PATH)"
set _search_path [split $env(PATH) {;}]
# Skip empty `PATH` elements
set _search_path [lsearch -all -inline -not -exact \
$_search_path ""]
set _search_exe .exe
} else {
set _search_path [split $env(PATH) :]
set _search_exe {}
}
}
if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
set suffix {}
} else {
set suffix $_search_exe
}
foreach p $_search_path {
set p [file join $p $what$suffix]
if {[file exists $p]} {
return [file normalize $p]
}
}
return {}
}
proc sanitize_command_line {command_line from_index} {
set i $from_index
while {$i < [llength $command_line]} {
set cmd [lindex $command_line $i]
if {[file pathtype $cmd] ne "absolute"} {
set fullpath [_which $cmd]
if {$fullpath eq ""} {
throw {NOT-FOUND} "$cmd not found in PATH"
}
lset command_line $i $fullpath
}
# handle piped commands, e.g. `exec A | B`
for {incr i} {$i < [llength $command_line]} {incr i} {
if {[lindex $command_line $i] eq "|"} {
incr i
break
}
}
}
return $command_line
}
# Override `exec` to avoid unsafe PATH lookup
rename exec real_exec
proc exec {args} {
# skip options
for {set i 0} {$i < [llength $args]} {incr i} {
set arg [lindex $args $i]
if {$arg eq "--"} {
incr i
break
}
if {[string range $arg 0 0] ne "-"} {
break
}
}
set args [sanitize_command_line $args $i]
uplevel 1 real_exec $args
}
# Override `open` to avoid unsafe PATH lookup
rename open real_open
proc open {args} {
set arg0 [lindex $args 0]
if {[string range $arg0 0 0] eq "|"} {
set command_line [string trim [string range $arg0 1 end]]
lset args 0 "| [sanitize_command_line $command_line 0]"
}
uplevel 1 real_open $args
}
# End of safe PATH lookup stuff
proc hasworktree {} {
return [expr {[exec git rev-parse --is-bare-repository] == "false" &&
[exec git rev-parse --is-inside-git-dir] == "false"}]
Expand Down
Loading

0 comments on commit e7fd49f

Please sign in to comment.