Skip to content

Commit 2d2fc8c

Browse files
committed
Merge tag 'v2.35.5' into HEAD
Git 2.35.5
2 parents 9a2f22d + 868154b commit 2d2fc8c

File tree

68 files changed

+307
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+307
-61
lines changed

Documentation/RelNotes/2.30.6.txt

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Git v2.30.6 Release Notes
2+
=========================
3+
4+
This release addresses the security issues CVE-2022-39253 and
5+
CVE-2022-39260.
6+
7+
Fixes since v2.30.5
8+
-------------------
9+
10+
* CVE-2022-39253:
11+
When relying on the `--local` clone optimization, Git dereferences
12+
symbolic links in the source repository before creating hardlinks
13+
(or copies) of the dereferenced link in the destination repository.
14+
This can lead to surprising behavior where arbitrary files are
15+
present in a repository's `$GIT_DIR` when cloning from a malicious
16+
repository.
17+
18+
Git will no longer dereference symbolic links via the `--local`
19+
clone mechanism, and will instead refuse to clone repositories that
20+
have symbolic links present in the `$GIT_DIR/objects` directory.
21+
22+
Additionally, the value of `protocol.file.allow` is changed to be
23+
"user" by default.
24+
25+
* CVE-2022-39260:
26+
An overly-long command string given to `git shell` can result in
27+
overflow in `split_cmdline()`, leading to arbitrary heap writes and
28+
remote code execution when `git shell` is exposed and the directory
29+
`$HOME/git-shell-commands` exists.
30+
31+
`git shell` is taught to refuse interactive commands that are
32+
longer than 4MiB in size. `split_cmdline()` is hardened to reject
33+
inputs larger than 2GiB.
34+
35+
Credit for finding CVE-2022-39253 goes to Cory Snider of Mirantis. The
36+
fix was authored by Taylor Blau, with help from Johannes Schindelin.
37+
38+
Credit for finding CVE-2022-39260 goes to Kevin Backhouse of GitHub.
39+
The fix was authored by Kevin Backhouse, Jeff King, and Taylor Blau.
40+
41+
42+
Jeff King (2):
43+
shell: add basic tests
44+
shell: limit size of interactive commands
45+
46+
Kevin Backhouse (1):
47+
alias.c: reject too-long cmdline strings in split_cmdline()
48+
49+
Taylor Blau (11):
50+
builtin/clone.c: disallow `--local` clones with symlinks
51+
t/lib-submodule-update.sh: allow local submodules
52+
t/t1NNN: allow local submodules
53+
t/2NNNN: allow local submodules
54+
t/t3NNN: allow local submodules
55+
t/t4NNN: allow local submodules
56+
t/t5NNN: allow local submodules
57+
t/t6NNN: allow local submodules
58+
t/t7NNN: allow local submodules
59+
t/t9NNN: allow local submodules
60+
transport: make `protocol.file.allow` be "user" by default

Documentation/RelNotes/2.31.5.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.31.5 Release Notes
2+
=========================
3+
4+
This release merges the security fix that appears in v2.30.6; see
5+
the release notes for that version for details.

Documentation/RelNotes/2.32.4.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.32.4 Release Notes
2+
=========================
3+
4+
This release merges the security fix that appears in v2.30.6; see
5+
the release notes for that version for details.

Documentation/RelNotes/2.33.5.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.33.5 Release Notes
2+
=========================
3+
4+
This release merges the security fix that appears in v2.30.6; see
5+
the release notes for that version for details.

Documentation/RelNotes/2.34.5.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.34.5 Release Notes
2+
=========================
3+
4+
This release merges the security fix that appears in v2.30.6; see
5+
the release notes for that version for details.

Documentation/RelNotes/2.35.5.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Git v2.35.5 Release Notes
2+
=========================
3+
4+
This release merges the security fix that appears in v2.30.6; see
5+
the release notes for that version for details.

Documentation/config/protocol.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
protocol.allow::
22
If set, provide a user defined default policy for all protocols which
33
don't explicitly have a policy (`protocol.<name>.allow`). By default,
4-
if unset, known-safe protocols (http, https, git, ssh, file) have a
4+
if unset, known-safe protocols (http, https, git, ssh) have a
55
default policy of `always`, known-dangerous protocols (ext) have a
6-
default policy of `never`, and all other protocols have a default
7-
policy of `user`. Supported policies:
6+
default policy of `never`, and all other protocols (including file)
7+
have a default policy of `user`. Supported policies:
88
+
99
--
1010

GIT-VERSION-GEN

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
GVF=GIT-VERSION-FILE
4-
DEF_VER=v2.35.4
4+
DEF_VER=v2.35.5
55

66
LF='
77
'

RelNotes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Documentation/RelNotes/2.35.4.txt
1+
Documentation/RelNotes/2.35.5.txt

alias.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ void list_aliases(struct string_list *list)
4646

4747
#define SPLIT_CMDLINE_BAD_ENDING 1
4848
#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
49+
#define SPLIT_CMDLINE_ARGC_OVERFLOW 3
4950
static const char *split_cmdline_errors[] = {
5051
N_("cmdline ends with \\"),
51-
N_("unclosed quote")
52+
N_("unclosed quote"),
53+
N_("too many arguments"),
5254
};
5355

5456
int split_cmdline(char *cmdline, const char ***argv)
5557
{
56-
int src, dst, count = 0, size = 16;
58+
size_t src, dst, count = 0, size = 16;
5759
char quoted = 0;
5860

5961
ALLOC_ARRAY(*argv, size);
@@ -96,6 +98,11 @@ int split_cmdline(char *cmdline, const char ***argv)
9698
return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
9799
}
98100

101+
if (count >= INT_MAX) {
102+
FREE_AND_NULL(*argv);
103+
return -SPLIT_CMDLINE_ARGC_OVERFLOW;
104+
}
105+
99106
ALLOC_GROW(*argv, count + 1, size);
100107
(*argv)[count] = NULL;
101108

builtin/clone.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,11 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
310310
int src_len, dest_len;
311311
struct dir_iterator *iter;
312312
int iter_status;
313-
unsigned int flags;
314313
struct strbuf realpath = STRBUF_INIT;
315314

316315
mkdir_if_missing(dest->buf, 0777);
317316

318-
flags = DIR_ITERATOR_PEDANTIC | DIR_ITERATOR_FOLLOW_SYMLINKS;
319-
iter = dir_iterator_begin(src->buf, flags);
317+
iter = dir_iterator_begin(src->buf, DIR_ITERATOR_PEDANTIC);
320318

321319
if (!iter)
322320
die_errno(_("failed to start iterator over '%s'"), src->buf);
@@ -332,6 +330,10 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
332330
strbuf_setlen(dest, dest_len);
333331
strbuf_addstr(dest, iter->relative_path);
334332

333+
if (S_ISLNK(iter->st.st_mode))
334+
die(_("symlink '%s' exists, refusing to clone with --local"),
335+
iter->relative_path);
336+
335337
if (S_ISDIR(iter->st.st_mode)) {
336338
mkdir_if_missing(dest->buf, 0777);
337339
continue;

shell.c

+30-4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ static void cd_to_homedir(void)
4747
die("could not chdir to user's home directory");
4848
}
4949

