Users login

Create an account »


Users login

Home » Hacking News » FreeBSD-SA-02:14-pam-pgsql port authentication bypass

FreeBSD-SA-02:14-pam-pgsql port authentication bypass

by Nikola Strahija on March 12th, 2002 pam-pgsql is a PAM module which allows PAM-enabled applications such as login(1) to use a PostgreSQL database for user authentication.

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.

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.

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.

III. 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.

IV. Workaround

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

V. Solution

One of the following:

1) Upgrade your entire ports collection and rebuild the port.

2) Download a new port skeleton for the pam-pgsql port from:

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:

VI. Correction details

The following list contains the revision numbers of each file that was
corrected in the FreeBSD Ports Collection.

Path Revision
- -------------------------------------------------------------------------
ports/security/pam-pgsql/Makefile 1.9
ports/security/pam-pgsql/distinfo 1.3
ports/security/pam-pgsql/pkg-descr 1.2
- -------------------------------------------------------------------------

Newsletter signup

Signup to our monthly newsletter and stay in touch with IT news!

Free E-books

We've got ebooks! But they're not online. :( Please give us a few days to bring downloads back.


Have something to say or just wanna drop us a line? Please keep this in mind: to spam, we reply with spam.

Contact us »