Skip to content

Commit 6a53a59

Browse files
committed
Sync with 2.34.7
* maint-2.34: Git 2.34.7 http: support CURLOPT_PROTOCOLS_STR http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT Git 2.33.7 Git 2.32.6 Git 2.31.7 Git 2.30.8 apply: fix writing behind newly created symbolic links dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS clone: delay picking a transport until after get_repo_path() t5619: demonstrate clone_local() with ambiguous transport
2 parents c508c30 + 91da4a2 commit 6a53a59

19 files changed

+397
-53
lines changed

Documentation/RelNotes/2.30.8.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Git v2.30.8 Release Notes
2+
=========================
3+
4+
This release addresses the security issues CVE-2023-22490 and
5+
CVE-2023-23946.
6+
7+
8+
Fixes since v2.30.7
9+
-------------------
10+
11+
* CVE-2023-22490:
12+
13+
Using a specially-crafted repository, Git can be tricked into using
14+
its local clone optimization even when using a non-local transport.
15+
Though Git will abort local clones whose source $GIT_DIR/objects
16+
directory contains symbolic links (c.f., CVE-2022-39253), the objects
17+
directory itself may still be a symbolic link.
18+
19+
These two may be combined to include arbitrary files based on known
20+
paths on the victim's filesystem within the malicious repository's
21+
working copy, allowing for data exfiltration in a similar manner as
22+
CVE-2022-39253.
23+
24+
* CVE-2023-23946:
25+
26+
By feeding a crafted input to "git apply", a path outside the
27+
working tree can be overwritten as the user who is running "git
28+
apply".
29+
30+
* A mismatched type in `attr.c::read_attr_from_index()` which could
31+
cause Git to errantly reject attributes on Windows and 32-bit Linux
32+
has been corrected.
33+
34+
Credit for finding CVE-2023-22490 goes to yvvdwf, and the fix was
35+
developed by Taylor Blau, with additional help from others on the
36+
Git security mailing list.
37+
38+
Credit for finding CVE-2023-23946 goes to Joern Schneeweisz, and the
39+
fix was developed by Patrick Steinhardt.
40+
41+
42+
Johannes Schindelin (1):
43+
attr: adjust a mismatched data type
44+
45+
Patrick Steinhardt (1):
46+
apply: fix writing behind newly created symbolic links
47+
48+
Taylor Blau (3):
49+
t5619: demonstrate clone_local() with ambiguous transport
50+
clone: delay picking a transport until after get_repo_path()
51+
dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
52+

Documentation/RelNotes/2.31.7.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.31.7 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.8 to
5+
address the security issues CVE-2023-22490 and CVE-2023-23946;
6+
see the release notes for that version for details.

Documentation/RelNotes/2.32.6.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.32.6 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.8 and v2.31.7
5+
to address the security issues CVE-2023-22490 and CVE-2023-23946;
6+
see the release notes for these versions for details.

Documentation/RelNotes/2.33.7.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.33.7 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.8, v2.31.7
5+
and v2.32.6 to address the security issues CVE-2023-22490 and
6+
CVE-2023-23946; see the release notes for these versions for
7+
details.

Documentation/RelNotes/2.34.7.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.34.7 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.8, v2.31.7,
5+
v2.32.6 and v2.33.7 to address the security issues CVE-2023-22490
6+
and CVE-2023-23946; see the release notes for these versions
7+
for details.

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Issues of note:
144144
not need that functionality, use NO_CURL to build without
145145
it.
146146

147-
Git requires version "7.19.4" or later of "libcurl" to build
147+
Git requires version "7.19.5" or later of "libcurl" to build
148148
without NO_CURL. This version requirement may be bumped in
149149
the future.
150150

