From owner-freebsd-toolchain@FreeBSD.ORG Tue Jan 13 22:22:31 2015 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 138F9BF8 for ; Tue, 13 Jan 2015 22:22:31 +0000 (UTC) Received: from phabric-backend.isc.freebsd.org (phabric-backend.isc.freebsd.org [IPv6:2001:4f8:3:ffe0:406a:0:50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB639693 for ; Tue, 13 Jan 2015 22:22:30 +0000 (UTC) Received: from phabric-backend.isc.freebsd.org (phabric-backend.isc.freebsd.org [127.0.1.5]) by phabric-backend.isc.freebsd.org (8.14.9/8.14.9) with ESMTP id t0DMMUvc035839 for ; Tue, 13 Jan 2015 22:22:30 GMT (envelope-from root@phabric-backend.isc.freebsd.org) Received: (from root@localhost) by phabric-backend.isc.freebsd.org (8.14.9/8.14.9/Submit) id t0DMMUjN035838; Tue, 13 Jan 2015 22:22:30 GMT (envelope-from root) Date: Tue, 13 Jan 2015 22:22:30 +0000 To: freebsd-toolchain@freebsd.org From: "emaste (Ed Maste)" Subject: [Differential] [Request, 10 lines] D1524: ar: Disallow directory traversal Message-ID: X-Priority: 3 Thread-Topic: D1524: ar: Disallow directory traversal X-Herald-Rules: none X-Phabricator-To: X-Phabricator-Cc: Thread-Index: Njc2MzUzYWFkN2I5MDZkNGU4MTcyOGJjZWU1 X-Phabricator-Sent-This-Message: Yes X-Mail-Transport-Agent: MetaMTA X-Auto-Response-Suppress: All X-Phabricator-Mail-Tags: , , MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2015 22:22:31 -0000 emaste created this revision. emaste added a subscriber: freebsd-toolchain. REVISION SUMMARY Set ARCHIVE_EXTRACT_SECURE_SYMLINKS and ARCHIVE_EXTRACT_SECURE_NODOTDOT as in bsdtar to prevent extraction of archive entries whose pathnames contain .. or whose target directory would be altered by a symlink. Also disallow absolute pathnames. We don't currently provide an option to disable this behaviour (as bsdtar's -P does). It is unlikely to be a problem in practice for ar(1), but the -P option is available if we want to allow it. Reported by: Alexander Cherepanov Elftoolchain ticket: 474 TEST PLAN From https://sourceforge.net/p/elftoolchain/tickets/474/ ~~~ printf '!\n%-48s%-10s`\n%-48s%-10s`\n' /tmp/file 0 ../file 0 > test.a n% ./ar -xv test.a x - /tmp/file ar: warning: Absolute path '/tmp/file' x - ../file ar: warning: Path contains '..' ~~~ REVISION DETAIL https://reviews.freebsd.org/D1524 AFFECTED FILES usr.bin/ar/read.c To: emaste Cc: freebsd-toolchain