Re: How to protect Postgres password in my app?

Поиск
Список
Период
Сортировка
От Stephen Cook
Тема Re: How to protect Postgres password in my app?
Дата
Msg-id 4DC9A012.5090100@gmail.com
обсуждение исходный текст
Ответ на How to protect Postgres password in my app?  (Basil Bourque <basil.list@me.com>)
Список pgsql-novice
On 5/10/2011 4:07 PM, Basil Bourque wrote:
> I'm an experienced programmer, but for the first time I'm developing an app that connects to a Postgres server over
theinternet. 
>
> How do you secure the password used to connect to Postgres?
>
> My idea is to have a single user, representing my app, defined in Postgres. Then separately I'll have my own table to
trackeach human user. I've learned about BCrypt and Postgres' encryption functions "crypt" etc. to securely store the
humanuser's password as a value in a row in my own "user_" table. 
>
> But how do I secure the app's password to connect to Postgres?
>
> a) I assume I should encrypt the connection with SSL. I'm learning about SSL certificates now. Is that the way to go?
Wouldyou consider that to be required in any serious business app connecting to Postgres over the Internets? 
>
> b) Hard-coding the app's Postgres password in the app's source code seems less than ideal to me. Is there some better
way?
>
> -- If the app is built in Java, I've heard that Java is very easy to de-compile and thus expose the password. Other
languagessuch as Real Studio (REALbasic) may be not suffer that vulnerability. 
>
> -- Hard-coding means I'm not free to change the password on the server. To change the password, I would have to
upgradeall my users simultaneously. 
>
> c) Should I manage all my human users as Postgres users? Is trying to manage the passwords on my own a dumb idea?
>
> --Basil
>

Who are you trying to protect the password from?

SSL will protect it in transit (e.g. against "evil" nodes along the way,
or someone listening in), but not against anyone who has access to your
app itself (your users). You can't really protect it from users; even if
you encrypt it on the client end the app will have to decrypt it for use
and tech-savvy users can get at it with a bit of effort (this is true
for any and all programming languages used).

Your best bet might be to assume that any hacker (or anyone who
downloads that one hacker's work) *will* have access to the PostgreSQL
password. Only allow the PG user minimal access to get its job done.
Then if some guy writes an "alternative" app using your "secret" PG
password, it can't do anything that the original wasn't allowed in the
first place.

More info about what you are doing would help if you want more advice.


-- Stephen Cook

В списке pgsql-novice по дате отправления:

Предыдущее
От: Basil Bourque
Дата:
Сообщение: How to protect Postgres password in my app?
Следующее
От: Grzegorz Szpetkowski
Дата:
Сообщение: Re: How to protect Postgres password in my app?