apply.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4426,6 +4426,33 @@ static int create_one_file(struct apply_state *state,
44264426
if (state->cached)
44274427
return 0;
44284428

4429+
/*
4430+
* We already try to detect whether files are beyond a symlink in our
4431+
* up-front checks. But in the case where symlinks are created by any
4432+
* of the intermediate hunks it can happen that our up-front checks
4433+
* didn't yet see the symlink, but at the point of arriving here there
4434+
* in fact is one. We thus repeat the check for symlinks here.
4435+
*
4436+
* Note that this does not make the up-front check obsolete as the
4437+
* failure mode is different:
4438+
*
4439+
* - The up-front checks cause us to abort before we have written
4440+
* anything into the working directory. So when we exit this way the
4441+
* working directory remains clean.
4442+
*
4443+
* - The checks here happen in the middle of the action where we have
4444+
* already started to apply the patch. The end result will be a dirty
4445+
* working directory.
4446+
*
4447+
* Ideally, we should update the up-front checks to catch what would
4448+
* happen when we apply the patch before we damage the working tree.
4449+
* We have all the information necessary to do so. But for now, as a
4450+
* part of embargoed security work, having this check would serve as a
4451+
* reasonable first step.
4452+
*/
4453+
if (path_is_beyond_symlink(state, path))
4454+
return error(_("affected file '%s' is beyond a symbolic link"), path);
4455+
44294456
res = try_create_file(state, path, mode, buf, size);
44304457
if (res < 0)
44314458
return -1;

builtin/clone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,10 +1112,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11121112
refspec_appendf(&remote->fetch, "+%s*:%s*", src_ref_prefix,
11131113
branch_top.buf);
11141114

1115-
transport = transport_get(remote, remote->url[0]);
1116-
transport_set_verbosity(transport, option_verbosity, option_progress);
1117-
transport->family = family;
1118-
11191115
path = get_repo_path(remote->url[0], &is_bundle);
11201116
is_local = option_local != 0 && path && !is_bundle;
11211117
if (is_local) {
@@ -1137,6 +1133,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11371133
}
11381134
if (option_local > 0 && !is_local)
11391135
warning(_("--local is ignored"));
1136+
1137+
transport = transport_get(remote, path ? path : remote->url[0]);
1138+
transport_set_verbosity(transport, option_verbosity, option_progress);
1139+
transport->family = family;
11401140
transport->cloning = 1;
11411141

11421142
transport_set_option(transport, TRANS_OPT_KEEP, "yes");

dir-iterator.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct dir_iterator *dir_iterator_begin(const char *path, unsigned int flags)
203203
{
204204
struct dir_iterator_int *iter = xcalloc(1, sizeof(*iter));
205205
struct dir_iterator *dir_iterator = &iter->base;
206-
int saved_errno;
206+
int saved_errno, err;
207207

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

215215
/*
216-
* Note: stat already checks for NULL or empty strings and
217-
* inexistent paths.
216+
* Note: stat/lstat already checks for NULL or empty strings and
217+
* nonexistent paths.
218218
*/
219-
if (stat(iter->base.path.buf, &iter->base.st) < 0) {
219+
if (iter->flags & DIR_ITERATOR_FOLLOW_SYMLINKS)
220+
err = stat(iter->base.path.buf, &iter->base.st);
221+
else
222+
err = lstat(iter->base.path.buf, &iter->base.st);
223+
224+
if (err < 0) {
220225
saved_errno = errno;
221226
goto error_out;
222227
}

dir-iterator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
* not the symlinks themselves, which is the default behavior. Broken
6262
* symlinks are ignored.
6363
*
64+
* Note: setting DIR_ITERATOR_FOLLOW_SYMLINKS affects resolving the
65+
* starting path as well (e.g., attempting to iterate starting at a
66+
* symbolic link pointing to a directory without FOLLOW_SYMLINKS will
67+
* result in an error).
68+
*
6469
* Warning: circular symlinks are also followed when
6570
* DIR_ITERATOR_FOLLOW_SYMLINKS is set. The iteration may end up with
6671
* an ELOOP if they happen and DIR_ITERATOR_PEDANTIC is set.

git-curl-compat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,12 @@
126126
#define GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
127127
#endif
128128

129+
/**
130+
* CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR were added in 7.85.0,
131+
* released in August 2022.
132+
*/
133+
#if LIBCURL_VERSION_NUM >= 0x075500
134+
#define GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR 1
135+
#endif
136+
129137
#endif

http-push.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ static void curl_setup_http(CURL *curl, const char *url,
198198
const char *custom_req, struct buffer *buffer,
199199
curl_write_callback write_fn)
200200
{
201-
curl_easy_setopt(curl, CURLOPT_PUT, 1);
201+
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
202202
curl_easy_setopt(curl, CURLOPT_URL, url);
203203
curl_easy_setopt(curl, CURLOPT_INFILE, buffer);
204204
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer->buf.len);
205205
curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
206-
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_buffer);
207-
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, buffer);
206+
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_buffer);
207+
curl_easy_setopt(curl, CURLOPT_SEEKDATA, buffer);
208208
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_fn);
209209
curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
210210
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, custom_req);

