From owner-doc-jp@jp.FreeBSD.org Sat Jan 19 09:47:46 2002
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id g0J0lk261530;
	Sat, 19 Jan 2002 09:47:46 +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.11.6+3.4W/8.11.3) with ESMTP/inet id g0J0lkm61525
	for <doc-jp@jp.FreeBSD.org>; Sat, 19 Jan 2002 09:47:46 +0900 (JST)
	(envelope-from hrs@eos.ocn.ne.jp)
Received: from mail.hrslab.yi.org (p5126-ip02funabasi.chiba.ocn.ne.jp [61.214.4.126])
	by eos.ocn.ne.jp (OCN) with ESMTP id JAA06441
	for <doc-jp@jp.FreeBSD.org>; Sat, 19 Jan 2002 09:47:43 +0900 (JST)
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 JAA40571
	for <doc-jp@jp.FreeBSD.org>; Sat, 19 Jan 2002 09:46:40 +0900 (JST)
	(envelope-from hrs@eos.ocn.ne.jp)
Date: Sat, 19 Jan 2002 09:44:51 +0900 (JST)
Message-Id: <20020119.094451.41634230.hrs@eos.ocn.ne.jp>
To: doc-jp@jp.FreeBSD.org
From: Hiroki Sato <hrs@eos.ocn.ne.jp>
In-Reply-To: <200201181356.g0IDuhS95323@freefall.freebsd.org>
References: <200201181356.g0IDuhS95323@freefall.freebsd.org>
X-Mailer: Mew version 2.1 on Emacs 20.7 / Mule 4.0 (HANANOEN)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Sat_Jan_19_09:44:51_2002_313)--"
Content-Transfer-Encoding: 7bit
Reply-To: doc-jp@jp.FreeBSD.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+011218
X-Sequence: doc-jp 8630
Subject: [doc-jp 8630] Re: ANNOUNCE: FreeBSD Security Advisory FreeBSD-SA-02:07.k5su
Errors-To: owner-doc-jp@jp.FreeBSD.org
Sender: owner-doc-jp@jp.FreeBSD.org
X-Originator: hrs@eos.ocn.ne.jp

----Next_Part(Sat_Jan_19_09:44:51_2002_313)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

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

 02:07 $B$G$9!#(B

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

----Next_Part(Sat_Jan_19_09:44:51_2002_313)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Disposition: inline; filename="02:07"
Content-Transfer-Encoding: 7bit


FreeBSD $B%;%-%e%j%F%#4+9p(B $BF|K\8lHG(B
=============================================================================
FreeBSD-SA-02:07 (2002-01-18)
 * Kerberos 5 su command uses getlogin for authorization
