From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Jonathan Nieder" <jrnieder@gmail.com>,
git@vger.kernel.org,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH/RFC] fsck: complain when .gitignore and .gitattributes are symlinks
Date: Thu, 17 Jan 2019 12:13:12 -0800 [thread overview]
Message-ID: <xmqq1s5bniuf.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190117170005.GA27667@sigill.intra.peff.net> (Jeff King's message of "Thu, 17 Jan 2019 12:00:06 -0500")
Jeff King <peff@peff.net> writes:
> Hmm. I think this commit message isn't quite right, because we also
> skipped the patches to touch gitignore/gitattributes in verify_path().
>
> Are you thinking we should resurrect that behavior[1], too, or just
> protect at the fsck level?
>
>> It was omitted from that series because it does not address any known
>> exploit, but to me it seems worthwhile anyway:
>>
>> - if a client enables transfer.fsckObjects, this helps them protect
>> themselves against weird input that does *not* have a known exploit
>> attached, to
>>
>> - it generally feels more simple and robust. Git-related tools can
>> benefit from this kind of check as an indication of input they can
>> bail out on instead of trying to support.
>
> I think I may just be restating your two points above, but what I'd
> argue is:
>
> - even though there's no known-interesting exploit, this can cause Git
> to unexpectedly read arbitrary files outside of the repository
> directory. That in itself isn't necessarily evil, but it's weird.
>
> - there are potentially non-malicious bugs here, where we try to read
> .gitattributes out of the index, but obviously don't follow symlinks
> there
FWIW, you two can count me as the third person who agrees with the
above points.
> [1] This wasn't a separate patch, but just an early iteration of the
> "ban symlinks in .gitmodules" patch. I think the incremental is
> just:
>
> diff --git a/read-cache.c b/read-cache.c
> index bfff271a3d..121c0bec69 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -937,7 +937,9 @@ static int verify_dotfile(const char *rest, unsigned mode)
> return 0;
> if (S_ISLNK(mode)) {
> rest += 3;
> - if (skip_iprefix(rest, "modules", &rest) &&
> + if ((skip_iprefix(rest, "modules", &rest) ||
> + skip_iprefix(rest, "ignore", &rest) ||
> + skip_iprefix(rest, "attributes", &rest)) &&
> (*rest == '\0' || is_dir_sep(*rest)))
> return 0;
> }
OK.
> @@ -966,7 +968,9 @@ int verify_path(const char *path, unsigned mode)
> if (is_hfs_dotgit(path))
> return 0;
> if (S_ISLNK(mode)) {
> - if (is_hfs_dotgitmodules(path))
> + if (is_hfs_dotgitmodules(path) ||
> + is_hfs_dotgitignore(path) ||
> + is_hfs_dotgitattributes(path))
> return 0;
> }
> }
> @@ -974,7 +978,9 @@ int verify_path(const char *path, unsigned mode)
> if (is_ntfs_dotgit(path))
> return 0;
> if (S_ISLNK(mode)) {
> - if (is_ntfs_dotgitmodules(path))
> + if (is_ntfs_dotgitmodules(path) ||
> + is_ntfs_dotgitignore(path) ||
> + is_ntfs_dotgitattributes(path))
> return 0;
Curious that we already have these helpers, nobody seems to call
them in the current codebase, and we haven't seen the "these are
unused" linter message on the list for a while ;-).
next prev parent reply other threads:[~2019-01-17 20:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-14 23:09 [PATCH/RFC] fsck: complain when .gitignore and .gitattributes are symlinks Jonathan Nieder
2019-01-17 17:00 ` Jeff King
2019-01-17 20:13 ` Junio C Hamano [this message]
2019-01-17 21:24 ` Jeff King
2019-01-18 1:41 ` Ramsay Jones
2019-01-22 7:23 ` Jeff King
2019-01-22 18:19 ` Ramsay Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1s5bniuf.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).