Skip to content

Commit f1b50ec

Browse files
committed
Merge tag 'v2.35.2'
2 parents ab1f276 + 53ef17d commit f1b50ec

File tree

14 files changed

+272
-12
lines changed

14 files changed

+272
-12
lines changed

Documentation/RelNotes/2.30.3.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Git v2.30.2 Release Notes
2+
=========================
3+
4+
This release addresses the security issue CVE-2022-24765.
5+
6+
Fixes since v2.30.2
7+
-------------------
8+
9+
* Build fix on Windows.
10+
11+
* Fix `GIT_CEILING_DIRECTORIES` with Windows-style root directories.
12+
13+
* CVE-2022-24765:
14+
On multi-user machines, Git users might find themselves
15+
unexpectedly in a Git worktree, e.g. when another user created a
16+
repository in `C:\.git`, in a mounted network drive or in a
17+
scratch space. Merely having a Git-aware prompt that runs `git
18+
status` (or `git diff`) and navigating to a directory which is
19+
supposedly not a Git worktree, or opening such a directory in an
20+
editor or IDE such as VS Code or Atom, will potentially run
21+
commands defined by that other user.
22+
23+
Credit for finding this vulnerability goes to 俞晨东; The fix was
24+
authored by Johannes Schindelin.

Documentation/RelNotes/2.31.2.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.31.2 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.3 to address
5+
the security issue CVE-2022-24765; see the release notes for that
6+
version for details.

Documentation/RelNotes/2.32.1.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.32.1 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.3 and
5+
v2.31.2 to address the security issue CVE-2022-24765; see the
6+
release notes for these versions for details.

Documentation/RelNotes/2.33.2.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Git v2.33.2 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.3, v2.31.2
5+
and v2.32.1 to address the security issue CVE-2022-24765; see
6+
the release notes for these versions for details.
7+
8+
In addition, it contains the following fixes:
9+
10+
* Squelch over-eager warning message added during this cycle.
11+
12+
* A bug in "git rebase -r" has been fixed.
13+
14+
* One CI task based on Fedora image noticed a not-quite-kosher
15+
construct recently, which has been corrected.

Documentation/RelNotes/2.34.2.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.34.2 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.3, v2.31.2,
5+
v2.32.1 and v2.33.2 to address the security issue CVE-2022-24765;
6+
see the release notes for these versions for details.

Documentation/RelNotes/2.35.2.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.35.2 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.3,
5+
v2.31.2, v2.32.1, v2.33.2 and v2.34.2 to address the security
6+
issue CVE-2022-24765; see the release notes for these versions
7+
for details.

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ include::config/repack.txt[]
495495

496496
include::config/rerere.txt[]
497497

498+
include::config/safe.txt[]
499+
498500
include::config/sendemail.txt[]
499501

500502
include::config/sequencer.txt[]

Documentation/config/safe.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
safe.directory::
2+
These config entries specify Git-tracked directories that are
3+
considered safe even if they are owned by someone other than the
4+
current user. By default, Git will refuse to even parse a Git
5+
config of a repository owned by someone else, let alone run its
6+
hooks, and this config setting allows users to specify exceptions,
7+
e.g. for intentionally shared repositories (see the `--shared`
8+
option in linkgit:git-init[1]).
9+
+
10+
This is a multi-valued setting, i.e. you can add more than one directory
11+
via `git config --add`. To reset the list of safe directories (e.g. to
12+
override any such directories specified in the system config), add a
13+
`safe.directory` entry with an empty value.
14+
+
15+
This config setting is only respected when specified in a system or global
16+
config, not when it is specified in a repository config or via the command
17+
line option `-c safe.directory=<path>`.
18+
+
19+
The value of this setting is interpolated, i.e. `~/<path>` expands to a
20+
path relative to the home directory and `%(prefix)/<path>` expands to a
21+
path relative to Git's (runtime) prefix.