=============================================================================

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

  Subject: ANNOUNCE: FreeBSD Security Advisory FreeBSD-SA-02:07.k5su
  From: FreeBSD Security Advisories <security-advisories@FreeBSD.ORG>
  Date: Fri, 18 Jan 2002 05:56:43 -0800 (PST)
  Message-Id: <200201181356.g0IDuh995329@freefall.freebsd.org>
  X-Sequence: announce-jp 908

 $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=$@5%Q%C%AEy$NFbMF$,2~$6$s$5$l$F$$$J$$$3$H$r3NG'$9$k$?$a$K(B PGP $B=pL>$N(B
 $B%A%'%C%/$r9T$J$&$K$O(B, $B86J8$r;2>H$7$F$/$@$5$$(B. 

 $BF|K\8lLu$*$h$S(B, $B%_%i!<%5%$%HMxMQ$N>\:Y$K$D$$$F$O(B, $BJ8Kv$N!V(BA. FreeBSD
 $B%;%-%e%j%F%#4+9p(B $BF|K\8lHG$K$D$$$F!W$r$4Mw$/$@$5$$(B.


                                     [$BK]Lu<T(B: $B:4F#(B $B9-@8(B <hrs@jp.FreeBSD.org>]
--($B$3$3$+$i(B)
=============================================================================
FreeBSD-SA-02:07                                            Security Advisory
                                                                FreeBSD, Inc.

$B%H%T%C%/(B:	Kerberos 5 su $B%3%^%s%I$,G'>Z$K(B getlogin $B$r;HMQ$7$F$$$kLdBj(B
                (Kerberos 5 su command uses getlogin for authorization)

$BJ,N`(B:		krb5, ports
$B%b%8%e!<%k(B:	crypto/heimdal/appl/su, heimdal
$B9pCNF|(B:		2002-01-18
$B%/%l%8%C%H(B:	Aaron <lumpy@musicvision.com>
$B1F6AHO0O(B:	FreeBSD 4.4-RELEASE
                $B=$@5F|0JA0$N(B FreeBSD 4.4-STABLE
                $B=$@5F|0JA0$N(B Ports Collection
$B=$@5F|(B:		2002-01-15 21:52:48 UTC (RELENG_4)
                2002-01-17 15:45:05 UTC (RELENG_4_4)
                2002-10-31 19:58:05 UTC (heimdal port)
FreeBSD $B$K8GM-$+(B:	NO


I.   $BGX7J(B - Background

The getlogin and setlogin system calls are used to manage the user
name associated with a login session.

getlogin $B$*$h$S(B setlogin $B$O(B, $B%m%0%$%s%;%7%g%s$K;H$o$l$k(B
$B%f!<%6L>$r4IM}$9$k$?$a$K;H$o$l$k%7%9%F%`%3!<%k$G$9(B.

k5su is a Kerberos 5-enabled su program.  Like su, it allows
authorized users to `switch user' in order to obtain additional
privileges.

k5su $B$O(B Kerberos 5 $B$KBP1~$7$?(B su $B%W%m%0%i%`$G$9(B.  $B$3$l$O(B su $B$H(B
$BF1$8$h$&$K(B, $B$=$l$r5v$5$l$?%f!<%6$,9b$$8"8B$rF@$k$?$a$K(B
$B%f!<%6$N@Z$jBX$((B (switch user) $B$r<B8=$7$^$9(B.


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

The setlogin system call, the use of which is restricted to the
superuser, is used to associate a user name with a login session.  The
getlogin system call is used to retrieve that user name.  The setlogin
system call is typically used by applications such as login and sshd.

setlogin $B%7%9%F%`%3!<%k$O%9!<%Q%f!<%6$N$_$,MxMQ$G$-$k$b$N$G(B,
$B%m%0%$%s%;%7%g%s$K%f!<%6L>$r3d$jEv$F$k$?$a$K;H$o$l$^$9(B.
getlogin $B%7%9%F%`%3!<%k$O(B, $B$=$N3d$jEv$F$i$l$?%f!<%6L>$rF@$k$?$a$K(B
$B;H$$$^$9(B.  setlogin $B%7%9%F%`%3!<%k$ODL>o(B, login $B$d(B sshd $B$N$h$&$J(B
$B%"%W%j%1!<%7%g%s%W%m%0%i%`$+$i;HMQ$5$l$^$9(B.

The k5su command included with FreeBSD, versions prior to 4.5-RELEASE,
and the su command included in the heimdal port, versions prior to
heimdal-0.4e_2, use the getlogin system call in order to determine
whether the currently logged-in user is `root'.  In some
circumstances, it is possible for a non-privileged process to have
`root' as the login name returned by getlogin.

4.5-RELEASE $B$h$jA0$N(B FreeBSD $B$K4^$^$l$k(B k5su $B%3%^%s%I$*$h$S(B,
heimdal-0.4e_2 $B$h$jA0$N(B heimdal $B$N(B port $B$K4^$^$l$k(B su $B%3%^%s%I$K$O(B,
$B8=:_%m%0%$%s$7$F$$$k%f!<%6$,(B root $B$+$I$&$+D4$Y$k$?$a$K(B getlogin $B%7%9%F%`(B
$B%3!<%k$r;H$$$^$9(B.  $B$7$+$7$"$k>r7o2<$G$O(B, $B%W%m%;%9$,9b$$8"8B$r;}$?$J$$(B
$B$K$b$+$+$o$i$:(B, getlogin $B$+$iJV$5$l$k%f!<%6L>$,(B root $B$K$J$k2DG=@-$,$"$j$^$9(B.

The `k5su' command may be installed as part of FreeBSD when Kerberos 5
support is requested, or it may be installed from the FreeBSD Ports
Collection (ports/security/heimdal), in which case it is installed
simply as `su'.

k5su $B%3%^%s%I$O(B Kerberos 5 $B$r;XDj$7$?;~$K(B FreeBSD $B$N0lIt$H$7$F(B
$B%$%s%9%H!<%k$9$k$3$H$,$G$-$^$9(B.  $B$^$?(B, FreeBSD Ports Collection
(ports/security/heimdal) $B$+$i%$%s%9%H!<%k$9$k$3$H$b2DG=$G$9(B.
$B$=$N>l9g(B, $B%3%^%s%IL>$O(B su $B$K$J$j$^$9(B.

The Heimdal port is not installed by default, nor is it "part of
FreeBSD" as such: it is part of the FreeBSD ports collection, which
contains over 6000 third-party applications in a ready-to-install
format. The ports collection shipped with FreeBSD 4.4 contains this
problem since it was discovered after the release.

FreeBSD makes no claim about the security of these third-party
applications, although an effort is underway to provide a security
audit of the most security-critical ports.

Heimdal $B$N(B port $B$O%G%U%)%k%H$G%$%s%9%H!<%k$5$l$k$b$N$G$O$J$/(B,
$B!V(BFreeBSD $B%7%9%F%`$N0lIt!W$r9=@.$9$k$b$N$G$b$"$j$^$;$s(B.
$B$=$l$i$O(B 6000 $B$r1[$($k%5!<%I%Q!<%F%#@=%"%W%j%1!<%7%g%s$,$9$0$K(B
$B%$%s%9%H!<%k$G$-$k7A$G<}$a$i$l$F$$$k(B FreeBSD Ports Collection $B$N0lIt$G$9(B.
$B$3$NLdBj$O(B FreeBSD 4.4 $B$N%j%j!<%98e$KH/8+!&=$@5$5$l$?$?$a(B,
FreeBSD 4.4 $B$K$O$3$NLdBj$K$h$k%;%-%e%j%F%#>e$N<eE@$,4^$^$l$F$$$^$9(B.

FreeBSD $B$G$O(B, $B$3$N$h$&$J%5!<%I%Q!<%F%#@=%"%W%j%1!<%7%g%s$N%;%-%e%j%F%#(B
$BLdBj$KBP$7$F(B, $BFC$K2?$+$r<gD%$9$k$3$H$O$"$j$^$;$s(B ($BLuCm(B: Ports Collection $B$K(B
$BF~$C$F$$$k$+$i$H$$$C$F(B, FreeBSD $B$N3+H/<T$?$A$,$=$N%"%W%j%1!<%7%g%s$,(B
$B0BA4$G$"$k$HI>2A$7$?$o$1$G$O$"$j$^$;$s(B).  $B$?$@$7(B, $B%;%-%e%j%F%#LdBj$KBP$7$F(B
$BBg$-$J1F6A$r;}$D$h$&$J(B ports $B$KBP$9$k%;%-%e%j%F%#4F::$rDs6!$9$Y$/(B,
$B8=:_EXNOCf$G$9(B.


III. $B1F6AHO0O(B - Impact

In some circumstances, process that have been started by root but have
given up superuser privileges may be able to invoke `k5su' to regain
superuser privileges.

$B$"$k>r7o2<$G$O(B, root $B$K$h$C$F<B9T$5$l(B, $B$=$N8e$K%9!<%Q%f!<%68"8B$r(B
$BJ|4~$7$?%W%m%;%9$+$i(B k5su $B$r8F$S=P$9$3$H$G(B, $B$=$N%W%m%;%9$,(B
$B:F$S%9!<%Q%f!<%68"8B$rF@$k$3$H$,$G$-$k2DG=@-$,$"$j$^$9(B.


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

Commands to be executed as root are signified by lines starting with
the `#' character.

$B0J2<(B, `#' $B$H$$$&J8;z$G;O$^$C$F$$$k9T$O(B root $B8"8B$G(B
$B<B9T$7$J$1$l$P$J$i$J$$%3%^%s%I$G$9(B.

[Kerberos 5 in the base system]
[$B%Y!<%9%7%9%F%`$K(B Kerberos 5 $B$,4^$^$l$F$$$k>l9g(B]

Remove the set-user-ID bit from the `k5su' executable by running the
following command as root:

root $B8"8B$G<!$N%3%^%s%I$r<B9T$7(B, k5su $B<B9T%U%!%$%k$N(B
set-user-ID $B%S%C%H$r:o=|$7$^$9(B.

# chmod u-s /usr/bin/k5su

[Heimdal port]

Remove the set-user-ID bit from the `su' executable by running the
following command as root:

root $B8"8B$G<!$N%3%^%s%I$r<B9T$7(B, su $B<B9T%U%!%$%k$N(B
set-user-ID $B%S%C%H$r:o=|$7$^$9(B.

# chmod u-s /usr/local/bin/su


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

[Kerberos 5 in the base system]
[$B%Y!<%9%7%9%F%`$K(B Kerberos 5 $B$,4^$^$l$F$$$k>l9g(B]

NOTE: If the file /usr/bin/k5su does not exist on your system,
Kerberos 5 is not installed and you do not need to take any action.

$BCm0U(B: /usr/bin/k5su $B$H$$$&%U%!%$%k$,%7%9%F%`$K4^$^$l$F$$$J$1$l$P(B,
      Kerberos 5 $B$O%$%s%9%H!<%k$5$l$F$$$^$;$s$N$G(B, $BBP:v$NI,MW$O$"$j$^$;$s(B.

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

1) Upgrade your system to 4.4-STABLE or the RELENG_4_4 security
branch, dated after the respective correction dates.
1) $B<eE@$r;}$C$?(B FreeBSD $B%7%9%F%`$r(B, $B$=$l$>$l=$@5F|0J9_$N(B
   4.4-STABLE, RELENG_4_4 $B%;%-%e%j%F%#%V%i%s%A$K%"%C%W%0%l!<%I$9$k(B.

2) To patch your present system:
2) $B8=:_$N%7%9%F%`$K=$@5%Q%C%A$rE,MQ$9$k(B.

The following patch has been verified to apply to FreeBSD 4.4-RELEASE
and 4.4-STABLE dated prior to the correction date.  It may or may not
apply to older, unsupported versions of FreeBSD.

$B<!$N=$@5%Q%C%A$O(B, FreeBSD 4.4-RELEASE, $B=$@5F|0JA0$N(B 4-STABLE $B$K(B
$BBP$7$FE,MQ2DG=$J$3$H$,3NG'$5$l$F$$$k$b$N$G$9(B.  $B$=$l$h$j$b8E$$%j%j!<%9$d(B
$B%5%]!<%H$5$l$F$$$J$$(B FreeBSD $B%j%j!<%9$KBP$7$F$O(B, $B$3$l$i$N=$@5%Q%C%A$,(B
$B@5$7$/E,MQ$G$-$J$$2DG=@-$,$"$j$^$9(B.

Download the patch and the detached PGP signature from the following
locations, and verify the signature using your PGP utility.

$B=$@5%Q%C%A$H(B PGP $B=pL>$r<!$N>l=j$+$i%@%&%s%m!<%I$7$F(B,
PGP $B%f!<%F%#%j%F%#$r;H$C$F(B PGP $B=pL>$r3NG'$7$^$9(B.

# fetch ftp://ftp.freebsd.org/pub/FreeBSD/CERT/patches/SA-02:07/k5su.patch
# fetch ftp://ftp.freebsd.org/pub/FreeBSD/CERT/patches/SA-02:07/k5su.patch.asc

Execute the following commands as root:

$B$=$7$F(B root $B8"8B$G0J2<$N%3%^%s%I$r<B9T$7$^$9(B.

# cd /usr/src
# patch < /path/to/k5su.patch
# cd /usr/src/kerberos5/lib
# env MAKE_KERBEROS5=yes make depend
# env MAKE_KERBEROS5=yes make all install
# cd /usr/src/kerberos5/usr.bin/k5su
# env MAKE_KERBEROS5=yes make depend
# env MAKE_KERBEROS5=yes make all install

[Heimdal port]

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

1) Upgrade your entire ports collection and rebuild the port.
1) Ports Collection $BA4BN$r%"%C%W%0%l!<%I$7(B heimdal $B$N(B port $B$r:F9=C[$9$k(B.

2) Deinstall the old package and install a new package dated after the
correction date, obtained from the following directories:
2) $B8E$$(B ($BLuCm(B: heimdal $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(B
   $B<hF@$7$F%$%s%9%H!<%k$9$k(B.

[i386]
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/security/heimdal-0.4e_2.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/security/heimdal-0.4e_2.tgz

[alpha]
Packages are not automatically generated for the alpha architecture at
this time due to lack of build resources.
$B8=;~E@$G$O(B alpha $B%"!<%-%F%/%A%cMQ$N(B package $B$O<+F0@8@.$5$l$F$$$^$;$s(B.
$B$3$l$O(B, $B9=C[$N$?$a$N%^%7%s%j%=!<%9$,ITB-$7$F$$$k$?$a$G$9(B.

3) Download a new port skeleton for the heimdal port from:
3) heimdal $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[$9$k(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$&(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-4-stable/devel/portcheckout-2.0.tgz
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-current/devel/portcheckout-2.0.tgz


VI.  $B=$@5$N>\:Y(B - Correction details

The following list contains the revision numbers of each file that was
corrected in the FreeBSD ports collection.
$B<!$NI=$O(B FreeBSD Ports Collection $B$K4^$^$l$F$$$k(B,
$B:#2s=$@5$5$l$?%=!<%9%U%!%$%k$N(B $FreeBSD$ $B%j%S%8%g%sHV9f$G$9(B.

[Kerberos 5 in the base system]
[$B%Y!<%9%7%9%F%`$K4^$^$l$F$$$k(B Kerberos 5]

Path                                                             Revision
$B%Q%9L>(B                                                       $B%j%S%8%g%sHV9f(B
  Branch
  $B%V%i%s%A(B
- -------------------------------------------------------------------------
src/crypto/heimdal/appl/su/su.c
  HEAD                                                            1.1.1.4
  RELENG_4                                                    1.1.1.1.2.2
  RELENG_4_4                                              1.1.1.1.2.1.4.1
  RELENG_4_3                                              1.1.1.1.2.1.2.1
- -------------------------------------------------------------------------

[Heimdal port]

Path                                                             Revision
$B%Q%9L>(B                                                       $B%j%S%8%g%sHV9f(B
- -------------------------------------------------------------------------
ports/security/heimdal/Makefile                                      1.46
ports/security/heimdal/patch-appl::su::su.c                           1.1
- -------------------------------------------------------------------------


A.   FreeBSD $B%;%-%e%j%F%#4+9p(B $BF|K\8lHG$K$D$$$F(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$9(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.  

$B$?$@$7(B, $BK]Lu<T$*$h$S(B doc-jp $B$O(B, $B$=$NFbMF$K$D$$$F$$$+$J$kJ]>Z$b(B
$B$$$?$7$^$;$s$N$G$4Cm0U$/$@$5$$(B.  $BF|K\8lLu$K$D$$$F$N$40U8+(B, $B$4MWK>(B,
$B$*Ld$$9g$o$;Ey$O(B doc-jp@jp.FreeBSD.org $B$^$G$*4j$$$7$^$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%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.

$BF|K\$N%_%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.

$BB>$NCO0h$r4^$`(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$^$H$a$i$l$F$$$^$9(B.

$hrs: announce-jp/FreeBSD-SA/02:07,v 1.1 2002/01/19 00:41:41 hrs Exp $

----Next_Part(Sat_Jan_19_09:44:51_2002_313)----
