X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C8293D1DF5D for ; Thu, 29 Apr 2004 13:57:45 -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 78382-01 for ; Thu, 29 Apr 2004 13:57:25 -0300 (ADT) Received: from smtp-out4.xs4all.nl (smtp-out4.xs4all.nl [194.109.24.5]) by svr1.postgresql.org (Postfix) with ESMTP id 0A841D1CA32 for ; Thu, 29 Apr 2004 13:57:24 -0300 (ADT) Received: from localhost.localdomain (kiar.xs4all.nl [80.126.234.5]) by smtp-out4.xs4all.nl (8.12.10/8.12.10) with ESMTP id i3TGvOBT081659 for ; Thu, 29 Apr 2004 18:57:24 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 500) id EC580B6EC4; Thu, 29 Apr 2004 18:57:23 +0200 (CEST) Date: Thu, 29 Apr 2004 18:57:23 +0200 From: Joolz To: list-postgresql-php Subject: securing PHP/Postgresql (was: MD5 in pg and php) Message-ID: <20040429165723.GA18588@localhost.localdomain> Reply-To: pgsql-php@postgresql.org Mail-Followup-To: list-postgresql-php References: <20040429070716.GA6918@localhost.localdomain> <20040429101129.GC26489@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040429101129.GC26489@wolff.to> User-Agent: Mutt/1.4.1i 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: 200404/62 X-Sequence-Number: 2719 > [Bruno Wolff III schreef op 29-04-2004 05:11 -0500] > > On Thu, Apr 29, 2004 at 09:07:16 +0200, > Joolz wrote: > > > > I want to store passwords in a pg db, MD5 seems like a good way to > > enhance security (no more plaintext passwords over the line etc.) > > I had a look at MD5, in PHP 4.3.4 there is a function md5() which > > seems to work nicely: > > This may not help as much as you think. If you are using an ssl > connection, the passwords won't be sent in the clear. If you aren't > using an ssl connection the hashes will be in clear. I don't believe > the postgres uses a random challenge so that you won't really raise > the bar much. Plus if snooping passwords is a threat, most likely > snooping data will be as well (though not always) and forcing > connections to use ssl may be your best bet. I believe as typically > used this is vulnerable to man in the middle attacks, but these are > going to be significantly harder to do than simple snooping. Thanks for the tip. I already have things like: if (ini_get('register_globals') === 1) { say it's not safe, don't enter the application } and if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') { idem } in my login screen. Still, I would feel more assured if passwords go over the line md5()'d, even if that line is encrypted. I have other things to worry about next. Right now I let the user enter the pg username and password, store these values in session variables and use them every time a database connection is needed. Someone told me this is very insecure, as the session variables are stored in either /tmp on the server (that's where I have them put), in a local cookie or in the URL. Neither would be safe, a better approach would be to authenticicate once (by looking up the user + password in a table), and give access to certain tables, views etc. based on the result of the first lookup; the result being different roles in the organisation who have access to certain views etc. or a simple 'false' if the password is wrong. I have to think about it long and hard :-), the extra "layer" makes things more secure, I would only have to register username (for auditing purposes) plus the "role" in session variables, which could be md5()'d. Still, the extra layer is from a logical point of view redundant and thus errorprone. Still, it might be a good idea. If anyone cares to share their opinion on the matter (or discuss how you handled this), TIA! -- 18:38-18:57 Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2188.nptl