50+
#define MAX_INTERACTIVE_COMMAND (4*1024*1024)
51+
5052
static void run_shell(void)
5153
{
5254
int done = 0;
@@ -67,22 +69,46 @@ static void run_shell(void)
6769
run_command_v_opt(help_argv, RUN_SILENT_EXEC_FAILURE);
6870

6971
do {
70-
struct strbuf line = STRBUF_INIT;
7172
const char *prog;
7273
char *full_cmd;
7374
char *rawargs;
75+
size_t len;
7476
char *split_args;
7577
const char **argv;
7678
int code;
7779
int count;
7880

7981
fprintf(stderr, "git> ");
80-
if (git_read_line_interactively(&line) == EOF) {
82+
83+
/*
84+
* Avoid using a strbuf or git_read_line_interactively() here.
85+
* We don't want to allocate arbitrary amounts of memory on
86+
* behalf of a possibly untrusted client, and we're subject to
87+
* OS limits on command length anyway.
88+
*/
89+
fflush(stdout);
90+
rawargs = xmalloc(MAX_INTERACTIVE_COMMAND);
91+
if (!fgets(rawargs, MAX_INTERACTIVE_COMMAND, stdin)) {
8192
fprintf(stderr, "\n");
82-
strbuf_release(&line);
93+
free(rawargs);
8394
break;
8495
}
85-
rawargs = strbuf_detach(&line, NULL);
96+
len = strlen(rawargs);
97+
98+
/*
99+
* If we truncated due to our input buffer size, reject the
100+
* command. That's better than running bogus input, and
101+
* there's a good chance it's just malicious garbage anyway.
102+
*/
103+
if (len >= MAX_INTERACTIVE_COMMAND - 1)
104+
die("invalid command format: input too long");
105+
106+
if (len > 0 && rawargs[len - 1] == '\n') {
107+
if (--len > 0 && rawargs[len - 1] == '\r')
108+
--len;
109+
rawargs[len] = '\0';
110+
}
111+
86112
split_args = xstrdup(rawargs);
87113
count = split_cmdline(split_args, &argv);
88114
if (count < 0) {

t/lib-submodule-update.sh

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ test_git_directory_exists () {
197197
# the submodule repo if it doesn't exist and configures the most problematic
198198
# settings for diff.ignoreSubmodules.
199199
prolog () {
200+
test_config_global protocol.file.allow always &&
200201
(test -d submodule_update_repo || create_lib_submodule_repo) &&
201202
test_config_global diff.ignoreSubmodules all &&
202203
test_config diff.ignoreSubmodules all

t/t1091-sparse-checkout-builtin.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ test_expect_success 'interaction with submodules' '
509509
(
510510
cd super &&
511511
mkdir modules &&
512-
git submodule add ../repo modules/child &&
512+
git -c protocol.file.allow=always \
513+
submodule add ../repo modules/child &&
513514
git add . &&
514515
git commit -m "add submodule" &&
515516
git sparse-checkout init --cone &&

t/t1092-sparse-checkout-compatibility.sh

+2
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,8 @@ test_expect_success 'submodule handling' '
793793
test_all_match git add modules &&
794794
test_all_match git commit -m "add modules directory" &&
795795
796+
test_config_global protocol.file.allow always &&
797+
796798
run_on_all git submodule add "$(pwd)/initial-repo" modules/sub &&
797799
test_all_match git commit -m "add submodule" &&
798800

t/t1500-rev-parse.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ test_expect_success 'showing the superproject correctly' '
225225
test_commit -C super test_commit &&
226226
test_create_repo sub &&
227227
test_commit -C sub test_commit &&
228-
git -C super submodule add ../sub dir/sub &&
228+
git -c protocol.file.allow=always \
229+
-C super submodule add ../sub dir/sub &&
229230
echo $(pwd)/super >expect &&
230231
git -C super/dir/sub rev-parse --show-superproject-working-tree >out &&
231232
test_cmp expect out &&

t/t2080-parallel-checkout-basics.sh

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ TEST_NO_CREATE_REPO=1
4141
# - m/m (file)
4242
#
4343
test_expect_success 'setup repo for checkout with various types of changes' '
44+
test_config_global protocol.file.allow always &&
45+
4446
git init sub &&
4547
(
4648
cd sub &&
@@ -140,6 +142,7 @@ do
140142
esac
141143

142144
test_expect_success "$mode checkout on clone" '
145+
test_config_global protocol.file.allow always &&
143146
repo=various_${mode}_clone &&
144147
set_checkout_config $workers $threshold &&
145148
test_checkout_workers $expected_workers \

t/t2400-worktree-add.sh

+2
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ test_expect_success '"add" should not fail because of another bad worktree' '
614614
'
615615

616616
test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' '
617+
test_config_global protocol.file.allow always &&
617618
test_create_repo submodule &&
618619
test_commit -C submodule first &&
619620
test_create_repo project &&
@@ -629,6 +630,7 @@ test_expect_success '"add" with uninitialized submodule, with submodule.recurse
629630
'
630631

631632
test_expect_success '"add" with initialized submodule, with submodule.recurse unset' '
633+
test_config_global protocol.file.allow always &&
632634
git -C project-clone submodule update --init &&
633635
git -C project-clone worktree add ../project-4
634636
'

t/t2403-worktree-move.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ test_expect_success 'move a repo with uninitialized submodule' '
138138
(
139139
cd withsub &&
140140
test_commit initial &&
141-
git submodule add "$PWD"/.git sub &&
141+
git -c protocol.file.allow=always \
142+
submodule add "$PWD"/.git sub &&
142143
git commit -m withsub &&
143144
git worktree add second HEAD &&
144145
git worktree move second third
@@ -148,7 +149,7 @@ test_expect_success 'move a repo with uninitialized submodule' '
148149
test_expect_success 'not move a repo with initialized submodule' '
149150
(
150151
cd withsub &&
151-
git -C third submodule update &&
152+
git -c protocol.file.allow=always -C third submodule update &&
152153
test_must_fail git worktree move third forth
153154
)
154155
'
@@ -227,6 +228,7 @@ test_expect_success 'remove cleans up .git/worktrees when empty' '
227228
'
228229

229230
test_expect_success 'remove a repo with uninitialized submodule' '
231+
test_config_global protocol.file.allow always &&
230232
(
231233
cd withsub &&
232234
git worktree add to-remove HEAD &&
@@ -235,6 +237,7 @@ test_expect_success 'remove a repo with uninitialized submodule' '
235237
'
236238

237239
test_expect_success 'not remove a repo with initialized submodule' '
240+
test_config_global protocol.file.allow always &&
238241
(
239242
cd withsub &&
240243
git worktree add to-remove HEAD &&

t/t2405-worktree-submodule.sh

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010
base_path=$(pwd -P)
1111

1212
test_expect_success 'setup: create origin repos' '
13+
git config --global protocol.file.allow always &&
1314
git init origin/sub &&
1415
test_commit -C origin/sub file1 &&
1516
git init origin/main &&

t/t3200-branch.sh

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ test_expect_success 'deleting checked-out branch from repo that is a submodule'
289289
git init repo1 &&
290290
git init repo1/sub &&
291291
test_commit -C repo1/sub x &&
292+
test_config_global protocol.file.allow always &&
292293
git -C repo1 submodule add ./sub &&
293294
git -C repo1 commit -m "adding sub" &&
294295

t/t3420-rebase-autostash.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ test_expect_success 'autostash is saved on editor failure with conflict' '
310310
test_expect_success 'autostash with dirty submodules' '
311311
test_when_finished "git reset --hard && git checkout main" &&
312312
git checkout -b with-submodule &&
313-
git submodule add ./ sub &&
313+
git -c protocol.file.allow=always submodule add ./ sub &&
314314
test_tick &&
315315
git commit -m add-submodule &&
316316
echo changed >sub/file0 &&

t/t3426-rebase-submodule.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ test_expect_success 'rebase interactive ignores modified submodules' '
4747
git init sub &&
4848
git -C sub commit --allow-empty -m "Initial commit" &&
4949
git init super &&
50-
git -C super submodule add ../sub &&
50+
git -c protocol.file.allow=always \
51+
-C super submodule add ../sub &&
5152
git -C super config submodule.sub.ignore dirty &&
5253
>super/foo &&
5354
git -C super add foo &&

t/t3512-cherry-pick-submodule.sh

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ fi
1616
test_submodule_switch "cherry-pick"
1717

1818
test_expect_success 'unrelated submodule/file conflict is ignored' '
19+
test_config_global protocol.file.allow always &&
20+
1921
test_create_repo sub &&
2022
2123
touch sub/file &&

0 commit comments

Comments
 (0)