Date: Fri, 24 Apr 2015 15:48:24 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r281936 - stable/10/usr.bin/ar Message-ID: <201504241548.t3OFmOwP057984@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Fri Apr 24 15:48:23 2015 New Revision: 281936 URL: https://svnweb.freebsd.org/changeset/base/281936 Log: MFC r281311: ar: Disallow directory traversal 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 not currently used and available if we want to consider it for this purpose. Obtained from: ELF tool chain ar, Ticket #474 Relnotes: Yes Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.bin/ar/read.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/ar/read.c ============================================================================== --- stable/10/usr.bin/ar/read.c Fri Apr 24 15:36:58 2015 (r281935) +++ stable/10/usr.bin/ar/read.c Fri Apr 24 15:48:23 2015 (r281936) @@ -186,7 +186,15 @@ read_archive(struct bsdar *bsdar, char m if (bsdar->options & AR_V) (void)fprintf(stdout, "x - %s\n", name); - flags = 0; + /* Disallow absolute paths. */ + if (name[0] == '/') { + bsdar_warnc(bsdar, 0, + "Absolute path '%s'", name); + continue; + } + /* Basic path security flags. */ + flags = ARCHIVE_EXTRACT_SECURE_SYMLINKS | \ + ARCHIVE_EXTRACT_SECURE_NODOTDOT; if (bsdar->options & AR_O) flags |= ARCHIVE_EXTRACT_TIME;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504241548.t3OFmOwP057984>