From owner-doc-jp@jp.freebsd.org  Sat Sep 18 15:12:23 1999
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id PAA22266;
	Sat, 18 Sep 1999 15:12:23 +0900 (JST)
	(envelope-from owner-doc-jp@jp.FreeBSD.org)
Received: from mx.micon.co.jp (merry.micon.co.jp [210.226.150.226])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id PAA22261
	for <doc-jp@jp.freebsd.org>; Sat, 18 Sep 1999 15:12:22 +0900 (JST)
	(envelope-from sakauchi@micon.co.jp)
Received: from sam.micon.co.jp (sam.micon.co.jp [210.226.150.227]) by mx.micon.co.jp (8.8.5/CF-3.5W+01/21/98) with ESMTP id PAA13291 for <doc-jp@jp.freebsd.org>; Sat, 18 Sep 1999 15:12:21 +0900 (JST)
Message-Id: <199909180612.PAA18130@kid.micon.co.jp>
To: doc-jp@jp.freebsd.org
X-Mailer: Mew version 1.69 on Emacs 19.28.1 / Mule 2.3
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Date: Sat, 18 Sep 1999 15:12:20 +0900
From: Atushi Sakauchi <sakauchi@micon.co.jp>
Reply-To: doc-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+990727
X-Sequence: doc-jp 6684
Subject: [doc-jp 6684] FreeBSD-SA-99:05.fts
Errors-To: owner-doc-jp@jp.freebsd.org
Sender: owner-doc-jp@jp.freebsd.org
X-Originator: sakauchi@micon.co.jp

$B:dFb$G$9!#(B

