pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedDisable TRUST authentication by using ClientAuthentication_hook
5+ messages / 4 participants
[nested] [flat]
* Disable TRUST authentication by using ClientAuthentication_hook
@ 2018-07-13 11:57 kpi6288@gmail.com
0 siblings, 1 reply; 5+ messages in thread
From: kpi6288@gmail.com @ 2018-07-13 11:57 UTC (permalink / raw)
To: pgsql-general
I'd like to disable the TRUST authentication method for certain servers
where modification of pg_hba.conf and restarting a service is fairly easy
for a number of users.
I looked at this example
https://wiki.postgresql.org/images/e/e3/Hooks_in_postgresql.pdf It appears
that creating a ClientAuthentication_hook and call ereport(ERROR) in case
that Port->HbaLine contains TRUST would do the job. Is that right?
I am aware that this would not make the server entirely secure but it would
make it at least a bit more difficult to enter.
Thanks Klaus
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Disable TRUST authentication by using ClientAuthentication_hook
@ 2018-07-13 12:01 Guillaume Lelarge <guillaume@lelarge.info>
parent: kpi6288@gmail.com
0 siblings, 1 reply; 5+ messages in thread
From: Guillaume Lelarge @ 2018-07-13 12:01 UTC (permalink / raw)
To: kpi6288@gmail.com; +Cc: pgsql-general
2018-07-13 13:57 GMT+02:00 <kpi6288@gmail.com>:
> I’d like to disable the TRUST authentication method for certain servers
> where modification of pg_hba.conf and restarting a service is fairly easy
> for a number of users.
>
>
>
> I looked at this example https://wiki.postgresql.org/images/e/e3/Hooks_in_
> postgresql.pdf It appears that creating a ClientAuthentication_hook and
> call ereport(ERROR) in case that Port->HbaLine contains TRUST would do the
> job. Is that right?
>
>
>
> I am aware that this would not make the server entirely secure but it
> would make it at least a bit more difficult to enter.
>
>
>
I'm not sure this is such a good idea. You may need the trust
authentication method, for example if you forgot the superuser password.
Otherwise, there's good chance you might use the ClientAuthentication hook
to do what you want.
--
Guillaume.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Disable TRUST authentication by using ClientAuthentication_hook
@ 2018-07-13 13:19 Fabrízio de Royes Mello <fabrizio@timbira.com.br>
parent: Guillaume Lelarge <guillaume@lelarge.info>
0 siblings, 2 replies; 5+ messages in thread
From: Fabrízio de Royes Mello @ 2018-07-13 13:19 UTC (permalink / raw)
To: Guillaume Lelarge <guillaume@lelarge.info>; +Cc: kpi6288@gmail.com; pgsql-general
2018-07-13 9:01 GMT-03:00 Guillaume Lelarge <guillaume@lelarge.info>:
> 2018-07-13 13:57 GMT+02:00 <kpi6288@gmail.com>:
>
>> I’d like to disable the TRUST authentication method for certain servers
>> where modification of pg_hba.conf and restarting a service is fairly easy
>> for a number of users.
>>
>>
>>
>> I looked at this example https://wiki.postgresql.org/im
>> ages/e/e3/Hooks_in_postgresql.pdf It appears that creating a
>> ClientAuthentication_hook and call ereport(ERROR) in case that
>> Port->HbaLine contains TRUST would do the job. Is that right?
>>
>>
>>
>> I am aware that this would not make the server entirely secure but it
>> would make it at least a bit more difficult to enter.
>>
>>
>>
>
> I'm not sure this is such a good idea. You may need the trust
> authentication method, for example if you forgot the superuser password.
> Otherwise, there's good chance you might use the ClientAuthentication hook
> to do what you want.
>
>
>
If you're an server admin you can disable the extension (editing
shared_pre_load_libraries GUC), change password and then enable the
extension again...
And maybe you can implement a simple way to enable/disable this hook inside
the extension.
Regards,
--
Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Disable TRUST authentication by using ClientAuthentication_hook
@ 2018-07-13 13:36 Guillaume Lelarge <guillaume@lelarge.info>
parent: Fabrízio de Royes Mello <fabrizio@timbira.com.br>
1 sibling, 0 replies; 5+ messages in thread
From: Guillaume Lelarge @ 2018-07-13 13:36 UTC (permalink / raw)
To: Fabrízio de Royes Mello <fabrizio@timbira.com.br>; +Cc: kpi6288@gmail.com; pgsql-general
2018-07-13 15:19 GMT+02:00 Fabrízio de Royes Mello <fabrizio@timbira.com.br>
:
>
> 2018-07-13 9:01 GMT-03:00 Guillaume Lelarge <guillaume@lelarge.info>:
>
>> 2018-07-13 13:57 GMT+02:00 <kpi6288@gmail.com>:
>>
>>> I’d like to disable the TRUST authentication method for certain servers
>>> where modification of pg_hba.conf and restarting a service is fairly easy
>>> for a number of users.
>>>
>>>
>>>
>>> I looked at this example https://wiki.postgresql.org/im
>>> ages/e/e3/Hooks_in_postgresql.pdf It appears that creating a
>>> ClientAuthentication_hook and call ereport(ERROR) in case that
>>> Port->HbaLine contains TRUST would do the job. Is that right?
>>>
>>>
>>>
>>> I am aware that this would not make the server entirely secure but it
>>> would make it at least a bit more difficult to enter.
>>>
>>>
>>>
>>
>> I'm not sure this is such a good idea. You may need the trust
>> authentication method, for example if you forgot the superuser password.
>> Otherwise, there's good chance you might use the ClientAuthentication hook
>> to do what you want.
>>
>>
>>
> If you're an server admin you can disable the extension (editing
> shared_pre_load_libraries GUC), change password and then enable the
> extension again...
>
>
That would require a restart.
And maybe you can implement a simple way to enable/disable this hook inside
> the extension.
>
>
That looks like a better idea.
--
Guillaume.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Disable TRUST authentication by using ClientAuthentication_hook
@ 2018-07-13 13:51 Tom Lane <tgl@sss.pgh.pa.us>
parent: Fabrízio de Royes Mello <fabrizio@timbira.com.br>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Lane @ 2018-07-13 13:51 UTC (permalink / raw)
To: Fabrízio de Royes Mello <fabrizio@timbira.com.br>; +Cc: Guillaume Lelarge <guillaume@lelarge.info>; kpi6288@gmail.com; pgsql-general
=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= <fabrizio@timbira.com.br> writes:
> 2018-07-13 9:01 GMT-03:00 Guillaume Lelarge <guillaume@lelarge.info>:
>> 2018-07-13 13:57 GMT+02:00 <kpi6288@gmail.com>:
>>> I’d like to disable the TRUST authentication method for certain servers
>>> where modification of pg_hba.conf and restarting a service is fairly easy
>>> for a number of users.
>> I'm not sure this is such a good idea. You may need the trust
>> authentication method, for example if you forgot the superuser password.
>> Otherwise, there's good chance you might use the ClientAuthentication hook
>> to do what you want.
> If you're an server admin you can disable the extension (editing
> shared_pre_load_libraries GUC), change password and then enable the
> extension again...
Or more to the point: exactly what is the threat model here? ISTM
that someone with enough privilege to alter pg_hba.conf can probably
suppress loading of an extension too, so that the security added by
this idea is not just questionable but completely illusory.
What would actually move the goalposts a bit is to build a modified
server which doesn't have the TRUST code path at all, so that there
is no question of installing an extension or not; then somebody who
wants to defeat the security needs to be able to replace the server
executable. But you don't need any hook if you do that.
BTW, the usual way to get around I-forgot-the-superuser-password
is to start the server in single-user mode and use that to issue
an ALTER USER ... PASSWORD command. As long as your patch doesn't
break single-user mode, you don't need any other escape hatch.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-07-13 13:51 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-13 11:57 Disable TRUST authentication by using ClientAuthentication_hook kpi6288@gmail.com
2018-07-13 12:01 ` Guillaume Lelarge <guillaume@lelarge.info>
2018-07-13 13:19 ` Fabrízio de Royes Mello <fabrizio@timbira.com.br>
2018-07-13 13:36 ` Guillaume Lelarge <guillaume@lelarge.info>
2018-07-13 13:51 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox