<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: encrypted passwords in database</title>
	<atom:link href="http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 21:40:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-29991</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Mon, 28 Jun 2010 19:51:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-29991</guid>
		<description>@need help:
it looks like crypt() with md5 algorithm, but with empty (or removed) salt.</description>
		<content:encoded><![CDATA[<p>@need help:<br />
it looks like crypt() with md5 algorithm, but with empty (or removed) salt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: need help</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-29990</link>
		<dc:creator>need help</dc:creator>
		<pubDate>Mon, 28 Jun 2010 19:38:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-29990</guid>
		<description>someone can help me!!
use what encryption this one
$1$$YT09lUh5xTp9kWFx8G2bV0

can someone encrypt for me??

thanks before</description>
		<content:encoded><![CDATA[<p>someone can help me!!<br />
use what encryption this one<br />
$1$$YT09lUh5xTp9kWFx8G2bV0</p>
<p>can someone encrypt for me??</p>
<p>thanks before</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kpy3</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-29937</link>
		<dc:creator>kpy3</dc:creator>
		<pubDate>Fri, 18 Jun 2010 14:03:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-29937</guid>
		<description>Oh! I&#039;ve missed it, thanx.</description>
		<content:encoded><![CDATA[<p>Oh! I&#8217;ve missed it, thanx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-29936</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Fri, 18 Jun 2010 12:55:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-29936</guid>
		<description>@kpy3:
that&#039;s because left is now keyword. just prefix variable names, and you&#039;ll be good.</description>
		<content:encoded><![CDATA[<p>@kpy3:<br />
that&#8217;s because left is now keyword. just prefix variable names, and you&#8217;ll be good.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kpy3</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-29935</link>
		<dc:creator>kpy3</dc:creator>
		<pubDate>Fri, 18 Jun 2010 12:31:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-29935</guid>
		<description>This doesn&#039;t work on PostgreSQL 9.0 beta 2, function password_beq fails with error 
ERROR:  syntax error at or near &quot;,&quot;
LINE 58:   left_crypted := ( substr(left, 1, 3) = &#039;$1$&#039; );
                                        ^


********** Error **********

ERROR: syntax error at or near &quot;,&quot;
SQL state: 42601
Character: 1404</description>
		<content:encoded><![CDATA[<p>This doesn&#8217;t work on PostgreSQL 9.0 beta 2, function password_beq fails with error<br />
ERROR:  syntax error at or near &#8220;,&#8221;<br />
LINE 58:   left_crypted := ( substr(left, 1, 3) = &#8216;$1$&#8217; );<br />
                                        ^</p>
<p>********** Error **********</p>
<p>ERROR: syntax error at or near &#8220;,&#8221;<br />
SQL state: 42601<br />
Character: 1404</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Harding</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-27129</link>
		<dc:creator>Ian Harding</dc:creator>
		<pubDate>Wed, 10 Dec 2008 17:34:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-27129</guid>
		<description>I was thinking of backups.  If I get your backups, I have everyone&#039;s password.  If the system doesn&#039;t allow passing the hash to log in, I just have a bunch of hashes that I have to crack.  THEN I have everyone&#039;s password.  But that takes a while.  

On the other point, if I crack your web server, I have database privileges as the web user account.  That should leave you only partially screwed since the web server connects as an unprivileged user.  It takes a whole other level of kung-fu to get to super user from there.  And it takes a while.

Anyway, not throwing rocks, this is an excellent intro to pgcrypto and custom operators.  Thanks!</description>
		<content:encoded><![CDATA[<p>I was thinking of backups.  If I get your backups, I have everyone&#8217;s password.  If the system doesn&#8217;t allow passing the hash to log in, I just have a bunch of hashes that I have to crack.  THEN I have everyone&#8217;s password.  But that takes a while.  </p>
<p>On the other point, if I crack your web server, I have database privileges as the web user account.  That should leave you only partially screwed since the web server connects as an unprivileged user.  It takes a whole other level of kung-fu to get to super user from there.  And it takes a while.</p>
<p>Anyway, not throwing rocks, this is an excellent intro to pgcrypto and custom operators.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-27123</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Tue, 09 Dec 2008 20:49:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-27123</guid>
		<description>@Ian Harding:
Well yes and no.

To get hashes bad guy would have to have database privileges, and in this situation we&#039;re screwed anyway. The point is that he/she will not be able to get the passwords to use them someplace else.</description>
		<content:encoded><![CDATA[<p>@Ian Harding:<br />
Well yes and no.</p>
<p>To get hashes bad guy would have to have database privileges, and in this situation we&#8217;re screwed anyway. The point is that he/she will not be able to get the passwords to use them someplace else.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Harding</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-27122</link>
		<dc:creator>Ian Harding</dc:creator>
		<pubDate>Tue, 09 Dec 2008 20:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-27122</guid>
		<description># select * from users where passwd = &#039;$1$Im51jH1k$/9AOm/t.4BixxF7YzZ5hx0&#039;;
id &#124; username &#124; passwd
----+----------+------------------------------------
1 &#124; depesz &#124; $1$Im51jH1k$/9AOm/t.4BixxF7YzZ5hx0
(1 row)

Doesn&#039;t this negate the whole thing?  I thought the purpose was to make the hashed values useless to a bad guy.  This makes them identical in function to the real passwords.</description>
		<content:encoded><![CDATA[<p># select * from users where passwd = &#8216;$1$Im51jH1k$/9AOm/t.4BixxF7YzZ5hx0&#8242;;<br />
id | username | passwd<br />
&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
1 | depesz | $1$Im51jH1k$/9AOm/t.4BixxF7YzZ5hx0<br />
(1 row)</p>
<p>Doesn&#8217;t this negate the whole thing?  I thought the purpose was to make the hashed values useless to a bad guy.  This makes them identical in function to the real passwords.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: &#60;/depesz&#62; &#187; Blog Archive &#187; smtp + sql = more than it seems so (part 3)</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-25214</link>
		<dc:creator>&#60;/depesz&#62; &#187; Blog Archive &#187; smtp + sql = more than it seems so (part 3)</dc:creator>
		<pubDate>Tue, 26 Feb 2008 08:54:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-25214</guid>
		<description>[...] now we have it. let&#8217;s check previous post from my blog, about password [...]</description>
		<content:encoded><![CDATA[<p>[...] now we have it. let&#8217;s check previous post from my blog, about password [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pythian Group Blog &#187; Blog Archive &#187; Log Buffer #70: a Carnival of the Vanities for DBAs</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24216</link>
		<dc:creator>Pythian Group Blog &#187; Blog Archive &#187; Log Buffer #70: a Carnival of the Vanities for DBAs</dc:creator>
		<pubDate>Fri, 09 Nov 2007 18:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24216</guid>
		<description>[...] with Postgres, on &lt;depesz&gt;, Hubert Lubaczewski hosts and exploration and discussion of encrypted passwords in the database. He endorses letting Postgres itself handle password encryption with the pgcrypto module from the [...]</description>
		<content:encoded><![CDATA[<p>[...] with Postgres, on &lt;depesz&gt;, Hubert Lubaczewski hosts and exploration and discussion of encrypted passwords in the database. He endorses letting Postgres itself handle password encryption with the pgcrypto module from the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24209</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Thu, 08 Nov 2007 02:04:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24209</guid>
		<description>@depesz:

However, I would like to add that if there is a legal requirement that you not store plaintext passwords, be very careful that no SQL statements get logged, and that no monitoring scripts watch pg_stat_activity. Otherwise a password might get saved in plaintext in a log or notification.</description>
		<content:encoded><![CDATA[<p>@depesz:</p>
<p>However, I would like to add that if there is a legal requirement that you not store plaintext passwords, be very careful that no SQL statements get logged, and that no monitoring scripts watch pg_stat_activity. Otherwise a password might get saved in plaintext in a log or notification.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24208</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Thu, 08 Nov 2007 02:02:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24208</guid>
		<description>@depesz:

Oh, I see. Makes sense, particularly the point about backups.</description>
		<content:encoded><![CDATA[<p>@depesz:</p>
<p>Oh, I see. Makes sense, particularly the point about backups.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24207</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Wed, 07 Nov 2007 19:55:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24207</guid>
		<description>@Jeff Davis:
usually against &quot;hacks&quot;.
somebody hacks, gets dump of database.
somebody steals backups.
this kind of things.

of course hacker that will hack, get root access will be able to circumvent it, but it will take longer time, thus it makes the hack easier to be revealed.

also - sometimes password encryption/hashing in database is external requirement (think: business, local law, common practice)</description>
		<content:encoded><![CDATA[<p>@Jeff Davis:<br />
usually against &#8220;hacks&#8221;.<br />
somebody hacks, gets dump of database.<br />
somebody steals backups.<br />
this kind of things.</p>
<p>of course hacker that will hack, get root access will be able to circumvent it, but it will take longer time, thus it makes the hack easier to be revealed.</p>
<p>also &#8211; sometimes password encryption/hashing in database is external requirement (think: business, local law, common practice)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24206</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Wed, 07 Nov 2007 19:05:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24206</guid>
		<description>@depesz

If you&#039;re not protecting against the DBA, then why not just REVOKE and forget encryption all together?

If the goal is to avoid accidentally storing the plaintext password (as DBA), I showed two examples where it&#039;s easy to accidentally store the password in plaintext if you&#039;re the DBA.</description>
		<content:encoded><![CDATA[<p>@depesz</p>
<p>If you&#8217;re not protecting against the DBA, then why not just REVOKE and forget encryption all together?</p>
<p>If the goal is to avoid accidentally storing the plaintext password (as DBA), I showed two examples where it&#8217;s easy to accidentally store the password in plaintext if you&#8217;re the DBA.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24200</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Tue, 06 Nov 2007 20:02:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24200</guid>
		<description>@Jeff Davis:
actually i think that protecting &quot;against&quot; dba is futile anyway. dba can do whatever he want, so with some level of knowledge he can circumvent any kind of solution (as long as unencrypted/unhashed data shows to db server at least once).</description>
		<content:encoded><![CDATA[<p>@Jeff Davis:<br />
actually i think that protecting &#8220;against&#8221; dba is futile anyway. dba can do whatever he want, so with some level of knowledge he can circumvent any kind of solution (as long as unencrypted/unhashed data shows to db server at least once).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24199</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Tue, 06 Nov 2007 19:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24199</guid>
		<description>If you use a trigger to encrypt the password, keep in mind that there are still many situations in which the password might be revealed to the DBA.

For instance:
  * anything that causes the statement to be logged, such as log_min_duration_statement
  * anyone who has access to pg_stat_activity. You might have monitoring scripts that show you some query worth looking at, and that query might end up being the one to insert the password.

And probably some other stuff. It is certainly worth considering to keep all encryption _outside_ of the database. You can&#039;t keep information secure from the DBA if it&#039;s encrypted by the database. And if not keeping it secure from the DBA, why not just revoke privileges from everyone else?</description>
		<content:encoded><![CDATA[<p>If you use a trigger to encrypt the password, keep in mind that there are still many situations in which the password might be revealed to the DBA.</p>
<p>For instance:<br />
  * anything that causes the statement to be logged, such as log_min_duration_statement<br />
  * anyone who has access to pg_stat_activity. You might have monitoring scripts that show you some query worth looking at, and that query might end up being the one to insert the password.</p>
<p>And probably some other stuff. It is certainly worth considering to keep all encryption _outside_ of the database. You can&#8217;t keep information secure from the DBA if it&#8217;s encrypted by the database. And if not keeping it secure from the DBA, why not just revoke privileges from everyone else?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24198</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Tue, 06 Nov 2007 14:14:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24198</guid>
		<description>@Tzvetan Tzankov:
kind of. chkpass uses old algorithm, which has one very important drawback - handles correctly only password up to 8 characters long.
also - there are ready databases (web-accessible) which &quot;decode&quot; those password.</description>
		<content:encoded><![CDATA[<p>@Tzvetan Tzankov:<br />
kind of. chkpass uses old algorithm, which has one very important drawback &#8211; handles correctly only password up to 8 characters long.<br />
also &#8211; there are ready databases (web-accessible) which &#8220;decode&#8221; those password.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tzvetan Tzankov</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24197</link>
		<dc:creator>Tzvetan Tzankov</dc:creator>
		<pubDate>Tue, 06 Nov 2007 12:56:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24197</guid>
		<description>there is other contrib package chkpass, which does mostly the same thing</description>
		<content:encoded><![CDATA[<p>there is other contrib package chkpass, which does mostly the same thing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: depesz</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24196</link>
		<dc:creator>depesz</dc:creator>
		<pubDate>Tue, 06 Nov 2007 10:54:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24196</guid>
		<description>@Tom Davis:
hmm .. i wouldn&#039;t use db-authen in any website scenario. 1.5 million users?!

@Andrew Hammond:
i really think md5 is sufficient for passwords. using sha* is good for cryptographically secure document signatures, but for password - i don&#039;t see real need to use anything &gt; md5.

@smk: 
sure, you&#039;re right.

@Ron:
take a look at trigger code - salt *is* random.
gen_salt() function generates random salt.</description>
		<content:encoded><![CDATA[<p>@Tom Davis:<br />
hmm .. i wouldn&#8217;t use db-authen in any website scenario. 1.5 million users?!</p>
<p>@Andrew Hammond:<br />
i really think md5 is sufficient for passwords. using sha* is good for cryptographically secure document signatures, but for password &#8211; i don&#8217;t see real need to use anything &gt; md5.</p>
<p>@smk:<br />
sure, you&#8217;re right.</p>
<p>@Ron:<br />
take a look at trigger code &#8211; salt *is* random.<br />
gen_salt() function generates random salt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24195</link>
		<dc:creator>Ron</dc:creator>
		<pubDate>Tue, 06 Nov 2007 10:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24195</guid>
		<description>And for the paranoid, you should probably throw in a random salt, different for each user, to protect against table-lookups of the hashes , should they somehow be compromised.</description>
		<content:encoded><![CDATA[<p>And for the paranoid, you should probably throw in a random salt, different for each user, to protect against table-lookups of the hashes , should they somehow be compromised.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: smk</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24194</link>
		<dc:creator>smk</dc:creator>
		<pubDate>Tue, 06 Nov 2007 08:46:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24194</guid>
		<description>Just one, minor issue: You are talking about hashing, not encryption. Encryption is reversible, hashing is not (which is the whole point of hashing).</description>
		<content:encoded><![CDATA[<p>Just one, minor issue: You are talking about hashing, not encryption. Encryption is reversible, hashing is not (which is the whole point of hashing).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Hammond</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24190</link>
		<dc:creator>Andrew Hammond</dc:creator>
		<pubDate>Tue, 06 Nov 2007 00:38:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24190</guid>
		<description>Tom, I think you have a good approach there for small business solutions, sacrificing pooling simply isn&#039;t acceptable for larger scale soltions. In those cases, it makes good sense to have a separate user for each application or administrator who&#039;s going to be connecting to the database, and then do application level identification in a system such as depsez is discussing.

My worry about the solution discussed above is that it&#039;s using md5 instead of the more robust / security-droid compliant sha512. Fortunately that&#039;s easily fixed:

SELECT encode(digest(decode(TEXT &#039;swordfish&#039;, TEXT &#039;escape&#039;), TEXT &#039;sha512&#039;),
TEXT &#039;base64&#039;);

Or you can skip that outer layer of encoding and handle passwords as bytea. Annoyingly, this requires having built against openssl 0.9.8+.</description>
		<content:encoded><![CDATA[<p>Tom, I think you have a good approach there for small business solutions, sacrificing pooling simply isn&#8217;t acceptable for larger scale soltions. In those cases, it makes good sense to have a separate user for each application or administrator who&#8217;s going to be connecting to the database, and then do application level identification in a system such as depsez is discussing.</p>
<p>My worry about the solution discussed above is that it&#8217;s using md5 instead of the more robust / security-droid compliant sha512. Fortunately that&#8217;s easily fixed:</p>
<p>SELECT encode(digest(decode(TEXT &#8216;swordfish&#8217;, TEXT &#8216;escape&#8217;), TEXT &#8216;sha512&#8242;),<br />
TEXT &#8216;base64&#8242;);</p>
<p>Or you can skip that outer layer of encoding and handle passwords as bytea. Annoyingly, this requires having built against openssl 0.9.8+.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Davis</title>
		<link>http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/comment-page-1/#comment-24188</link>
		<dc:creator>Tom Davis</dc:creator>
		<pubDate>Mon, 05 Nov 2007 17:16:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.depesz.com/index.php/2007/11/05/encrypted-passwords-in-database/#comment-24188</guid>
		<description>The implication of using a table for storing user/password information is that you are bypassing the database authorization for something homegrown. There are two basic problems with this
1) Security: the application itself must be given authorization of the most powerful users, meaning that when someone compromises your application server (eg: apache) they have full access to your data.
2) Scalability: anyone wanting access to the data must either be given that same all powerful authorization, or additional authorization schemes must be implemented (say someone wants to use ODBC/JDBC to access the data for some reporting tool). And of course if you add new features to the application the old parts must be reviewed to ensure that the security model is not being compromised.

A solution which avoids these pitfalls is to use the database connection as the authorization function in your application. The downsize for that is that each user must use a separate connection which for HTTP means each GET/POST will create a new connection (connection pooling tends not to be useful as it is unlikely that a user will be serviced by the same process).

Nevertheless, in many cases, especially for intranet applications for small and medium sized offices, the performance hit is negligible and the improved security and data access is well worth using the database authorization system.</description>
		<content:encoded><![CDATA[<p>The implication of using a table for storing user/password information is that you are bypassing the database authorization for something homegrown. There are two basic problems with this<br />
1) Security: the application itself must be given authorization of the most powerful users, meaning that when someone compromises your application server (eg: apache) they have full access to your data.<br />
2) Scalability: anyone wanting access to the data must either be given that same all powerful authorization, or additional authorization schemes must be implemented (say someone wants to use ODBC/JDBC to access the data for some reporting tool). And of course if you add new features to the application the old parts must be reviewed to ensure that the security model is not being compromised.</p>
<p>A solution which avoids these pitfalls is to use the database connection as the authorization function in your application. The downsize for that is that each user must use a separate connection which for HTTP means each GET/POST will create a new connection (connection pooling tends not to be useful as it is unlikely that a user will be serviced by the same process).</p>
<p>Nevertheless, in many cases, especially for intranet applications for small and medium sized offices, the performance hit is negligible and the improved security and data access is well worth using the database authorization system.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
