Jeff King a02ea57717 git_connect_git(): forbid newlines in host and path
When we connect to a git:// server, we send an initial request that
looks something like:

  002dgit-upload-pack repo.git\0host=example.com

If the repo path contains a newline, then it's included literally, and
we get:

  002egit-upload-pack repo
  .git\0host=example.com

This works fine if you really do have a newline in your repository name;
the server side uses the pktline framing to parse the string, not
newlines. However, there are many _other_ protocols in the wild that do
parse on newlines, such as HTTP. So a carefully constructed git:// URL
can actually turn into a valid HTTP request. For example:

  git://localhost:1234/%0d%0a%0d%0aGET%20/%20HTTP/1.1 %0d%0aHost:localhost%0d%0a%0d%0a

becomes:

  0050git-upload-pack /
  GET / HTTP/1.1
  Host:localhost

  host=localhost:1234

on the wire. Again, this isn't a problem for a real Git server, but it
does mean that feeding a malicious URL to Git (e.g., through a
submodule) can cause it to make unexpected cross-protocol requests.
Since repository names with newlines are presumably quite rare (and
indeed, we already disallow them in git-over-http), let's just disallow
them over this protocol.

Hostnames could likewise inject a newline, but this is unlikely a
problem in practice; we'd try resolving the hostname with a newline in
it, which wouldn't work. Still, it doesn't hurt to err on the side of
caution there, since we would not expect them to work in the first
place.

The ssh and local code paths are unaffected by this patch. In both cases
we're trying to run upload-pack via a shell, and will quote the newline
so that it makes it intact. An attacker can point an ssh url at an
arbitrary port, of course, but unless there's an actual ssh server
there, we'd never get as far as sending our shell command anyway.  We
_could_ similarly restrict newlines in those protocols out of caution,
but there seems little benefit to doing so.

The new test here is run alongside the git-daemon tests, which cover the
same protocol, but it shouldn't actually contact the daemon at all.  In
theory we could make the test more robust by setting up an actual
repository with a newline in it (so that our clone would succeed if our
new check didn't kick in). But a repo directory with newline in it is
likely not portable across all filesystems. Likewise, we could check
git-daemon's log that it was not contacted at all, but we do not
currently record the log (and anyway, it would make the test racy with
the daemon's log write). We'll just check the client-side stderr to make
sure we hit the expected code path.

Reported-by: Harold Kim <h.kim@flatt.tech>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-07 14:25:44 -08:00
2019-12-06 16:30:49 +01:00
2020-04-19 16:28:57 -07:00
2018-12-07 19:43:07 +01:00
2018-08-02 13:54:58 -07:00
2018-11-02 11:04:53 +09:00
2018-08-20 12:41:32 -07:00
2018-11-05 13:42:11 +09:00
2018-09-12 15:15:34 -07:00
2018-07-26 10:12:51 -07:00
2018-10-19 13:34:02 +09:00
2018-10-19 13:34:02 +09:00
2018-11-02 11:04:53 +09:00
2018-05-08 15:59:17 +09:00
2019-12-06 16:30:49 +01:00
2018-11-19 16:24:41 +09:00
2018-08-20 12:41:32 -07:00
2020-04-19 16:24:14 -07:00
2018-10-19 13:34:02 +09:00
2018-10-19 13:34:02 +09:00
2018-10-19 13:34:02 +09:00
2018-10-19 13:34:02 +09:00
2019-12-06 16:30:49 +01:00
2018-05-08 15:59:17 +09:00
2019-12-06 16:30:49 +01:00
2020-04-19 16:28:57 -07:00
2019-12-06 16:30:49 +01:00
2019-12-06 16:30:49 +01:00
2020-04-19 16:28:57 -07:00
2018-11-02 11:04:53 +09:00
2018-11-05 13:42:11 +09:00
2018-11-05 13:42:11 +09:00
2018-12-12 17:18:29 +09:00
2018-07-16 14:27:39 -07:00
2020-04-19 16:28:57 -07:00
2018-05-30 21:51:28 +09:00
2018-10-30 15:43:39 +09:00
2018-10-19 13:34:02 +09:00
2018-08-29 13:05:35 -07:00
2018-11-29 15:45:31 +09:00
2018-11-13 22:37:19 +09:00
2018-10-19 13:34:02 +09:00
2018-08-29 11:32:49 -07:00
2018-08-20 15:31:40 -07:00
2018-08-29 11:32:49 -07:00
2018-10-04 11:12:14 -07:00
2018-10-04 11:12:14 -07:00
2018-11-21 20:39:02 +09:00
2018-06-01 15:06:37 +09:00
2018-10-19 13:34:02 +09:00
2019-12-06 16:30:49 +01:00
2018-11-18 18:23:52 +09:00
2018-11-02 12:14:21 +09:00
2018-11-02 12:14:21 +09:00
2019-12-06 16:30:49 +01:00
2018-08-15 15:08:23 -07:00
2020-04-19 16:28:57 -07:00
2018-09-17 13:53:52 -07:00
2018-08-20 15:31:40 -07:00
2018-09-17 13:53:57 -07:00
2018-06-01 15:06:37 +09:00
2018-11-02 11:04:54 +09:00
2018-11-02 11:04:54 +09:00
2019-12-06 16:30:49 +01:00
2019-12-06 16:30:49 +01:00
2019-12-06 16:30:49 +01:00
2019-12-06 16:30:49 +01:00
2018-10-19 13:34:02 +09:00
2019-12-06 16:30:49 +01:00
2019-12-06 16:30:49 +01:00
2018-08-15 11:52:09 -07:00
2018-05-30 21:51:28 +09:00
2018-10-19 13:34:02 +09:00
2018-08-15 15:08:25 -07:00
2018-08-20 12:41:32 -07:00
2018-07-18 12:20:28 -07:00
2018-10-19 13:34:02 +09:00

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just "subscribe git" in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://public-inbox.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the "What's cooking" reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name "git" was given by Linus Torvalds when he wrote the very first version. He described the tool as "the stupid content tracker" and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of "get" may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • "global information tracker": you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • "goddamn idiotic truckload of sh*t": when it breaks
Description
No description provided
Readme 235 MiB
Languages
C 50.1%
Shell 38.4%
Perl 5.1%
Tcl 3.3%
Python 0.8%
Other 2%