$B$[$H$s$IF1$8$J$N$G(B  SA-99:05 $B$b$d$C$F$_$^$7$?!#(B

  $B$3$N%a!<%k$O(B announce-jp $B$KN.$l$?(B

Subject: ANNOUNCE: FreeBSD Security Advisory: FreeBSD-SA-99:05.fts
From: FreeBSD Security Officer <security-officer@FreeBSD.ORG>
Date: Wed, 15 Sep 1999 23:25:21 -0600 (MDT)
Message-Id: <199909160525.XAA19379@harmony.village.org>

$B$rF|K\8lLu$7$?$b$N$G$9(B.
  $B86J8$O(B PGP $B=pL>$5$l$F$$$^$9$,(B, $B$3$NF|K\8lLu$O(B PGP $B=pL>$5$l$F$$$^$;$s(B. 
$B%Q%C%AEy$NFbMF$,2~cb$5$l$F$$$J$$$3$H$r3NG'$9$k$?$a$K(B PGP $B$N%A%'%C%/$r9T(B
$B$J$&$K$O86J8$r;2>H$7$F$/$@$5$$(B. 
  $BF|K\8lLu$O(B FreeBSD $BF|K\8l%I%-%e%a%s%F!<%7%g%s%W%m%8%'%/%H(B (doc-jp) $B$,(B
$B;29M$N$?$a$KDs6!$9$k$b$N$G(B, $BK]Lu<T$*$h$S(B doc-jp $B$O(B $B$=$NFbMF$K$D$$$F(B
$B$$$+$J$kJ]>Z$b$$$?$7$^$;$s(B. 
  $BF|K\8lLu$K$D$$$F$N$*Ld$$9g$o$;$O(B doc-jp@jp.freebsd.org $B$^$G(B
$B$*4j$$$7$^$9(B. 
=============================================================================
FreeBSD-SA-99:05                                            Security Advisory
                                                                FreeBSD, Inc.

$B%H%T%C%/(B:             fts library routine vulnerability

$B%+%F%4%j!<(B:           core
$B%b%8%e!<%k(B:           kernel
$B9pCNF|(B:               1999$BG/(B 9$B7n(B15$BF|(B
$B1F6ABP>](B:             FreeBSD 3.2 ($B$*$h$S(B 3.2 $B0JA0$N%P!<%8%g%s(B)
                      $B=$@5$5$l$k0JA0$N(B FreeBSD-current
                      $B=$@5$5$l$k0JA0$N(B FreeBSD 3.2-stable
$B=$@5:Q(B:               FreeBSD 3.3-RELEASE
                      1999$BG/(B8$B7n(B26$BF|0J9_$N(B FreeBSD-current
                      1999$BG/(B8$B7n(B26$BF|0J9_$N(B FreeBSD-3.2-stable
                      FreeBSD-3.3-RC $B%7%j!<%:$K$O1F6A$J$7(B
FreeBSD $B$@$1$NLdBj$+(B: $BH](B

$B%Q%C%A(B:             ftp://ftp.freebsd.org/pub/FreeBSD/CERT/patches/SA-99:05/

I.   $BGX7J(B

The fts library routines provide a convenient way for a program to
walk a hierarchy of files.

fts $B$O(B, $B%U%!%$%k$N3,AX$r4JC1$K07$&$?$a$N%i%$%V%i%j$G$9(B.

II.  $B2r@b(B

The fts library functions had a buffer overflow in them where which
would lead to a core dump when periodic ran the security checking
scripts (or other scripts which traverse trees that can be controlled
by users).  periodic(3) should limit core size to zero to disable core
dumps while it is executing commands, but does not do so.  In
addition, the kernel should not follow symbolic links.

fts $B%i%$%V%i%j4X?t$K$O(B, periodic(8) $B$,%;%-%e%j%F%#%A%'%C%/MQ$N(B
$B%9%/%j%W%H(B($B$*$h$S(B, $B%f!<%6$K$h$C$F;XDj$5$l$?%G%#%l%/%H%j%D%j!<$r(B
$BAv::$9$k$h$&$JB>$N%9%/%j%W%H(B)$B$r<B9T$7$F$$$k;~$K(B, 
$B%P%C%U%!%*!<%P%U%m!<$K$h$j%3%"%@%s%W$r@8$8$k2DG=@-$,$"$j$^$9(B.
periodic(8) $B$,%3%^%s%I$r<B9T$7$F$b%3%"%@%s%W$rH/@8$5$;$J$$$h$&(B, 
$B%3%"%5%$%:$r(B 0 $B$K@)8B$9$Y$-$G$9(B. $B$^$?(B, $B%+!<%M%k$O(B
$B%7%s%\%j%C%/%j%s%/$r$?$I$k$Y$-$G$O$"$j$^$;$s(B. 

All three of these problems caused a situation where it was possible
for an attacker could create or overwrite an arbitrary file on the
system with a moderate degree of controll of its contents to cause a
problem.

$B0J>e$N(B 3 $B$D$NLdBjE@$O967b<T$KBP$7(B, $BLdBj$H$J$k$h$&$JFbMF$r4^$`(B
$BG$0U$N%U%!%$%k$r%7%9%F%`>e$K:n@.$7$?$j(B, $B$b$7$/$O4{B8$N%U%!%$%k$r(B
$B>e=q$-$9$k$3$H$r2DG=$K$9$k>u67$r$D$/$j$^$9(B.

III. $B1F6A(B

Local users could gain root access.

$B%m!<%+%k$N%f!<%6$,(B, root $B8"8B$rC%$&$3$H$,2DG=$G$9(B.

IV.  $BBP1~:v(B

One can workaround this problem by preventing core dumps for periodic.
This solution is less than completely satisfying, since it only plugs
the known exploit hole.  None the less, this may provide a short term
stopgap solution until a new kernel and userland can be installed.

$B$3$NLdBj$r2r7h$9$k$?$a$N0l$D$NJ}K!$O(B, periodic(8) $B$N%3%"%@%s%W$r(B
$BM^@)$9$k$3$H$G$9(B. $B$3$l$OLdBj$H$J$C$F$$$k4{CN$N%;%-%e%j%F%#%[!<%k$r(B 
$BC1$K1#$9$@$1$J$N$G(B, $B40A4$KK~B-$N$$$/$b$N$G$O$"$j$^$;$s$,(B,
$B?7$7$$%P!<%8%g%s$N%+!<%M%k$d%f!<%6%i%s%I$r%$%s%9%H!<%k$G$-$k$h$&$K$J$k$^$G(B
$B5^>l$7$N$.$NBP:v$K$O$J$k$G$7$g$&(B.

    # mv /usr/sbin/periodic /usr/sbin/periodic.bin
    # cat > /usr/sbin/periodic
    #!/bin/sh
    ulimit -c 0
    /usr/sbin/periodic.bin $*
    ^D
    # chmod 555 /usr/sbin/periodic

V.   $B2r7h:v(B

Apply the following patches to libc and do a make world.  Please also
see the companion advisory FreeBSD-SA-99:04.core.asc in the advisories
directory of our ftp site for details on the kernel portions of this
fix.

$B0J2<$N%Q%C%A$r(B libc $B$KE,MQ$7(B make world $B$7$^$9(B. $B%+!<%M%kItJ,$N=$@5$K(B
$B$D$$$F$N>\:Y$O(B FreeBSD $B$N(B FTP $B%5%$%H$N(B adovisories $B%G%#%l%/%H%j$K$"$k(B 
FreeBSD-SA-99:04.core.asc $B$r;2>H$7$F$/$@$5$$(B.

    Index: lib/libc/gen/fts.c
    ===================================================================
    RCS file: /home/imp/FreeBSD/CVS/src/lib/libc/gen/fts.c,v
    retrieving revision 1.10
    retrieving revision 1.11
    diff -u -r1.10 -r1.11
    --- fts.c	1999/08/15 19:21:29	1.10
    +++ fts.c	1999/09/02 07:45:07	1.11
    @@ -963,6 +963,24 @@
	    return (sp->fts_path == NULL);
     }

    +static void
    +ADJUST(p, addr)
    +	FTSENT *p;
    +	void *addr;
    +{
    +	if ((p)->fts_accpath >= (p)->fts_path &&			
    +	    (p)->fts_accpath < (p)->fts_path + (p)->fts_pathlen) {
    +		if (p->fts_accpath != p->fts_path)
    +			errx(1, "fts ADJUST: accpath %p path %p",
    +			    p->fts_accpath, p->fts_path);
    +		if (p->fts_level != 0)
    +			errx(1, "fts ADJUST: level %d not 0", p->fts_level);
    +		(p)->fts_accpath =					
    +		    (char *)addr + ((p)->fts_accpath - (p)->fts_path);	
    +	}
    +	(p)->fts_path = addr;						
    +}
    +
     /*
      * When the path is realloc'd, have to fix all of the pointers in structures
      * already returned.
    @@ -974,18 +992,18 @@
     {
	    FTSENT *p;

    -#define	ADJUST(p) {							\
    -	(p)->fts_accpath =						\
    -	    (char *)addr + ((p)->fts_accpath - (p)->fts_path);		\
    +#define	ADJUST1(p) {							\
    +	if ((p)->fts_accpath == (p)->fts_path)				\
    +		(p)->fts_accpath = (addr);				\
	    (p)->fts_path = addr;						\
     }
	    /* Adjust the current set of children. */
	    for (p = sp->fts_child; p; p = p->fts_link)
    -		ADJUST(p);
    +		ADJUST(p, addr);

	    /* Adjust the rest of the tree. */
	    for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
    -		ADJUST(p);
    +		ADJUST(p, addr);
		    p = p->fts_link ? p->fts_link : p->fts_parent;
	    }
     }


=============================================================================
FreeBSD, Inc.

Web Site:                       http://www.freebsd.org/
Confidential contacts:          security-officer@freebsd.org
Security notifications:         security-notifications@freebsd.org
Security public discussion:     freebsd-security@freebsd.org
PGP Key:                ftp://ftp.freebsd.org/pub/FreeBSD/CERT/public_key.asc

$BCm0U(B: $BK\J8=qCf$K%Q%C%A$,4^$^$l$F$$$k>l9g(B, $BEE;R=pL>$d%a%$%i$N=hM}$GJQ99(B
      $B$5$l$k$?$a(B, $B$=$N$^$^$G$O$-$A$s$HE,MQ$G$-$J$$$+$b$7$l$^$;$s(B. $BI,MW(B
      $B$G$"$l$P(B, $BK\J8=q$NKAF,$K5-:\$7$F$"$k(B URL $B$r;2>H$7$F%*%j%8%J%k$N(B
      $B%3%T!<$rF~<j$7$F$/$@$5$$(B.
=============================================================================
