Unix Technical Forum

Re: [pgadmin-hackers] Client-side password encryption

This is a discussion on Re: [pgadmin-hackers] Client-side password encryption within the pgsql Hackers forums, part of the PostgreSQL category; --> Andreas Pflug wrote: > Dave Page wrote: > > So did you just rip it from there into psql? ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 08:23 AM
Peter Eisentraut
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

Andreas Pflug wrote:
> Dave Page wrote:
> > So did you just rip it from there into psql? I don't see it in the
> > list of libpq exports so if thats not the case, on Windows at least
> > we'll need to change the api, and possibly the dll name as well to
> > avoid any compatibility issues.

>
> And a prototype in libpq-fe.h wouldn't hurt either... And a macro, to
> enable distinguishing md5-enabled libpq versions from older versions.


So it appears that pg_md5_encrypt is not officially exported from libpq.
Does anyone see a problem with adding it to the export list and the
header file?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 08:23 AM
Christopher Kings-Lynne
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

> So it appears that pg_md5_encrypt is not officially exported from libpq.
> Does anyone see a problem with adding it to the export list and the
> header file?


Is it different to normal md5? How is this helpful to the phpPgAdmin
project?

Chris


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 08:23 AM
Tom Lane
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
>> So it appears that pg_md5_encrypt is not officially exported from libpq.
>> Does anyone see a problem with adding it to the export list and the
>> header file?


> Is it different to normal md5? How is this helpful to the phpPgAdmin
> project?


It would be better to export an API that is (a) less random (why one
input null-terminated and the other not?) and (b) less tightly tied
to MD5 --- the fact that the caller knows how long the result must be
is the main problem here.

Something like
char *pg_gen_encrypted_passwd(const char *passwd, const char *user)
with malloc'd result (or NULL on failure) seems more future-proof.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-11-2008, 08:24 AM
Andrew Dunstan
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

Peter Eisentraut said:

>
> So it appears that pg_md5_encrypt is not officially exported from
> libpq. Does anyone see a problem with adding it to the export list
> and the header file?
>



Well, these changes have broken the windows build, so something needs to
change.I don't see a reason in principle not to expose our routine, given
that its name means it is unlikely to conflict with anything else.

cheers

andrew



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-11-2008, 08:26 AM
Andrew Dunstan
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption



Tom Lane wrote:

>Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
>
>
>>>So it appears that pg_md5_encrypt is not officially exported from libpq.
>>>Does anyone see a problem with adding it to the export list and the
>>>header file?
>>>
>>>

>
>
>
>>Is it different to normal md5? How is this helpful to the phpPgAdmin
>>project?
>>
>>

>
>It would be better to export an API that is (a) less random (why one
>input null-terminated and the other not?) and (b) less tightly tied
>to MD5 --- the fact that the caller knows how long the result must be
>is the main problem here.
>
>Something like
> char *pg_gen_encrypted_passwd(const char *passwd, const char *user)
>with malloc'd result (or NULL on failure) seems more future-proof.
>
>
>
>


Where are we on this? In general I agree with Tom, but I have no time to
do the work. Unless someone has an immediate implementation, I suggest
that pro tem we add pg_md5_encrypt to src/interfaces/libpq/exports.txt,
which is the minimum needed to unbreak Windows builds, while this gets
sorted out properly.

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-11-2008, 08:26 AM
Tom Lane
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

Andrew Dunstan <andrew@dunslane.net> writes:
> Where are we on this? In general I agree with Tom, but I have no time to
> do the work. Unless someone has an immediate implementation, I suggest
> that pro tem we add pg_md5_encrypt to src/interfaces/libpq/exports.txt,
> which is the minimum needed to unbreak Windows builds, while this gets
> sorted out properly.


I had forgotten that the Windows build is broken. I'll see what I can
do with throwing together the cleaner-API function.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-11-2008, 08:26 AM
Tom Lane
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

I wrote:
> I had forgotten that the Windows build is broken. I'll see what I can
> do with throwing together the cleaner-API function.


Done, but I noticed that the change to createuser has arguably broken
it; at least we need to change the docs. To wit, the docs say

-E
--encrypted
Encrypts the user's password stored in the database. If not
specified, the default password behavior is used.

-N
--unencrypted
Does not encrypt the user's password stored in the database. If not
specified, the default password behavior is used.

As currently coded, however, the behavior when neither switch is given
is to force the password to be encrypted --- the database's
password_encryption setting is overridden.

I'm not sure we can do much about this --- certainly we don't want the
default behavior of createuser to still be to send an unencrypted
password. But if we leave the code as-is the docs need a change.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-11-2008, 08:26 AM
Christopher Kings-Lynne
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

>>Where are we on this? In general I agree with Tom, but I have no time to
>>do the work. Unless someone has an immediate implementation, I suggest
>>that pro tem we add pg_md5_encrypt to src/interfaces/libpq/exports.txt,
>>which is the minimum needed to unbreak Windows builds, while this gets
>>sorted out properly.

>
>
> I had forgotten that the Windows build is broken. I'll see what I can
> do with throwing together the cleaner-API function.


Another question about these encrypted passwords. phpPgAdmin needs to
connect to databases that are sometimes on other servers.

I use the pg_connect() function to do this. This is passed down to
PQconenct() I presume.

So, can I specify the password to pg_connect() as
'md5127349123742342344234'?

ie. Can I CONNECT using an md5'd password?

Also, does this work for non-md5 host lines on the server, and how can I
avoid doing it on older (pre-7.2) PostgreSQL??

Chris


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-11-2008, 08:26 AM
Tom Lane
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> So, can I specify the password to pg_connect() as
> 'md5127349123742342344234'?


Certainly not. We'd hardly be worrying about obscuring the original
password if the encrypted version were enough to get in with.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-11-2008, 08:27 AM
Christopher Kings-Lynne
 
Posts: n/a
Default Re: [pgadmin-hackers] Client-side password encryption

>>So, can I specify the password to pg_connect() as
>>'md5127349123742342344234'?

>
> Certainly not. We'd hardly be worrying about obscuring the original
> password if the encrypted version were enough to get in with.


AndrewSN can't post at the moment, but asked me to post this for him:

"Knowing the md5 hash is enough to authenticate via the 'md5' method in
pg_hba.conf, even if you don't know the original password. Admittedly
you have to modify libpq to do this, but this isn't going to stop an
attacker for more than 5 seconds."

I'll add my own note that never sending the cleartext password does not
necessarily improve PostgreSQL security, but certainly stops someone who
sniffs the password from then using that cleartext password to get into
other applications. If all they can get is the md5 hash, then all they
can get into is PostgreSQL.

Chris


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:03 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com