From owner-doc-jp-work@jp.FreeBSD.org Wed Mar 13 00:35:47 2002
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id g2CFZlq35491;
	Wed, 13 Mar 2002 00:35:47 +0900 (JST)
	(envelope-from owner-doc-jp-work@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 g2CFZlc35486
	for <doc-jp-work@jp.FreeBSD.org>; Wed, 13 Mar 2002 00:35:47 +0900 (JST)
	(envelope-from hrs@eos.ocn.ne.jp)
Received: from mail.hrslab.yi.org (p18075-adsao09hon-acca.tokyo.ocn.ne.jp [61.127.132.75])
	by eos.ocn.ne.jp (OCN) with ESMTP id AAA14871
	for <doc-jp-work@jp.FreeBSD.org>; Wed, 13 Mar 2002 00:35:46 +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 AAA00706
	for <doc-jp-work@jp.FreeBSD.org>; Wed, 13 Mar 2002 00:35:41 +0900 (JST)
	(envelope-from hrs@eos.ocn.ne.jp)
Date: Wed, 13 Mar 2002 00:34:51 +0900 (JST)
Message-Id: <20020313.003451.41654937.hrs@eos.ocn.ne.jp>
To: doc-jp-work@jp.FreeBSD.org
From: Hiroki Sato <hrs@eos.ocn.ne.jp>
In-Reply-To: <200203121427.g2CERps64246@freefall.freebsd.org>
References: <200203121427.g2CERps64246@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(Wed_Mar_13_00:34:51_2002_080)--"
Content-Transfer-Encoding: 7bit
Reply-To: doc-jp-work@jp.FreeBSD.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+020312
X-Sequence: doc-jp-work 302
Subject: [doc-jp-work 302] Re: ANNOUNCE: FreeBSD Ports Security Advisory
 FreeBSD-SA-02:14.pam-pgsql
Errors-To: owner-doc-jp-work@jp.FreeBSD.org
Sender: owner-doc-jp-work@jp.FreeBSD.org
X-Originator: hrs@eos.ocn.ne.jp

----Next_Part(Wed_Mar_13_00:34:51_2002_080)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

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

 02:14 $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(Wed_Mar_13_00:34:51_2002_080)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Disposition: inline; filename="02:14"
Content-Transfer-Encoding: 7bit

FreeBSD $B%;%-%e%j%F%#4+9p(B $BF|K\8lHG(B
=============================================================================
FreeBSD-SA-02:14 (2002-03-12)
 * pam-pgsql port authentication bypass
=============================================================================

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

  Subject: ANNOUNCE: FreeBSD Ports Security Advisory FreeBSD-SA-02:14.pam-pgsql
  From: FreeBSD Security Advisories <security-advisories@FreeBSD.ORG>
  Date: Tue, 12 Mar 2002 06:27:51 -0800 (PST)
  Message-Id: <200203121427.g2CERpd64254@freefall.freebsd.org>
  X-Sequence: announce-jp 946

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

 $B86J8$O(B PGP $B=pL>$5$l$F$$$^$9$,!"$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!"86J8$r;2>H$7$F$/$@$5$$!#(B

 $BF|K\8lLu$*$h$S!"%_%i!<%5%$%HMxMQ$N>\:Y$K$D$$$F$O!"J8Kv$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:14                                            Security Advisory
                                                                FreeBSD, Inc.

$B%H%T%C%/(B:	pam-pgsql $B$N(B port $B$K$*$1$kG'>Z$N5!G=ITA4(B
		(pam-pgsql port authentication bypass)

$BJ,N`(B:		ports
$B%b%8%e!<%k(B:	pam-pgsql
$B9pCNF|(B:		2002-03-12
$B%/%l%8%C%H(B:	Jacques A. Vidrine <nectar@FreeBSD.org>
$B1F6AHO0O(B:	pam-pgsql-0.5.2 $B$h$jA0$N(B pam-pgsql port
$B=$@5F|(B:		2002-01-21 20:06:05 UTC
FreeBSD $B$K8GM-$+(B:	NO


I.   $BGX7J(B - Background

pam-pgsql is a PAM module which allows PAM-enabled applications such
as login(1) to use a PostgreSQL database for user authentication.

pam-pgsql $B$O(B login(1) $B$J$I$N(B PAM $BBP1~%"%W%j%1!<%7%g%s$K$*$$$F!"(B
$B%f!<%6G'>Z$K(B PostgreSQL $B%G!<%?%Y!<%9$r;HMQ2DG=$K$9$k$?$a$N(B
PAM $B%b%8%e!<%k$G$9!#(B


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

The affected versions of the pam-pgsql port contain a vulnerability
that may allow a remote user to cause arbitrary SQL code to be
executed.  pam-pgsql constructs a SQL statement to be executed by the
PostgreSQL server in order to lookup user information, verify user
passwords, and change user passwords.  The username and password given
by the user is inserted into the SQL statement without any quoting or
other safety checks.

$BLdBj$r;}$C$?%P!<%8%g%s$N(B pam-pgsql $B$N(B port $B$K$O!"%j%b!<%H%f!<%6$K(B
$BG$0U$N(B SQL $B%3!<%I$r<B9T2DG=$K$9$k$h$&$J%;%-%e%j%F%#>e$N<eE@$,(B
$B4^$^$l$F$$$^$9!#(Bpam-pgsql $B$O!"%f!<%6>pJs$N>H2q!"%f!<%6%Q%9%o!<%I$N(B
$B>H9g!"%f!<%6%Q%9%o!<%I$NJQ99$r9T$J$&$?$a$K!"(BPostgreSQL $B%5!<%P$G(B
$B<B9T$9$k(B SQL $BJ8$r@8@.$7$^$9!#$=$N:]!"%f!<%6$+$i;XDj$5$l$k%f!<%6L>$H(B
$B%Q%9%o!<%I$O!"%/%)!<%H=hM}$J$I$N0BA4@-$N%A%'%C%/$,$^$C$?$/(B
$B9T$J$o$l$J$$$^$^!"$=$N(B SQL $BJ8$KA^F~$5$l$^$9!#(B

The pam-pgsql port is not installed by default, nor is it "part of
FreeBSD" as such: it is part of the FreeBSD ports collection, which
contains thousands of 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.

pam-pgsql $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?t@i8D$K$*$h$V%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$N%;%-%e%j%F%#>e$N<eE@$O(B FreeBSD 4.5 $B$N%j%j!<%98e$KH=L@$7$?$b$N$G!"(B
FreeBSD 4.5 $B$K<}O?$5$l$?(B Ports Collection $B$K$b!"$3$NLdBj$,4^$^$l$F$$$^$9(B.

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.

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, $B$$$+$J$kJ]>Z$b$7$F$$$^$;$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

A user interacting with a PAM-enabled application may insert arbitrary
SQL code into the username or password fields during authentication or
while changing passwords, leading to several exploit opportunities.
In all versions of the pam-pgsql port prior to 0.5.2, attackers may
add or change user account records.  In addition, in versions of the
pam-pgsql port prior to 0.3, attackers may cause pam-pgsql to
completely bypass password authentication, allowing them to
authenticate as any user and obtain unauthorized access using the
PAM-enabled application.  Since common PAM applications include
login(1) and sshd(8), both local and remote attacks are possible.

PAM $B$KBP1~$7$?%"%W%j%1!<%7%g%s$rMxMQ$7$F$$$k%f!<%6$O!"%f!<%6G'>Z$d(B
$B%Q%9%o!<%I$NJQ99;~$K%f!<%6L>$d%Q%9%o!<%I$NF~NOItJ,$XG$0U$N(B SQL $B%3!<%I$r(B
$BA^F~$9$k$3$H$G!"%;%-%e%j%F%#>e$N<eE@$r0-MQ$G$-$k2DG=@-$,$"$j$^$9!#(B
0.5.2 $B$h$jA0$N$9$Y$F$N(B pam-pgsql $B$N(B port $B$K$*$$$F!"967b<T$O(B
$B%f!<%6%"%+%&%s%H%l%3!<%I$NDI2C!"JQ99$r9T$J$&$3$H$,2DG=$G$9!#(B
$B$^$?!"(B0.3 $B$h$jA0$N(B  pam-pgsql $B$N(B port $B$G$O!"$=$l$K2C$($F(B
$B%Q%9%o!<%IG'>Z$r40A4$K1*2s$9$k$3$H$,$G$-$k$?$a!"967b<T$OB>$N%f!<%6$r(B
$BAu$C$FG'>Z$r9T$J$C$?$j!"(BPAM $BBP1~%"%W%j%1!<%7%g%s$r;H$C$?(B
$BIT@5$J%"%/%;%9$r<B8=$9$k$3$H$,2DG=$K$J$j$^$9!#NI$/;H$o$l$F$$$k(B
PAM $BBP1~%"%W%j%1!<%7%g%s$K$O(B login(1) $B$*$h$S(B sshd(8) $B$,(B
$B4^$^$l$F$$$k$?$a!"%m!<%+%k$H%j%b!<%H$NN>J}$+$i$N967b$,2DG=$G$9!#(B


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

1) Deinstall the pam-pgsql port/package if you have it installed.

1) pam-pgsql $B$N(B port/package $B$,%$%s%9%H!<%k$5$l$F$$$k>l9g$O!"(B
   $B$=$l$r%7%9%F%`$+$i:o=|$7$^$9!#(B


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

$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 pam-pgsql $B$N(B port $B$r:F9=C[$9$k!#(B

2) Download a new port skeleton for the pam-pgsql port from:
2) pam-pgsql $B$N?7$7$$(B port $B%9%1%k%H%s$r0J2<$N>l=j$+$i%@%&%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.

3) Use the portcheckout utility to automate option (2) above. The
portcheckout port is available in /usr/ports/devel/portcheckout or the
package can be obtained from:
3) $B>e5-(B (2) $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/Latest/portcheckout.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$K$*$$$F!"(B
$B:#2s=$@5$5$l$?%U%!%$%k$N(B $FreeBSD$ $B%j%S%8%g%sHV9f$G$9!#(B

Path                                                             Revision
$B%Q%9L>(B                                                           $B%j%S%8%g%s(B
- -------------------------------------------------------------------------
ports/security/pam-pgsql/Makefile                                     1.9
ports/security/pam-pgsql/distinfo                                     1.3
ports/security/pam-pgsql/pkg-descr                                    1.2
- -------------------------------------------------------------------------


VII. $B;29M;qNA(B - References

This vulnerability is very similar to previous vulnerabilities
involving Apache modules and discovered by RUS-CERT.
<URL:http://cert.uni-stuttgart.de/advisories/apache_auth.php>

$B$3$N%;%-%e%j%F%#>e$N<eE@$O!"0JA0$K(B RUS-CERT $B$GH/8+$5$l$?(B
Apache $B%b%8%e!<%k$N<eE@$HHs>o$KNI$/;w$?$b$N$G$9!#(B
<URL:http://cert.uni-stuttgart.de/advisories/apache_auth.php>


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!#2a5n$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!"K]Lu<T$*$h$S(B doc-jp $B$O!"$=$NFbMF$K$D$$$F$$$+$J$kJ]>Z$b(B
$B$$$?$7$^$;$s$N$G$4Cm0U$/$@$5$$!#F|K\8lLu$K$D$$$F$N$40U8+!"$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!"F|K\$N%_%i!<%5%$%H$,B8:_$7$^$9!#(B
$B%M%C%H%o!<%/$N:.;($r4KOB$9$k$?$a!"$^$:$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^$`%_%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:14,v 1.1 2002/03/12 15:34:13 hrs Exp $

----Next_Part(Wed_Mar_13_00:34:51_2002_080)----
