From owner-doc-jp@jp.freebsd.org  Fri Sep 17 11:53:00 1999
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id LAA38174;
	Fri, 17 Sep 1999 11:53:00 +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 LAA38165
	for <doc-jp@jp.freebsd.org>; Fri, 17 Sep 1999 11:52:58 +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 LAA10058 for <doc-jp@jp.freebsd.org>; Fri, 17 Sep 1999 11:52:57 +0900 (JST)
Message-Id: <199909170252.LAA01052@kid.micon.co.jp>
To: doc-jp@jp.freebsd.org
In-Reply-To: Your message of "Fri, 17 Sep 1999 11:09:45 +0900"
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: Fri, 17 Sep 1999 11:52:56 +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 6673
Subject: [doc-jp 6673] Re: FreeBSD-SA-99:04.core
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$3$N%a!<%k$O(B announce-jp $B$KN.$l$?(B

Subject: ANNOUNCE: FreeBSD Security Advisory: FreeBSD-SA-99:04.core
From: FreeBSD Security Officer <security-officer@freebsd.org>
Date: Wed, 15 Sep 1999 23:25:03 -0600 (MDT)
Message-Id: <199909160525.XAA19375@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. 
                                         $BK]Lu(B : $B:dFbFX(B <sakauchi@micon.co.jp>
=============================================================================
FreeBSD-SA-99:04                                            Security Advisory
                                                                FreeBSD, Inc.

$B%H%T%C%/(B:       Coredumps and symbolic links

$B%+%F%4%j!<(B:     core
$B%b%8%e!<%k(B:     kernel
$B9pCNF|(B:         1999-09-15
$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$5$l$k0JA0$N(B FreeBSD 2.2.8-stable
$B=$@5:Q(B:         FreeBSD-3.3 RELEASE ($BLuCm(B: $BM=Dj(B)
		1999$BG/(B8$B7n(B26$BF|0J9_$N(B FreeBSD-current
		1999$BG/(B8$B7n(B26$BF|0J9_$N(B FreeBSD-3.2-stable
		1999$BG/(B8$B7n(B28$BF|0J9_$N(B FreeBSD-2.2.8-stable
		The 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:04/

I.  $BGX7J(B

As a diagnostic aid to help programmers find bugs in their programs,
the system creates core files when an illegal instruction or other
fatal error happens.  A flaw in the kernel allowed it to follow
symbolic links when creating core files.

$B%W%m%0%i%^$,(B, $B%P%0$r8+$D$1$k$?$a$N?GCG$N=u$1$H$J$k$h$&$K(B, $BIT@5L?Na$J$I(B
$B$NCWL?E*%(%i!<$,5/$-$k$H(B, $B%7%9%F%`$O%3%"%U%!%$%k$r@8@.$7$^$9(B. $B%+!<%M%k(B
$BFb$NLdBj$K$h$j(B, $B%3%"%U%!%$%k$,@8@.$5$l$k:]$K%7%s%\%j%C%/%j%s%/$r$?$I$k(B
$B$3$H$,5v$5$l$F$$$^$9(B.  

II.  $B2r@b(B

The fts library functions had a flaw 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?tFb$NLdBj$K$h$j(B, periodic $B%;%-%e%j%F%#%A%'%C%/$N%9%/(B
$B%j%W%H(B($B%f!<%6$,@)8f2DG=$J(B, $B$=$3$+$i8F$P$l$k$b$N$r4^$a$F(B)$B$G(B, $B%3%"%@%s%W(B
$B$9$k$3$H$,$G$-$^$9(B.  
periodic(3) $B$O(B $B%3%^%s%I$r<B9T$9$k:]$K%3%"%@%s%W$7$J$$$h$&%3%"$N%5%$%:(B
$B$r(B 0 $B$K@)8B$9$Y$-$G$9$,(B, $B$=$&$J$C$F$$$^$;$s(B. $B2C$($F(B, $B%+!<%M%k$O(B
$B%7%s%\%j%C%/%j%s%/$r$?$I$k$Y$-$G$O$J$$$N$G$9(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#3$D$rAH$_9g$o$;$k$H(B, $B967b<T$O(B, $BLdBj$rKI$0$?$a$KJ]8n$5$l$F$$$k$b$N(B
$B$b4^$a$F(B, $B%7%9%F%`Fb$NG$0U$N%U%!%$%k$r:n$C$?$j(B, $B>e=q$-$7$?$j$9$k$3$H$,(B
$B2DG=$G$9(B. 


III. $B1F6A(B

Local users could gain root access.

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

IV.  $BBP: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/or userland can be installed.

periodic $B%9%/%j%W%H(B $B$,(B $B%3%"%@%s%W$7$J$$$h$&BP:v$9$k$3$H$,$G$-$^$9(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

Another alternative would be to update the fts routines to a version
newer than 1999/09/02 (for -current or 3.3-stable) or 1999/09/04 (for
2.2.8-stable).  However, this requires that you rebuild via "make
world" to take effect.

fts $B%k!<%A%s$r(B 1999$BG/(B9$B7n(B2$BF|0J9_(B ( -current $B$H(B 3.3-stable ) $B$N$b$N$+(B,
1999$BG/(B9$B7n(B4$BF|0J9_(B ( 2.2.8-stable ) $B$N$b$N$KF~$l49$($k$3$H$G$b2r7h$G$-$^(B
$B$9(B. $B$,(B, $B$3$N>l9g(B "make world" $B$K$h$C$F:F9=C[$7$J$$$H8z2L$,$"$j$^$;$s(B.

V.   $B2r7h:v(B

Please note: there is a separate advisory describing the fts problem
and solution.  Please see FreeBSD-SA-99:05.fts.asc in the advisories
directory for additional information about the fts patch.

$BCm0U(B: fts $BLdBj$H2r7h$K$D$$$F$O(B, $BJL$N4+9p$,$"$j$^$9(B. fts $B%Q%C%A$N>\:Y(B
$B$K$D$$$F$O(B FreeBSD-SA-99:05.fts.asc $B$r8fMw$/$@$5$$(B.

Apply the following patches to your kernel.  They will disallow
following symbolic links when creating core files.  This will stop
this attack, and all similar such attacks.

$B0J2<$N%Q%C%A$r%+!<%M%k$KE,MQ$7$F2<$5$$(B. $B$3$l$O(B $B%3%"%U%!%$%k$r@8@.(B
$B$9$k:]$K%7%s%\%j%C%/%j%s%/$r$?$I$l$J$/$9$k$b$N$G$9(B. $B$3$l$K$h$j(B, 
$B:#2s$N$b$N$@$1$G$J$/(B, $BF1$8$h$&$JA4$F$N967b$KBP1~$G$-$^$9(B.

freebsd-current $B$KBP$9$k%Q%C%A(B:

    *** kern/imgact_elf.c	1999/07/09 19:10:14	1.61
    --- kern/imgact_elf.c	1999/08/26 17:32:48	1.62
    ***************
    *** 722,729 ****
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */

    ! 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);
    --- 722,729 ----
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */

    ! 	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);
    *** kern/imgact_aout.c	1999/05/17 00:53:36	1.52
    --- kern/imgact_aout.c	1999/08/26 17:32:48	1.53
    ***************
    *** 264,271 ****
	    name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */
    ! 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);
    --- 264,271 ----
	    name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */
    ! 	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);

freebsd-3.2-stable $B$KBP$9$k%Q%C%A(B:


    *** kern/imgact_elf.c	1999/07/15 13:01:54	1.44.2.4
    --- kern/imgact_elf.c	1999/08/26 17:35:03	1.44.2.5
    ***************
    *** 699,706 ****
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */

    ! 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);
    --- 699,706 ----
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */

    ! 	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);
    *** kern/imgact_aout.c	1999/04/14 04:55:22	1.44.2.1
    --- kern/imgact_aout.c	1999/08/26 17:35:02	1.44.2.2
    ***************
    *** 259,266 ****
	    name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */
    ! 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);
    --- 259,266 ----
	    name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
	    if (name == NULL)
		    return (EFAULT);	/* XXX -- not the best error */
    ! 	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
    ! 	error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
	    free(name, M_TEMP);
	    if (error)
		    return (error);

FreeBSD-2.2.8-stable $B$KBP$9$k%Q%C%A(B:

    *** sys/LINK/fcntl.h	Wed Dec 18 05:08:08 1996
    --- sys/fcntl.h	Fri Aug 27 14:39:26 1999
    ***************
    *** 84,89 ****
    --- 84,90 ----
      #define	O_EXLOCK	0x0020		/* open with exclusive file lock */
      #define	O_ASYNC		0x0040		/* signal pgrp when data ready */
      #define	O_FSYNC		0x0080		/* synchronous writes */
    + #define	O_NOFOLLOW	0x0100		/* don't follow symlinks */
      #endif
      #define	O_CREAT		0x0200		/* create if nonexistent */
      #define	O_TRUNC		0x0400		/* truncate to zero length */
    *** kern/LINK/kern_sig.c	Sat Dec 21 10:57:24 1996
    --- kern/kern_sig.c	Fri Aug 27 14:38:25 1999
    ***************
    *** 1241,1249 ****
		p->p_rlimit[RLIMIT_CORE].rlim_cur)
		    return (EFAULT);
	    sprintf(name, "%s.core", p->p_comm);
    ! 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
	    if ((error = vn_open(&nd,
    ! 	    O_CREAT | FWRITE, S_IRUSR | S_IWUSR)))
		    return (error);
	    vp = nd.ni_vp;

    --- 1241,1249 ----
		p->p_rlimit[RLIMIT_CORE].rlim_cur)
		    return (EFAULT);
	    sprintf(name, "%s.core", p->p_comm);
    ! 	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
	    if ((error = vn_open(&nd,
    ! 	    O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR)))
		    return (error);
	    vp = nd.ni_vp;

    *** kern/LINK/vfs_vnops.c	Sat Mar  8 07:16:18 1997
    --- kern/vfs_vnops.c	Fri Aug 27 14:37:01 1999
    ***************
    *** 87,93 ****
	    if (fmode & O_CREAT) {
		    ndp->ni_cnd.cn_nameiop = CREATE;
		    ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
    ! 		if ((fmode & O_EXCL) == 0)
			    ndp->ni_cnd.cn_flags |= FOLLOW;
		    error = namei(ndp);
		    if (error)
    --- 87,93 ----
	    if (fmode & O_CREAT) {
		    ndp->ni_cnd.cn_nameiop = CREATE;
		    ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
    ! 		if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0)
			    ndp->ni_cnd.cn_flags |= FOLLOW;
		    error = namei(ndp);
		    if (error)
    ***************
    *** 119,125 ****
		    }
	    } else {
		    ndp->ni_cnd.cn_nameiop = LOOKUP;
    ! 		ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF;
		    error = namei(ndp);
		    if (error)
			    return (error);
    --- 119,126 ----
		    }
	    } else {
		    ndp->ni_cnd.cn_nameiop = LOOKUP;
    ! 		ndp->ni_cnd.cn_flags =
    ! 		    ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | LOCKLEAF;
		    error = namei(ndp);
		    if (error)
			    return (error);
    *** kern/LINK/vfs_syscalls.c	Wed Aug  4 12:44:30 1999
    --- kern/vfs_syscalls.c	Sat Aug 28 10:48:51 1999
    ***************
    *** 694,699 ****
    --- 694,701 ----
	    flags = FFLAGS(uap->flags);
	    if ((flags & FREAD + FWRITE) == 0)
		    return (EINVAL);
    + 	if (flags & O_NOFOLLOW)
    + 		flags &= ~O_NOFOLLOW;
	    error = falloc(p, &nfp, &indx);
	    if (error)
		    return (error);


=============================================================================
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

Notice: Any patches in this document may not apply cleanly due to
        modifications caused by digital signature or mailer software.
        Please reference the URL listed at the top of this document
        for original copies of all patches if necessary.
=============================================================================