http.c

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,19 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
155155
return size / eltsize;
156156
}
157157

158-
curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp)
158+
int seek_buffer(void *clientp, curl_off_t offset, int origin)
159159
{
160160
struct buffer *buffer = clientp;
161161

162-
switch (cmd) {
163-
case CURLIOCMD_NOP:
164-
return CURLIOE_OK;
165-
166-
case CURLIOCMD_RESTARTREAD:
167-
buffer->posn = 0;
168-
return CURLIOE_OK;
169-
170-
default:
171-
return CURLIOE_UNKNOWNCMD;
162+
if (origin != SEEK_SET)
163+
BUG("seek_buffer only handles SEEK_SET");
164+
if (offset < 0 || offset >= buffer->buf.len) {
165+
error("curl seek would be outside of buffer");
166+
return CURL_SEEKFUNC_FAIL;
172167
}
168+
169+
buffer->posn = offset;
170+
return CURL_SEEKFUNC_OK;
173171
}
174172

175173
size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
@@ -717,20 +715,37 @@ void setup_curl_trace(CURL *handle)
717715
curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
718716
}
719717

720-
static long get_curl_allowed_protocols(int from_user)
718+
static void proto_list_append(struct strbuf *list, const char *proto)
721719
{
722-
long allowed_protocols = 0;
720+
if (!list)
721+
return;
722+
if (list->len)
723+
strbuf_addch(list, ',');
724+
strbuf_addstr(list, proto);
725+
}
723726

724-
if (is_transport_allowed("http", from_user))
725-
allowed_protocols |= CURLPROTO_HTTP;
726-
if (is_transport_allowed("https", from_user))
727-
allowed_protocols |= CURLPROTO_HTTPS;
728-
if (is_transport_allowed("ftp", from_user))
729-
allowed_protocols |= CURLPROTO_FTP;
730-
if (is_transport_allowed("ftps", from_user))
731-
allowed_protocols |= CURLPROTO_FTPS;
727+
static long get_curl_allowed_protocols(int from_user, struct strbuf *list)
728+
{
729+
long bits = 0;
732730

733-
return allowed_protocols;
731+
if (is_transport_allowed("http", from_user)) {
732+
bits |= CURLPROTO_HTTP;
733+
proto_list_append(list, "http");
734+
}
735+
if (is_transport_allowed("https", from_user)) {
736+
bits |= CURLPROTO_HTTPS;
737+
proto_list_append(list, "https");
738+
}
739+
if (is_transport_allowed("ftp", from_user)) {
740+
bits |= CURLPROTO_FTP;
741+
proto_list_append(list, "ftp");
742+
}
743+
if (is_transport_allowed("ftps", from_user)) {
744+
bits |= CURLPROTO_FTPS;
745+
proto_list_append(list, "ftps");
746+
}
747+
748+
return bits;
734749
}
735750

