From owner-doc-jp@jp.freebsd.org  Wed Nov 22 01:44:07 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id BAA45869;
	Wed, 22 Nov 2000 01:44:07 +0900 (JST)
	(envelope-from owner-doc-jp@jp.FreeBSD.org)
Received: from eos.ocn.ne.jp (eos.ocn.ne.jp [210.190.142.171])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id BAA45864
	for <doc-jp@jp.freebsd.org>; Wed, 22 Nov 2000 01:44:06 +0900 (JST)
	(envelope-from hrs@eos.ocn.ne.jp)
Received: from mail.hrslab.yi.org (p0189-ip01funabasi.chiba.ocn.ne.jp [211.123.225.189])
	by eos.ocn.ne.jp (8.9.1a/OCN/) with ESMTP id BAA25521
	for <doc-jp@jp.freebsd.org>; Wed, 22 Nov 2000 01:44:04 +0900 (JST)
Message-Id: <200011211644.BAA25521@eos.ocn.ne.jp>
Received: from localhost (alph.hrslab.yi.org [192.168.0.10])
	by mail.hrslab.yi.org (8.9.3/3.7W/DomainMaster) with ESMTP id BAA56428
	for <doc-jp@jp.freebsd.org>; Wed, 22 Nov 2000 01:41:15 +0900 (JST)
	(envelope-from hrs@eos.ocn.ne.jp)
To: doc-jp@jp.freebsd.org
In-Reply-To: <20001120220111.D4FC437B65F@hub.freebsd.org>
References: <20001120220111.D4FC437B65F@hub.freebsd.org>
X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Wed_Nov_22_01:40:28_2000_737)--"
Content-Transfer-Encoding: 7bit
Date: Wed, 22 Nov 2000 01:41:13 +0900
From: Hiroki Sato <hrs@eos.ocn.ne.jp>
X-Dispatcher: imput version 20000228(IM140)
Lines: 264
Reply-To: doc-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: doc-jp 7851
Subject: [doc-jp 7851] Re: ANNOUNCE: FreeBSD Security Advisory: FreeBSD-SA-00:76.tcsh-csh
Errors-To: owner-doc-jp@jp.freebsd.org
Sender: owner-doc-jp@jp.freebsd.org
X-Originator: hrs@eos.ocn.ne.jp

----Next_Part(Wed_Nov_22_01:40:28_2000_737)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B:4F#!wEl5~M}2JBg3X$G$9!#(B

 00:76 $B$NK]Lu$G$9!#(B

--
| $B:4F#(B $B9-@8!wEl5~M}2JBg3X(B <hrs@eos.ocn.ne.jp>
|
| sato@sekine00.ee.noda.sut.ac.jp (UNIV)
| hrs@FreeBSD.org (FreeBSD Project)

