delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/07/09/20:27:30

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_CG,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4C37BE2A.3020501@redhat.com>
Date: Fri, 09 Jul 2010 18:26:18 -0600
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.0.5
MIME-Version: 1.0
To: cygwin <cygwin AT cygwin DOT com>
Subject: Re: tar: symlinks unpacked to empty files (tar security problem?)
References: <1278237042 DOT 6012 DOT 15 DOT camel AT YAAKOV04> <20100704171709 DOT GA12616 AT ednor DOT casa DOT cgf DOT cx>
In-Reply-To: <20100704171709.GA12616@ednor.casa.cgf.cx>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------enigA7B76DFE9E7099B73AA294BB
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 07/04/2010 11:17 AM, Christopher Faylor wrote:
> On Sun, Jul 04, 2010 at 04:50:41AM -0500, Yaakov (Cygwin/X) wrote:
>> With tar-1.23-1 and recent snapshot:
>>
>> echo foo > foo
>> ln -s $PWD/foo bar
>> tar cf test.tar bar foo
>> rm -f bar foo
>> tar xf test.tar
>> ls -l bar foo
>>
>> You will see that 'bar' is a 0-byte file with 0000 permissions instead
>> of a symlink.  The symlink reference need not be absolute; it also
>> happens with relative links in different directories, but does not
>> happen if I just "ln -s foo bar".
>=20
> That's because of the way that tar handles symlinks.  If you have a
> reference to an absolute path, tar makes a zero-length regular file
> placeholder.  Then when it is done extracting, tar is supposed to remove
> this file and create the real symlink.  However, the test to make sure
> that it is ok to do this was broken by a recent DLL change.  The inode
> returned the first time that the file was created was !=3D the inode when
> the file is checked later.  So tar thought that the zero-length file was
> modified and silently decided not to create the symlink.

For the longest time, I was carrying a cygwin-specific patch that
ignored the inode check.  Thinking that it was leftovers from 1.5, I
removed that cygwin-specific patch (that is, re-enabled the inode
check), because I didn't have a test case that would trigger it.  It
looks like you have demonstrated the test case, and if cgf fixed the dll
to report the same inode in both situations, then great.  But since I'm
on vacation at the moment, with only limited email access, it will be
another week before I can even think about re-building tar to re-enable
the cygwin-specific patch.  I'll do that, unless cygwin 1.7.6 is
released first and fixes the problem in the meantime.

> I've fixed the cygwin problem - it should be in the next snapshot.  I
> think this silent behavior of tar is not too user friendly though.  It
> seems like there is a pathological situation there where you'd end
> thinking that you'd extracted a symlink without getting the symlink.  In
> fact, I think this is actually a security problem.
>=20
> Eric, am I missing something about tar's behavior here?

You're probably right that this should be reported upstream as a
potential hole, where tar should not be silent about failure to restore
a file.

--=20
Eric Blake   eblake AT redhat DOT com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


--------------enigA7B76DFE9E7099B73AA294BB
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBCAAGBQJMN74qAAoJEKeha0olJ0NqrQMIAK6XnSFGZLbuxV/Z0+IG1SgT
AnrUgMebiltRNJgEdqDAB/uA3QVkhvFAGSCNVxHLLdNjJnVS7cPvjYqfp+8p2bQE
tes6j4uXxHJjlXUz+l+gKiM59XbS4+BypfsCALdTgsIIx+A/moS8jOKN9hGZRo89
EajtGlP18uYICWQJ/6Kxq+o/+kaxlvOE14BNDCfdaTj7dER5njxpbEX5eXj1oMBT
iO/TmIaCCpQmJlr6X4NIdPMB7u0bCX+n7WMyIf2GSziJE7gVQHxg+1Yu2tMcp9Bx
XQoU/t128aXtVpGLbHI9/cft2JKUJYfkQW8IFcUvd88YesFLOlIPT4eFZAF0pbE=
=VA6R
-----END PGP SIGNATURE-----

--------------enigA7B76DFE9E7099B73AA294BB--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019