736751
#ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
@@ -874,10 +889,26 @@ static CURL *get_curl_handle(void)
874889

875890
curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
876891
curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
892+
893+
#ifdef GIT_CURL_HAVE_CURLOPT_PROTOCOLS_STR
894+
{
895+
struct strbuf buf = STRBUF_INIT;
896+
897+
get_curl_allowed_protocols(0, &buf);
898+
curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS_STR, buf.buf);
899+
strbuf_reset(&buf);
900+
901+
get_curl_allowed_protocols(-1, &buf);
902+
curl_easy_setopt(result, CURLOPT_PROTOCOLS_STR, buf.buf);
903+
strbuf_release(&buf);
904+
}
905+
#else
877906
curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
878-
get_curl_allowed_protocols(0));
907+
get_curl_allowed_protocols(0, NULL));
879908
curl_easy_setopt(result, CURLOPT_PROTOCOLS,
880-
get_curl_allowed_protocols(-1));
909+
get_curl_allowed_protocols(-1, NULL));
910+
#endif
911+
881912
if (getenv("GIT_CURL_VERBOSE"))
882913
http_trace_curl_no_data();
883914
setup_curl_trace(result);

http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct buffer {
4040
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
4141
size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
4242
size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf);
43-
curlioerr ioctl_buffer(CURL *handle, int cmd, void *clientp);
43+
int seek_buffer(void *clientp, curl_off_t offset, int origin);
4444

4545
/* Slot lifecycle functions */
4646
struct active_request_slot *get_active_slot(void);

remote-curl.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -710,25 +710,23 @@ static size_t rpc_out(void *ptr, size_t eltsize,
710710
return avail;
711711
}
712712

713-
static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
713+
static int rpc_seek(void *clientp, curl_off_t offset, int origin)
714714
{
715715
struct rpc_state *rpc = clientp;
716716

717-
switch (cmd) {
718-
case CURLIOCMD_NOP:
719-
return CURLIOE_OK;
717+
if (origin != SEEK_SET)
718+
BUG("rpc_seek only handles SEEK_SET, not %d", origin);
720719

721-
case CURLIOCMD_RESTARTREAD:
722-
if (rpc->initial_buffer) {
723-
rpc->pos = 0;
724-
return CURLIOE_OK;
720+
if (rpc->initial_buffer) {
721+
if (offset < 0 || offset > rpc->len) {
722+
error("curl seek would be outside of rpc buffer");
723+
return CURL_SEEKFUNC_FAIL;
725724
}
726-
error(_("unable to rewind rpc post data - try increasing http.postBuffer"));
727-
return CURLIOE_FAILRESTART;
728-
729-
default:
730-
return CURLIOE_UNKNOWNCMD;
725+
rpc->pos = offset;
726+
return CURL_SEEKFUNC_OK;
731727
}
728+
error(_("unable to rewind rpc post data - try increasing http.postBuffer"));
729+
return CURL_SEEKFUNC_FAIL;
732730
}
733731

734732
struct check_pktline_state {
@@ -948,8 +946,8 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece
948946
rpc->initial_buffer = 1;
949947
curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, rpc_out);
950948
curl_easy_setopt(slot->curl, CURLOPT_INFILE, rpc);
951-
curl_easy_setopt(slot->curl, CURLOPT_IOCTLFUNCTION, rpc_ioctl);
952-
curl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, rpc);
949+
curl_easy_setopt(slot->curl, CURLOPT_SEEKFUNCTION, rpc_seek);
950+
curl_easy_setopt(slot->curl, CURLOPT_SEEKDATA, rpc);
953951
if (options.verbosity > 1) {
954952
fprintf(stderr, "POST %s (chunked)\n", rpc->service_name);
955953
fflush(stderr);

0 commit comments

Comments
 (0)