----Next_Part(Wed_Nov_22_01:40:28_2000_737)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Disposition: attachment; filename="00:76"
Content-Transfer-Encoding: 7bit

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

  Subject: ANNOUNCE: FreeBSD Security Advisory: FreeBSD-SA-00:76.tcsh-csh
  From: FreeBSD Security Advisories <security-advisories@freebsd.org>
  Date: Mon, 20 Nov 2000 14:01:11 -0800 (PST)
  Message-Id: <20001120220111.D4FC437B65F@hub.freebsd.org>
  X-Sequence: announce-jp 610

 $B$rF|K\8lLu$7$?$b$N$G$9(B. 

 $B$3$N4+9p$NCf$G>R2p$5$l$F$$$k(B WWW $B%5%$%H(B http://www.FreeBSD.org/ $B$*$h$S(B
 FTP $B%5%$%H(B ftp://ftp.FreeBSD.org/ $B$K$O(B, $BF|K\$N%_%i!<%5%$%H$,B8:_$7$^$9(B.
 $B%_%i!<%5%$%H$rMxMQ$9$k$K$O(B,
 http://www.FreeBSD.org/ $B$r(B http://www.jp.FreeBSD.org/www.freebsd.org/ $B$K(B,
 ftp://ftp.FreeBSD.org/ $B$r(B ftp://ftp.jp.FreeBSD.org/ $B$K(B,
 $B$=$l$>$lCV$-49$($F$/$@$5$$(B.

 $B%M%C%H%o!<%/$N:.;($r4KOB$9$k$?$a(B, $B$^$:$O%_%i!<%5%$%H$NMxMQ$r(B
 $B9MN8$9$k$h$&$*4j$$$7$^$9(B.  $B%_%i!<%5%$%H$K4X$9$k>\:Y$O(B

  http://www.FreeBSD.org/handbook/mirror.html ($B1QJ8(B)
  http://www.FreeBSD.org/ja/handbook/mirror.html ($BF|K\8lLu(B)

 $B$K(B, $B$^$?(B, $B2a5n$NF|K\8lHG%;%-%e%j%F%#4+9p$O(B

  http://www.FreeBSD.org/ja/security/

 $B$K$^$H$a$i$l$F$$$^$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%/$r(B
 $B9T$J$&$K$O(B, $B86J8$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$,;29M$N(B
 $B$?$a$KDs6!$9$k$b$N$G(B, doc-jp $B$O(B $B$=$NFbMF$K$D$$$F$$$+$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$*4j$$$7$^$9(B.

--($B$3$3$+$i(B)

=============================================================================
FreeBSD-SA-00:76                                            Security Advisory
                                                                FreeBSD, Inc.

$B%H%T%C%/(B:	tcsh/csh creates insecure temporary file

$BJ,N`(B:		core, ports
$B%b%8%e!<%k(B:	tcsh, 44bsd-csh
$B9pCNF|(B:		2000-11-20
$B1F6AHO0O(B:	$B=$@5F|0JA0$N(B FreeBSD 4.x $B$*$h$S(B 3.x
$B=$@5F|(B:		2000-11-04 (FreeBSD 4.1.1-STABLE)
                2000-11-05 (FreeBSD 3.5.1-STABLE)
		2000-11-09 (44bsd-csh port)
		2000-11-19 (tcsh port)
$B%/%l%8%C%H(B:	proton <proton@ENERGYMECH.NET>
FreeBSD $B$K8GM-$+(B:	NO

I.   $BGX7J(B - Background

tcsh is an updated version of the traditional BSD C Shell
(csh).  Versions of csh and tcsh are included in the FreeBSD ports
collection (tcsh, 44bsd-csh) and the FreeBSD base system (csh, tcsh).

tcsh $B$O(B, $BEAE}E*$J(B BSD C Shell (csh) $B$N99?7HG$G$9(B.  csh $B$*$h$S(B tcsh $B$O(B,
FreeBSD Ports Collection ($B$=$l$>$l(B tcsh, 44bsd-csh)$B$H(B
FreeBSD $B%Y!<%9%7%9%F%`(B ($B$=$l$>$l(B csh, tcsh) $B$K4^$^$l$F$$$^$9(B.

II.  $BLdBj$N>\:Y(B - Problem Description

The csh and tcsh code creates temporary files when the '<<' operator
is used, however these are created insecurely and use a predictable
filename based on the process ID of the shell.  An attacker can
exploit this vulnerability to overwrite an arbitrary file writable by
the user running the shell.  The contents of the file are overwritten
with the text being entered using the '<<' operator, so it will
usually not be under the control of the attacker.

csh $B$H(B tcsh $B$N%3!<%I$O(B, '<<' $B1i;;;R$,;H$o$l$k;~$K0l;~%U%!%$%k$r(B
$B:n@.$7$^$9(B.  $B$7$+$7(B, $B$=$N0l;~%U%!%$%k$O%;%-%e%j%F%#$r9MN8$;$:$K(B
$B:n@.$5$l(B, $B%7%'%k$N%W%m%;%9(B ID $B$K4p$E$$$?M=B,2DG=$J%U%!%$%kL>$r(B
$B;H$$$^$9(B.  $B$=$N$?$a(B, $B967b<T$O$3$N<eE@$r0-MQ$7$F(B, $B%7%'%k$r<B9T$7$F$$$k(B
$B%f!<%6$,=q$-9~$_2DG=$JG$0U$N%U%!%$%k$r>e=q$-$9$k$3$H$,$G$-$F$7$^$$$^$9(B.
$B$?$@$7(B, $B$=$N%U%!%$%k$NFbMF$O(B '<<' $B1i;;;R$r;H$C$FF~NO$5$l$k%F%-%9%H$K$h$C$F(B
$B>e=q$-$5$l$k$?$a(B, $BDL>o$N<jCJ$G967b<T$,FbMF$rA*Br$9$k$3$H$OIT2DG=$G$9(B.

Therefore the likely impact of this vulnerability is a denial of
service since the attacker can cause critical files writable by the
user to be overwritten.  It is unlikely, although possible depending
on the circumstances in which the '<<' operator is used, that the
attacker could exploit the vulnerability to gain privileges (this
typically requires that they have control over the contents the target
file is overwritten with).

$B$7$?$,$C$F(B, $B$3$N%;%-%e%j%F%#>e$N<eE@$K$h$k<g$J1F6A$O(B,
$B0l<o$N%5!<%S%9K832967b$,2DG=$G$"$k$H$$$&E@$G$9(B.  $B$3$l$O(B, $B967b<T$,(B
$B$=$N%f!<%6$,=q$-9~$_8"8B$r;}$D(B, $B=EMW$J%7%9%F%`%U%!%$%k$r>e=q$-(B
$B$G$-$k$3$H$K$h$k$b$N$G$9(B.  '<<' $B1i;;;R$,;H$o$l$k>u67$K0MB8$9$k$N$G(B
$B40A4$K$OH]Dj$G$-$^$;$s$,(B, $B967b<T$,$3$N%;%-%e%j%F%#>e$N<eE@$r(B
$B0-MQ$7$F9b$$8"8B$r;}$D$H$$$&2DG=@-$OHs>o$KDc$$$H;W$o$l$^$9(B ($BDL>o(B,
$B9b$$8"8B$rF@$k$K$O(B, $B967bBP>]$N%U%!%$%k$K>e=q$-$5$l$kFbMF$r967b<T$,(B
$BA*Br$G$-$kI,MW$,$"$j$^$9(B).

All versions of FreeBSD prior to the correction date are vulnerable to
this problem: the /bin/csh shell included in the base system (which is
the same as /bin/tcsh in recent versions) as well as the tcsh
(versions prior to 6.09.03_1) and 44bsd-csh ports (versions prior to
44bsd-csh-20001106) in the ports collection.  The problems with the
base system shells and the 44bsd-csh port were resolved prior to the
release of FreeBSD 4.2.  The tcsh port was not fixed prior to the
release, but the port is disabled in FreeBSD 4.2 since the same
software exists in the base system.

$B=$@5F|0JA0$N$9$Y$F$N%P!<%8%g%s$N(B FreeBSD $B$,(B, $B$3$NLdBj$N1F6A$r<u$1$^$9(B.
FreeBSD $B%Y!<%9%7%9%F%`$K4^$^$l$k(B /bin/csh ($B:G6a$N%P!<%8%g%s$K4^$^$l$k(B
/bin/tcsh $B$bF1MM(B) $B$*$h$S(B, Ports Collection $B$K4^$^$l$k(B tcsh
(6.09.03_1 $B$h$jA0$N%P!<%8%g%s(B) $B$H(B 44bsd-csh (44bsd-csh-20001106 $B$h$j(B
$BA0$N%P!<%8%g%s(B) $B$N(B port $B$G$9(B.  $B%Y!<%9%7%9%F%`$K4^$^$l$k%7%'%k$H(B
44bsd-csh port $B$NLdBj$O(B, FreeBSD 4.2 $B$N8x3+A0$K=$@5$5$l$^$7$?(B.
tcsh port $B$O(B FreeBSD 4.2 $B$N8x3+A0$K=$@5$5$l$F$$$^$;$s$,(B,
FreeBSD 4.2 $B$N%Y!<%9%7%9%F%`$K$OF1$8%=%U%H%&%'%"$,B8:_$9$k$?$a(B,
$B$3$N(B port $B$OL58z2=$5$l$F$$$^$9(B.

III. $B1F6AHO0O(B - Impact

Unprivileged local users can cause an arbitrary file writable by a
victim to be overwritten when the victim invokes the '<<' operator in
csh or tcsh (e.g. from within a shell script).

$B9b$$8"8B$r;}$?$J$$%m!<%+%k%f!<%6$O(B, $B967bBP>]$N%f!<%6$,(B csh $B$b$7$/$O(B
tcsh $B$N(B '<<' $B1i;;;R$r(B ($B$?$H$($P%7%'%k%9%/%j%W%HCf$J$I$+$i(B) $B;H$C$?;~$K(B,
$B$=$N%f!<%6$,=q$-9~$_8"8B$r;}$C$F$$$kG$0U$N%U%!%$%k$r>e=q$-$9$k$3$H$,(B
$B$G$-$^$9(B.

If you have not installed the tcsh or 44bsd-csh ports on your
4.1.1-STABLE system dated after the correction date, your system is
not vulnerable to this problem.

tcsh $B$b$7$/$O(B 44bsd-csh $B$N(B port/package $B$r(B, $B=$@5F|0J9_$N(B
4.1.1-STABLE $B$K%$%s%9%H!<%k$7$F$$$J$1$l$P(B,
$B%7%9%F%`$K$3$NLdBj$K$h$k%;%-%e%j%F%#>e$N<eE@$O$"$j$^$;$s(B.


IV.  $B2sHrJ}K!(B - Workaround

None practical.
$B8=<BE*$J2sHrJ}K!$O$"$j$^$;$s(B.

V.   $B2r7h:v(B - Solution

Upgrade your vulnerable FreeBSD system to 4.1.1-STABLE after the
correction date, or patch your present system source code and
rebuild.
$B<eE@$r;}$C$?(B FreeBSD $B%7%9%F%`$r(B, $B=$@5F|0J9_$N(B
4.1.1-STABLE $B$K%"%C%W%0%l!<%I$9$k$+(B, $B8=:_$N%7%9%F%`$N%=!<%9%3!<%I$K(B
$B=$@5%Q%C%A$rE,MQ$7$F(B, $B%7%9%F%`$r:F%3%s%Q%$%k$7$F$/$@$5$$(B.

To patch your present system: download the relevant patch from the
below location, and execute the following commands as root:

$B8=:_$N%7%9%F%`$K=$@5%Q%C%A$rE,MQ$9$k$K$O(B, $B$=$l$>$lBP1~$9$k(B
$B=$@5%Q%C%A$r0J2<$N>l=j$+$i%@%&%s%m!<%I$7(B, root $B8"8B$G(B
$B<!$N%3%^%s%I$r<B9T$7$^$9(B.

[FreeBSD 4.x base system]
[FreeBSD 4.x $B%Y!<%9%7%9%F%`$N>l9g(B]

# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-00:76/tcsh.patch
# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-00:76/tcsh.patch.asc

Verify the detached PGP signature using your PGP utility.
PGP $B%f!<%F%#%j%F%#$r;H$C$F(B PGP $B=pL>$r3NG'$7$^$9(B.

cd /usr/src/contrib/tcsh
patch -p < /path/to/patch
cd /usr/src/bin/csh
make depend && make all install

[FreeBSD 3.x $B%Y!<%9%7%9%F%`$N>l9g(B]

# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-00:76/csh.patch
# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-00:76/csh.patch.asc

Verify the detached PGP signature using your PGP utility.
PGP $B%f!<%F%#%j%F%#$r;H$C$F(B PGP $B=pL>$r3NG'$7$^$9(B.

cd /usr/src/bin/csh
patch -p < /path/to/patch
make depend && make all install

[Ports collection]
[Ports Collection $B$N>l9g(B]

One of the following:
$B<!$N$$$:$l$+$K=>$C$F$/$@$5$$(B.

1) Upgrade your entire ports collection and rebuild the tcsh/44bsd-csh
port.
1) Ports Collection $BA4BN$r%"%C%W%0%l!<%I$7(B, tcsh $B$b$7$/$O(B
   44bsd-csh $B$N(B port $B$r:F9=C[$7$^$9(B.

2) Deinstall the old package and install a new package dated after the
correction date, obtained from:
2) $B8E$$(B ($BLuCm(B: tcsh $B$b$7$/$O(B 44bsd-csh $B$N(B) package $B$r%7%9%F%`$+$i:o=|$7(B,
   $B=$@5F|0J9_$K:n@.$5$l$??7$7$$(B package $B$r0J2<$N>l=j$+$i<hF@$7$F(B
   $B%$%s%9%H!<%k$7$^$9(B.

[tcsh]

ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-3-stable/shells/tcsh-6.09.03_1.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/shells/tcsh-6.09.03_1.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha/packages-4-stable/shells/tcsh-6.09.03_1.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/shells/tcsh-6.09.03_1.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha/packages-5-current/shells/tcsh-6.09.03_1.tgz

[44bsd-csh]

ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-3-stable/shells/44bsd-csh-20001106.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/shells/44bsd-csh-20001106.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha/packages-4-stable/shells/44bsd-csh-20001106.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/shells/44bsd-csh-20001106.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha/packages-5-current/shells/44bsd-csh-20001106.tgz

3) download a new port skeleton for the tcsh/44bsd-csh port from:
3) tcsh $B$b$7$/$O(B 44bsd-csh $B$N?7$7$$(B port $B%9%1%k%H%s$r0J2<$N>l=j$+$i(B
   $B%@%&%s%m!<%I$7(B, $B$=$l$r;H$C$F(B port $B$r:F9=C[$7$^$9(B.

http://www.freebsd.org/ports/

and use it to rebuild the port.

4) Use the portcheckout utility to automate option (3) above.  The
portcheckout port is available in /usr/ports/devel/portcheckout or the
package can be obtained from:
4) $B>e5-(B (3) $B$NA`:n$r<+F0E*$K9T$J$&(B portcheckout $B%f!<%F%#%j%F%#$r;H$$$^$9(B.
   portcheckout $B$N(B port $B$O(B /usr/ports/devel/portcheckout $B$K$"$j$^$9(B.
   $B$^$?(B, portcheckout $B$N(B package $B$,0J2<$N>l=j$+$iF~<j2DG=$G$9(B.

ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-3-stable/devel/portcheckout-2.0.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/devel/portcheckout-2.0.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha/packages-4-stable/devel/portcheckout-2.0.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/devel/portcheckout-2.0.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha/packages-5-current/devel/portcheckout-2.0.tgz

$hrs: FreeBSD-SA/00:76,v 1.1 2000/11/21 16:31:14 hrs Exp $

----Next_Part(Wed_Nov_22_01:40:28_2000_737)----