compat/mingw.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../git-compat-util.h"
22
#include "win32.h"
3+
#include <aclapi.h>
34
#include <conio.h>
45
#include <wchar.h>
56
#include "../strbuf.h"
@@ -2645,6 +2646,92 @@ static void setup_windows_environment(void)
26452646
}
26462647
}
26472648

2649+
static PSID get_current_user_sid(void)
2650+
{
2651+
HANDLE token;
2652+
DWORD len = 0;
2653+
PSID result = NULL;
2654+
2655+
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
2656+
return NULL;
2657+
2658+
if (!GetTokenInformation(token, TokenUser, NULL, 0, &len)) {
2659+
TOKEN_USER *info = xmalloc((size_t)len);
2660+
if (GetTokenInformation(token, TokenUser, info, len, &len)) {
2661+
len = GetLengthSid(info->User.Sid);
2662+
result = xmalloc(len);
2663+
if (!CopySid(len, result, info->User.Sid)) {
2664+
error(_("failed to copy SID (%ld)"),
2665+
GetLastError());
2666+
FREE_AND_NULL(result);
2667+
}
2668+
}
2669+
FREE_AND_NULL(info);
2670+
}
2671+
CloseHandle(token);
2672+
2673+
return result;
2674+
}
2675+
2676+
int is_path_owned_by_current_sid(const char *path)
2677+
{
2678+
WCHAR wpath[MAX_PATH];
2679+
PSID sid = NULL;
2680+
PSECURITY_DESCRIPTOR descriptor = NULL;
2681+
DWORD err;
2682+
2683+
static wchar_t home[MAX_PATH];
2684+
2685+
int result = 0;
2686+
2687+
if (xutftowcs_path(wpath, path) < 0)
2688+
return 0;
2689+
2690+
/*
2691+
* On Windows, the home directory is owned by the administrator, but for
2692+
* all practical purposes, it belongs to the user. Do pretend that it is
2693+
* owned by the user.
2694+
*/
2695+
if (!*home) {
2696+
DWORD size = ARRAY_SIZE(home);
2697+
DWORD len = GetEnvironmentVariableW(L"HOME", home, size);
2698+
if (!len || len > size)
2699+
wcscpy(home, L"::N/A::");
2700+
}
2701+
if (!wcsicmp(wpath, home))
2702+
return 1;
2703+
2704+
/* Get the owner SID */
2705+
err = GetNamedSecurityInfoW(wpath, SE_FILE_OBJECT,
2706+
OWNER_SECURITY_INFORMATION |
2707+
DACL_SECURITY_INFORMATION,
2708+
&sid, NULL, NULL, NULL, &descriptor);
2709+
2710+
if (err != ERROR_SUCCESS)
2711+
error(_("failed to get owner for '%s' (%ld)"), path, err);
2712+
else if (sid && IsValidSid(sid)) {
2713+
/* Now, verify that the SID matches the current user's */
2714+
static PSID current_user_sid;
2715+
2716+
if (!current_user_sid)
2717+
current_user_sid = get_current_user_sid();
2718+
2719+
if (current_user_sid &&
2720+
IsValidSid(current_user_sid) &&
2721+
EqualSid(sid, current_user_sid))
2722+
result = 1;
2723+
}
2724+
2725+
/*
2726+
* We can release the security descriptor struct only now because `sid`
2727+
* actually points into this struct.
2728+
*/
2729+
if (descriptor)
2730+
LocalFree(descriptor);
2731+
2732+
return result;
2733+
}
2734+
26482735
int is_valid_win32_path(const char *path, int allow_literal_nul)
26492736
{
26502737
const char *p = path;

compat/mingw.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ char *mingw_query_user_email(void);
456456
#include <inttypes.h>
457457
#endif
458458

459+
/**
460+
* Verifies that the specified path is owned by the user running the
461+
* current process.
462+
*/
463+
int is_path_owned_by_current_sid(const char *path);
464+
#define is_path_owned_by_current_user is_path_owned_by_current_sid
465+
459466
/**
460467
* Verifies that the given path is a valid one on Windows.
461468
*

0 commit comments

Comments
 (0)