Skip to content

Commit 230ce07

Browse files
committed
Merge tag 'v2.13.5' into maint
2 parents 4384e3c + 7234152 commit 230ce07

14 files changed

+130
-2
lines changed

Documentation/RelNotes/2.10.4.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git v2.10.4 Release Notes
2+
=========================
3+
4+
This release forward-ports the fix for "ssh://..." URL from Git v2.7.6

Documentation/RelNotes/2.11.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git v2.11.3 Release Notes
2+
=========================
3+
4+
This release forward-ports the fix for "ssh://..." URL from Git v2.7.6

Documentation/RelNotes/2.12.4.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git v2.12.4 Release Notes
2+
=========================
3+
4+
This release forward-ports the fix for "ssh://..." URL from Git v2.7.6

Documentation/RelNotes/2.13.5.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git v2.13.5 Release Notes
2+
=========================
3+
4+
This release forward-ports the fix for "ssh://..." URL from Git v2.7.6

Documentation/RelNotes/2.7.6.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Git v2.7.6 Release Notes
2+
========================
3+
4+
Fixes since v2.7.5
5+
------------------
6+
7+
* A "ssh://..." URL can result in a "ssh" command line with a
8+
hostname that begins with a dash "-", which would cause the "ssh"
9+
command to instead (mis)treat it as an option. This is now
10+
prevented by forbidding such a hostname (which will not be
11+
necessary in the real world).
12+
13+
* Similarly, when GIT_PROXY_COMMAND is configured, the command is
14+
run with host and port that are parsed out from "ssh://..." URL;
15+
a poorly written GIT_PROXY_COMMAND could be tricked into treating
16+
a string that begins with a dash "-". This is now prevented by
17+
forbidding such a hostname and port number (again, which will not
18+
be necessary in the real world).
19+
20+
* In the same spirit, a repository name that begins with a dash "-"
21+
is also forbidden now.
22+
23+
Credits go to Brian Neel at GitLab, Joern Schneeweisz of Recurity
24+
Labs and Jeff King at GitHub.
25+

Documentation/RelNotes/2.8.6.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git v2.8.6 Release Notes
2+
========================
3+
4+
This release forward-ports the fix for "ssh://..." URL from Git v2.7.6

Documentation/RelNotes/2.9.5.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Git v2.9.5 Release Notes
2+
========================
3+
4+
This release forward-ports the fix for "ssh://..." URL from Git v2.7.6

cache.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,14 @@ char *strip_path_suffix(const char *path, const char *suffix);
11461146
int daemon_avoid_alias(const char *path);
11471147
extern int is_ntfs_dotgit(const char *name);
11481148

1149+
/*
1150+
* Returns true iff "str" could be confused as a command-line option when
1151+
* passed to a sub-program like "ssh". Note that this has nothing to do with
1152+
* shell-quoting, which should be handled separately; we're assuming here that
1153+
* the string makes it verbatim to the sub-program.
1154+
*/
1155+
int looks_like_command_line_option(const char *str);
1156+
11491157
/**
11501158
* Return a newly allocated string with the evaluation of
11511159
* "$XDG_CONFIG_HOME/git/$filename" if $XDG_CONFIG_HOME is non-empty, otherwise

connect.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
578578

579579
get_host_and_port(&host, &port);
580580

581+
if (looks_like_command_line_option(host))
582+
die("strange hostname '%s' blocked", host);
583+
if (looks_like_command_line_option(port))
584+
die("strange port '%s' blocked", port);
585+
581586
proxy = xmalloc(sizeof(*proxy));
582587
child_process_init(proxy);
583588
argv_array_push(&proxy->args, git_proxy_command);
@@ -824,6 +829,9 @@ struct child_process *git_connect(int fd[2], const char *url,
824829
conn = xmalloc(sizeof(*conn));
825830
child_process_init(conn);
826831

832+
if (looks_like_command_line_option(path))
833+
die("strange pathname '%s' blocked", path);
834+
827835
strbuf_addstr(&cmd, prog);
828836
strbuf_addch(&cmd, ' ');
829837
sq_quote_buf(&cmd, path);
@@ -857,6 +865,9 @@ struct child_process *git_connect(int fd[2], const char *url,
857865
return NULL;
858866
}
859867

868+
if (looks_like_command_line_option(ssh_host))
869+
die("strange hostname '%s' blocked", ssh_host);
870+
860871
ssh = get_ssh_command();
861872
if (ssh)
862873
handle_ssh_variant(ssh, 1, &port_option,

path.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,11 @@ int is_ntfs_dotgit(const char *name)
13211321
}
13221322
}
13231323

1324+
int looks_like_command_line_option(const char *str)
1325+
{
1326+
return str && str[0] == '-';
1327+
}
1328+
13241329
char *xdg_config_home(const char *filename)
13251330
{
13261331
const char *home, *config_home;

0 commit comments

Comments
 (0)