* clean filter run in top of repo with wrong GIT_WORK_TREE
@ 2018-07-17 16:58 Joey Hess
2018-07-17 17:32 ` Joey Hess
0 siblings, 1 reply; 2+ messages in thread
From: Joey Hess @ 2018-07-17 16:58 UTC (permalink / raw)
To: git; +Cc: brian m. carlson
[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]
When git is running inside a subdirectory of the repository,
and needs to run the clean filter, it runs it chdired back to the top of
the repository. However, if git was run with a relative --work-tree,
it passes that relative path in GIT_WORK_TREE on to the clean filter.
If git was run with eg, "--work-tree=..", the clean filter sees a work
tree that is outside the repository. It might then read files located
outside the repository. That seems like it could have security
consequences, but it's certianly a surprising problem to need to deal
with when writing a clean filter.
Brian posted a fix for a very similar bug in sequencer.c on the 14th,
so it seems likely there are other occurances of the same problem
elsewhere.
Demonstration of this bug:
joey@darkstar:~/tmp/repo>cat .gitattributes
* filter=foo
joey@darkstar:~/tmp/repo>git config filter.foo.clean
clean-filter %f
joey@darkstar:~/tmp/repo>cat ~/bin/clean-filter
#!/bin/sh
pwd >&2
echo $GIT_WORK_TREE >&2
ls "$GIT_WORK_TREE/$1"
joey@darkstar:~/tmp/repo>cd foo/bar/
joey@darkstar:~/tmp/repo/foo/bar>ls
x
joey@darkstar:~/tmp/repo/foo/bar>touch x
joey@darkstar:~/tmp/repo/foo/bar>git --work-tree=../.. ls-files --modified
/home/joey/tmp/repo
../..
ls: cannot access '../../foo/bar/x': No such file or directory
git version 2.18.0
--
see shy jo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: clean filter run in top of repo with wrong GIT_WORK_TREE
2018-07-17 16:58 clean filter run in top of repo with wrong GIT_WORK_TREE Joey Hess
@ 2018-07-17 17:32 ` Joey Hess
0 siblings, 0 replies; 2+ messages in thread
From: Joey Hess @ 2018-07-17 17:32 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
The clean filter can work around this problem by chdir GIT_PREFIX,
but needing to do this in unusual cases seems to be asking for bugs.
--
see shy jo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-17 17:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 16:58 clean filter run in top of repo with wrong GIT_WORK_TREE Joey Hess
2018-07-17 17:32 ` Joey Hess
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).