X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C4788D1B346 for ; Tue, 11 May 2004 07:04:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 52773-09 for ; Tue, 11 May 2004 07:03:59 -0300 (ADT) Received: from kiwi.inf.tu-dresden.de (kiwi.inf.tu-dresden.de [141.76.1.118]) by svr1.postgresql.org (Postfix) with ESMTP id 39BABD1B341 for ; Tue, 11 May 2004 07:03:56 -0300 (ADT) Received: from pitt by kiwi.inf.tu-dresden.de with local (Exim) id 1BNU7C-0000oD-00; Tue, 11 May 2004 12:03:58 +0200 Date: Tue, 11 May 2004 12:03:58 +0200 From: Martin Pitt To: pgsql-bugs@postgresql.org Cc: 247306@bugs.debian.org Subject: Fwd: Bug#247306: odbc-postgresql: SIGSEGV with long inputs (> 10000 bytes) Message-ID: <20040511100357.GA23102@ifsr.de> Reply-To: 247306@bugs.debian.org, pgsql-bugs@postgresql.org Mail-Followup-To: pgsql-bugs@postgresql.org, 247306@bugs.debian.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lEGEL1/lMxI0MVQ2" Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/60 X-Sequence-Number: 8332 --lEGEL1/lMxI0MVQ2 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi PostgreSQL developers! A week ago we at Debian received the bug report below: due to a buffer overflow in psqlodbc it is possible to crash (and possibly exploit) apache. I already sent this mail to the psqlodbc list [1], but unfortunately got no response so far. So maybe there are some hackers here who can help with this? I can reliably reproduce the error (using the small attached php4 script), but I do not know anything about the psqlodbc internals. I would be glad if someone could assist me with that. Thanks in advance and have a nice day! Martin [1] http://archives.postgresql.org/pgsql-odbc/2004-05/msg00006.php ----- Forwarded message from delman ----- Subject: Bug#247306: odbc-postgresql: SIGSEGV with long inputs (> 10000 byt= es) Reply-To: delman , 247306@bugs.debian.org From: delman To: Debian Bug Tracking System Date: Tue, 04 May 2004 15:25:24 +0200 X-Spam-Status: No, hits=3D0.0 required=3D4.0 tests=3DSUBJ_BRACKET_BALANCED, SUBJ_BRACKET_OFF,SUBJ_BRACKET_ON autolearn=3Dno version=3D2.61 Package: odbc-postgresql Version: 1:07.03.0200-2 Severity: grave Tags: security Justification: user security hole I noticed Apache segfaulting when I feed a simple form with long inputs: [Tue May 4 11:32:10 2004] [notice] child pid 4084 exit signal Segmentatio= n fault (11) Such inputs are used by php function odbc_connect as username and password = to connect to a DSN using postgresql driver: $connection =3D @odbc_connect(DSN, $_POST['username'], $_POST['password']) The output of gdb is: (gdb) run -X -d apache [...] [Thread debugging using libthread_db enabled] [...] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1076569920 (LWP 832)] 0x44c3d627 in SOCK_put_next_byte () from /usr/lib/postgresql/lib/psqlodbc.= so Or: [same stuff here] 0x44c4c3d0 in strncpy_null () from /usr/lib/postgresql/lib/psqlodbc.so I suspect a security issue because playing around with long input strings o= f "A" I've been able to trigger in Apache error.log this message: =09 free(): invalid pointer 0x41414141! 0x41 is obviously one of my "A"... Other ODBC related messages found are: =09 /usr/sbin/apache: relocation error: AAAA[...]AAA: symbol getDSNdefaults, v= ersion not defined in file with link time reference The SIGSEGV is triggered with input strings > 10000 bytes. I use Apache/1.3= .29 (Debian GNU/Linux) PHP/4.3.4 mod_auth_pam/1.1.1 mod_ssl/2.8.16 OpenSSL/= 0.9.7c -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.4 Locale: LANG=3DC, LC_CTYPE=3DC Versions of packages odbc-postgresql depends on: ii libc6 2.3.2.ds1-11 GNU C Library: Shared librarie= s an ii odbcinst1 2.2.4-9 Support library and helper pro= gram -- no debconf information ----- End forwarded message ----- --=20 Martin Pitt Debian GNU/Linux Developer martin@piware.de mpitt@debian.org http://www.piware.de http://www.debian.org --vkogqOf2sHV7VnPd Content-Type: application/x-httpd-php Content-Disposition: attachment; filename="odbccrash.php" Content-Transfer-Encoding: quoted-printable ODBC Test

ODBC-Test

Unable to connect to db!

"; exit; } echo "

DB connection successful.

"; $res =3D odbc_exec( $cid, "select * from zahlung" ); if( !$res ) { echo "

Error with odbc_exec(): " . odbc_errormsg() . "

";=20 exit; } ?> \n"; } ?>
id Date Room Amount
" .=20 odbc_result( $res, 1 ) . "" .=20 odbc_result( $res, 2 ) . "" . odbc_result( $res, 3 ) . "" . odbc_result( $res, 4 ) . "
--vkogqOf2sHV7VnPd-- --lEGEL1/lMxI0MVQ2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD4DBQFAoKUMDecnbV4Fd/IRAhusAJYyG+z8c1FK86a/QnXNr1zo90ljAKCRScQM ejYRPmwnH83+fA1zkjXX0A== =sSOp -----END PGP SIGNATURE----- --lEGEL1/lMxI0MVQ2--