pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
crypt function crash on postgresql 9.3.20 and 10
13+ messages / 8 participants
[nested] [flat]

* crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 13:11  Михаил Манерко <asper@tagan.ru>
  0 siblings, 2 replies; 13+ messages in thread

From: Михаил Манерко @ 2018-02-02 13:11 UTC (permalink / raw)
  To: pgsql-bugs

If you send an asterisk in the crypt function, the function crashes.


example

i=# select crypt('123','*');
ОШИБКА:  invalid salt
i=#

-- 
Regards,
Michael A. Manerko

Megalink Company, Engineer
318, Chehova street, Taganrog, Russia, 347932
tel work: +7 8634 431431 (ext 159)
tel mobile: +7 999 6939428
sip: 159@tagan.ru
www.tagan.ru





^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 14:38  Francisco Olarte <folarte@peoplecall.com>
  parent: Михаил Манерко <asper@tagan.ru>
  1 sibling, 1 reply; 13+ messages in thread

From: Francisco Olarte @ 2018-02-02 14:38 UTC (permalink / raw)
  To: Михаил Манерко <asper@tagan.ru>; +Cc: pgsql-bugs

Seems more like pilot error than a bug....

On Fri, Feb 2, 2018 at 2:11 PM, Михаил Манерко <asper@tagan.ru> wrote:
> If you send an asterisk in the crypt function, the function crashes.
> example
>
> i=# select crypt('123','*');
> ОШИБКА:  invalid salt
> i=#

Id does not crash, it just rejects your salt as invalid, probably
because it is ( does not look right to me, but I'm not in the mood for
fully checking that ).

TFM states 'Calculates a crypt(3)-style hash of password. When storing
a new password, you need to use gen_salt() to generate a new salt
value. To check a password, pass the stored hash value as salt, and
test whether the result matches the stored value.'

Are you doing that ?

Francisco Olarte.




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 14:44  Mike Porter <mike@udel.edu>
  parent: Михаил Манерко <asper@tagan.ru>
  1 sibling, 1 reply; 13+ messages in thread

From: Mike Porter @ 2018-02-02 14:44 UTC (permalink / raw)
  To: Михаил Манерко <asper@tagan.ru>; +Cc: pgsql-bugs

On Fri, 2 Feb 2018, Михаил Манерко wrote:

> If you send an asterisk in the crypt function, the function crashes.
>
>
> example
>
> i=# select crypt('123','*');
> ОШИБКА:  invalid salt
> i=#

The second argument is the salt, and you have not passed enough bits
for the default hash type.

i=> select crypt( '123', 'aa' );
      crypt
---------------
  aamrgyQfDFSHw
(1 row)

i=> select crypt( '123', 'a' );
ERROR:  invalid salt

Regards,

Mike

>
> -- 
> Regards,
> Michael A. Manerko
>
> Megalink Company, Engineer
> 318, Chehova street, Taganrog, Russia, 347932
> tel work: +7 8634 431431 (ext 159)
> tel mobile: +7 999 6939428
> sip: 159@tagan.ru
> www.tagan.ru
>
>
>

-
Mike Porter
PGP Fingerprint: 139B 5431 9346 A577 C0F8  6C76 635D 6C9D 5ABB D433
Old Key: F4 AE E1 9F 67 F7 DA EA  2F D2 37 F3 99 ED D1 C2

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 14:50  Pavan Teja <pavan.postgresdba@gmail.com>
  parent: Mike Porter <mike@udel.edu>
  0 siblings, 1 reply; 13+ messages in thread

From: Pavan Teja @ 2018-02-02 14:50 UTC (permalink / raw)
  To: Mike Porter <mike@udel.edu>; +Cc: Михаил Манерко <asper@tagan.ru>; pgsql-bugs

On Feb 2, 2018 8:15 PM, "Mike Porter" <mike@udel.edu> wrote:

On Fri, 2 Feb 2018, Михаил Манерко wrote:

If you send an asterisk in the crypt function, the function crashes.
>
>
> example
>
> i=# select crypt('123','*');
> ОШИБКА:  invalid salt
> i=#
>

The second argument is the salt, and you have not passed enough bits
for the default hash type.

i=> select crypt( '123', 'aa' );
     crypt
---------------
 aamrgyQfDFSHw
(1 row)

i=> select crypt( '123', 'a' );
ERROR:  invalid salt

Regards,

Mike



> --
> Regards,
> Michael A. Manerko
>
> Megalink Company, Engineer
> 318, Chehova street, Taganrog, Russia, 347932
> tel work: +7 8634 431431 (ext 159)
> tel mobile: +7 999 6939428
> sip: 159@tagan.ru
> www.tagan.ru
>
>
>
>
-
Mike Porter
PGP Fingerprint: 139B 5431 9346 A577 C0F8  6C76 635D 6C9D 5ABB D433
Old Key: F4 AE E1 9F 67 F7 DA EA  2F D2 37 F3 99 ED D1 C2


      Hi,
              Yeah Mike what u said is correct, the consistency of bits for
generation of salt depends on algorithms like blow fish, md5 etc

Regards,
Pavan

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 14:51  David G. Johnston <david.g.johnston@gmail.com>
  parent: Francisco Olarte <folarte@peoplecall.com>
  0 siblings, 0 replies; 13+ messages in thread

From: David G. Johnston @ 2018-02-02 14:51 UTC (permalink / raw)
  To: Francisco Olarte <folarte@peoplecall.com>; +Cc: Михаил Манерко <asper@tagan.ru>; pgsql-bugs

On Fri, Feb 2, 2018 at 7:38 AM, Francisco Olarte <folarte@peoplecall.com>
wrote:

> Seems more like pilot error than a bug....
>
> On Fri, Feb 2, 2018 at 2:11 PM, Михаил Манерко <asper@tagan.ru> wrote:
> > If you send an asterisk in the crypt function, the function crashes.
> > example
> >
> > i=# select crypt('123','*');
> > ОШИБКА:  invalid salt
> > i=#
>
> Id does not crash,


​A crash either kills the server or at least drops your connection to the
database.  All this did was indicate invalid data (because you didn't use
the API correctly) and put you back at a psql prompt.​

it just rejects your salt as invalid, probably
> because it is ( does not look right to me, but I'm not in the mood for
> fully checking that ).
>

​Well "The salt string also tells crypt() which algorithm to use." ​and
"They use a random value, called the salt" - "*" looks like you trying to
specify a specific salt value which is not allowed.

>
> TFM states 'Calculates a crypt(3)-style hash of password. When storing
> a new password, you need to use gen_salt() to generate a new salt
> value. To check a password, pass the stored hash value as salt, and
> test whether the result matches the stored value.'
>

​Maybe someone could add:

HINT:  use gen_salt() to generate the salt​

to the code, though given that the "salt" argument also accepts a hashed
password as input maybe complicates this.

David J.

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 14:55  David G. Johnston <david.g.johnston@gmail.com>
  parent: Pavan Teja <pavan.postgresdba@gmail.com>
  0 siblings, 1 reply; 13+ messages in thread

From: David G. Johnston @ 2018-02-02 14:55 UTC (permalink / raw)
  To: Pavan Teja <pavan.postgresdba@gmail.com>; +Cc: Mike Porter <mike@udel.edu>; Михаил Манерко <asper@tagan.ru>; pgsql-bugs

On Fri, Feb 2, 2018 at 7:50 AM, Pavan Teja <pavan.postgresdba@gmail.com>
wrote:

>
>
> On Feb 2, 2018 8:15 PM, "Mike Porter" <mike@udel.edu> wrote:
>
> On Fri, 2 Feb 2018, Михаил Манерко wrote:
>
> If you send an asterisk in the crypt function, the function crashes.
>>
>>
>> example
>>
>> i=# select crypt('123','*');
>> ОШИБКА:  invalid salt
>> i=#
>>
>
> The second argument is the salt, and you have not passed enough bits
> for the default hash type.
>
> i=> select crypt( '123', 'aa' );
>      crypt
> ---------------
>  aamrgyQfDFSHw
> (1 row)
>
>
>       Hi,
>               Yeah Mike what u said is correct, the consistency of bits
> for generation of salt depends on algorithms like blow fish, md5 etc
>

​You sure?  Don't have time to show otherwise but the docs suggest what you
are doing is validating a store encrypted password as opposed to encrypting
the provided one.

David J.
​

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 14:58  Михаил Манерко <asper@tagan.ru>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Михаил Манерко @ 2018-02-02 14:58 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; Pavan Teja <pavan.postgresdba@gmail.com>; +Cc: Mike Porter <mike@udel.edu>; pgsql-bugs

02.02.2018 17:55, David G. Johnston пишет:
> On Fri, Feb 2, 2018 at 7:50 AM, Pavan Teja <pavan.postgresdba@gmail.com <mailto:pavan.postgresdba@gmail.com>>wrote:
>
>
>
>     On Feb 2, 2018 8:15 PM, "Mike Porter" <mike@udel.edu <mailto:mike@udel.edu>> wrote:
>
>         On Fri, 2 Feb 2018, Михаил Манерко wrote:
>
>             If you send an asterisk in the crypt function, the function crashes.
>
>
>             example
>
>             i=# select crypt('123','*');
>             ОШИБКА:  invalid salt
>             i=#
>
>
>         The second argument is the salt, and you have not passed enough bits
>         for the default hash type.
>
>         i=> select crypt( '123', 'aa' );
>              crypt
>         ---------------
>          aamrgyQfDFSHw
>         (1 row)
>
>
>           Hi, 
>                   Yeah Mike what u said is correct, the consistency of bits for generation of salt depends on
>     algorithms like blow fish, md5 etc
>
>
> ​You sure?  Don't have time to show otherwise but the docs suggest what you are doing is validating a store encrypted
> password as opposed to encrypting the provided one.
>
> David J.
> ​

function takes the text parameter
Should it fall from a 1-character long text?

-- 
Regards,
Michael A. Manerko

Megalink Company, Engineer
318, Chehova street, Taganrog, Russia, 347932
tel work: +7 8634 431431 (ext 159)
tel mobile: +7 999 6939428
sip: 159@tagan.ru
www.tagan.ru

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 15:24  Rainer Pruy <Rainer.Pruy@acrys.com>
  parent: Михаил Манерко <asper@tagan.ru>
  0 siblings, 1 reply; 13+ messages in thread

From: Rainer Pruy @ 2018-02-02 15:24 UTC (permalink / raw)
  To: Михаил Манерко <asper@tagan.ru>; David G. Johnston <david.g.johnston@gmail.com>; Pavan Teja <pavan.postgresdba@gmail.com>; +Cc: Mike Porter <mike@udel.edu>; pgsql-bugs


On 02.02.2018 15:58, Михаил Манерко wrote:
> 02.02.2018 17:55, David G. Johnston пишет:
>> On Fri, Feb 2, 2018 at 7:50 AM, Pavan Teja
>> <pavan.postgresdba@gmail.com <mailto:pavan.postgresdba@gmail.com>>wrote:
>>
>>
>>
>>     On Feb 2, 2018 8:15 PM, "Mike Porter" <mike@udel.edu
>>     <mailto:mike@udel.edu>> wrote:
>>
>>         On Fri, 2 Feb 2018, Михаил Манерко wrote:
>>
>>             If you send an asterisk in the crypt function, the
>>             function crashes.
>>
>>
>>             example
>>
>>             i=# select crypt('123','*');
>>             ОШИБКА:  invalid salt
>>             i=#
>>
>>
>>
> function takes the text parameter
> Should it fall from a 1-character long text?
>
>

Yes, exactly!
This is similar to calling "sqrt(-1)". The parameter is invalid for the
function, such thatthe function can not be performed.

Rainer

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 15:29  David G. Johnston <david.g.johnston@gmail.com>
  parent: Rainer Pruy <Rainer.Pruy@acrys.com>
  0 siblings, 1 reply; 13+ messages in thread

From: David G. Johnston @ 2018-02-02 15:29 UTC (permalink / raw)
  To: Rainer Pruy <Rainer.Pruy@acrys.com>; +Cc: Михаил Манерко <asper@tagan.ru>; Pavan Teja <pavan.postgresdba@gmail.com>; Mike Porter <mike@udel.edu>; pgsql-bugs

On Fri, Feb 2, 2018 at 8:24 AM, Rainer Pruy <Rainer.Pruy@acrys.com> wrote:

>
> On 02.02.2018 15:58, Михаил Манерко wrote:
>
> 02.02.2018 17:55, David G. Johnston пишет:
>
> On Fri, Feb 2, 2018 at 7:50 AM, Pavan Teja <pavan.postgresdba@gmail.com>
> wrote:
>
>>
>>
>> On Feb 2, 2018 8:15 PM, "Mike Porter" <mike@udel.edu> wrote:
>>
>> On Fri, 2 Feb 2018, Михаил Манерко wrote:
>>
>> If you send an asterisk in the crypt function, the function crashes.
>>>
>>>
>>> example
>>>
>>> i=# select crypt('123','*');
>>> ОШИБКА:  invalid salt
>>> i=#
>>>
>>
>>
> function takes the text parameter
> Should it fall from a 1-character long text?
>
>
> Yes, exactly!
> This is similar to calling "sqrt(-1)". The parameter is invalid for the
> function, such thatthe function can not be performed.
>

​Right.

Functions generally (rarely, never) have domain types created for them that
would prevent invalid input values from even being created.  Defining
constraints on input values is usually left up to the documentation.  In
this case the documentation describes how to properly use the function.
Used properly a single-character long text string should never be input
into the function - so it wasn't deemed necessary to document that if one
supplies such a string incorrectly that the function will error out.  That
seems like a reasonable decision (intentional or otherwise).

David J.

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 18:47  Michael <asper@tagan.ru>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Michael @ 2018-02-02 18:47 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Rainer Pruy <Rainer.Pruy@acrys.com>; Pavan Teja <pavan.postgresdba@gmail.com>; Mike Porter <mike@udel.edu>; pgsql-bugs

В Fri, 2 Feb 2018 08:29:08 -0700
"David G. Johnston" <david.g.johnston@gmail.com> пишет:

> On Fri, Feb 2, 2018 at 8:24 AM, Rainer Pruy <Rainer.Pruy@acrys.com>
> wrote:
> 
> >
> > On 02.02.2018 15:58, Михаил Манерко wrote:
> >
> > 02.02.2018 17:55, David G. Johnston пишет:
> >
> > On Fri, Feb 2, 2018 at 7:50 AM, Pavan Teja
> > <pavan.postgresdba@gmail.com> wrote:
> >  
> >>
> >>
> >> On Feb 2, 2018 8:15 PM, "Mike Porter" <mike@udel.edu> wrote:
> >>
> >> On Fri, 2 Feb 2018, Михаил Манерко wrote:
> >>
> >> If you send an asterisk in the crypt function, the function
> >> crashes.  
> >>>
> >>>
> >>> example
> >>>
> >>> i=# select crypt('123','*');
> >>> ОШИБКА:  invalid salt
> >>> i=#
> >>>  
> >>
> >>  
> > function takes the text parameter
> > Should it fall from a 1-character long text?
> >
> >
> > Yes, exactly!
> > This is similar to calling "sqrt(-1)". The parameter is invalid for
> > the function, such thatthe function can not be performed.
> >  
> 
> ​Right.
> 
> Functions generally (rarely, never) have domain types created for
> them that would prevent invalid input values from even being
> created.  Defining constraints on input values is usually left up to
> the documentation.  In this case the documentation describes how to
> properly use the function. Used properly a single-character long text
> string should never be input into the function - so it wasn't deemed
> necessary to document that if one supplies such a string incorrectly
> that the function will error out.  That seems like a reasonable
> decision (intentional or otherwise).
> 
> David J.

However, in a postgresql 9.3.2, such a call does not lead to an error.
how then should the function respond to a call
select crypt('123',NULL);
this does not cause an error





^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 18:53  David G. Johnston <david.g.johnston@gmail.com>
  parent: Michael <asper@tagan.ru>
  0 siblings, 2 replies; 13+ messages in thread

From: David G. Johnston @ 2018-02-02 18:53 UTC (permalink / raw)
  To: Michael <asper@tagan.ru>; +Cc: Rainer Pruy <Rainer.Pruy@acrys.com>; Pavan Teja <pavan.postgresdba@gmail.com>; Mike Porter <mike@udel.edu>; pgsql-bugs

On Friday, February 2, 2018, Michael <asper@tagan.ru> wrote:

>
> However, in a postgresql 9.3.2, such a call does not lead to an error.


If you are saying 9.3.2 gives a result and 9.3.20 raises an error I suspect
the response in 9.3.2 was bogus and giving an error instead of a bogus
result was deemed the best fix.


> how then should the function respond to a call
> select crypt('123',NULL);
> this does not cause an error
>

It probably returns null because I would hope the function is defined as
strict.

David J.

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 19:05  Michael <asper@tagan.ru>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  1 sibling, 0 replies; 13+ messages in thread

From: Michael @ 2018-02-02 19:05 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Rainer Pruy <Rainer.Pruy@acrys.com>; Pavan Teja <pavan.postgresdba@gmail.com>; Mike Porter <mike@udel.edu>; pgsql-bugs

В Fri, 2 Feb 2018 11:53:06 -0700
"David G. Johnston" <david.g.johnston@gmail.com> пишет:

> On Friday, February 2, 2018, Michael <asper@tagan.ru> wrote:
> 
> >
> > However, in a postgresql 9.3.2, such a call does not lead to an
> > error.  
> 
> 
> If you are saying 9.3.2 gives a result and 9.3.20 raises an error I
> suspect the response in 9.3.2 was bogus and giving an error instead
> of a bogus result was deemed the best fix.
> 
> 
> > how then should the function respond to a call
> > select crypt('123',NULL);
> > this does not cause an error
> >  
> 
> It probably returns null because I would hope the function is defined
> as strict.
> 
> David J.

Thank you for the clarification. In any case, I've already fixed the
queries in my application to get around this behavior.




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: crypt function crash on postgresql 9.3.20 and 10
@ 2018-02-02 23:38  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  1 sibling, 0 replies; 13+ messages in thread

From: Tom Lane @ 2018-02-02 23:38 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Michael <asper@tagan.ru>; Rainer Pruy <Rainer.Pruy@acrys.com>; Pavan Teja <pavan.postgresdba@gmail.com>; Mike Porter <mike@udel.edu>; pgsql-bugs

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> If you are saying 9.3.2 gives a result and 9.3.20 raises an error I suspect
> the response in 9.3.2 was bogus and giving an error instead of a bogus
> result was deemed the best fix.

A bit of diving in the git history says that behavior changed here:

Author: Noah Misch <noah@leadboat.com>
Branch: master Release: REL9_6_BR [1d812c8b0] 2015-10-05 10:06:29 -0400
Branch: REL9_5_STABLE Release: REL9_5_0 [4d6752277] 2015-10-05 10:06:33 -0400
Branch: REL9_4_STABLE Release: REL9_4_5 [4d95419e8] 2015-10-05 10:06:34 -0400
Branch: REL9_3_STABLE Release: REL9_3_10 [cc1210f0a] 2015-10-05 10:06:34 -0400
Branch: REL9_2_STABLE Release: REL9_2_14 [56232f987] 2015-10-05 10:06:35 -0400
Branch: REL9_1_STABLE Release: REL9_1_19 [48f6310bc] 2015-10-05 10:06:35 -0400
Branch: REL9_0_STABLE Release: REL9_0_23 [188e081ef] 2015-10-05 10:06:36 -0400

    pgcrypto: Detect and report too-short crypt() salts.
    
    Certain short salts crashed the backend or disclosed a few bytes of
    backend memory.  For existing salt-induced error conditions, emit a
    message saying as much.  Back-patch to 9.0 (all supported versions).
    
    Josh Kupershmidt
    
    Security: CVE-2015-5288


The 9.3.10 release notes do contain an entry about this.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 13+ messages in thread


end of thread, other threads:[~2018-02-02 23:38 UTC | newest]

Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 13:11 crypt function crash on postgresql 9.3.20 and 10 Михаил Манерко <asper@tagan.ru>
2018-02-02 14:38 ` Francisco Olarte <folarte@peoplecall.com>
2018-02-02 14:51   ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-02 14:44 ` Mike Porter <mike@udel.edu>
2018-02-02 14:50   ` Pavan Teja <pavan.postgresdba@gmail.com>
2018-02-02 14:55     ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-02 14:58       ` Михаил Манерко <asper@tagan.ru>
2018-02-02 15:24         ` Rainer Pruy <Rainer.Pruy@acrys.com>
2018-02-02 15:29           ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-02 18:47             ` Michael <asper@tagan.ru>
2018-02-02 18:53               ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-02 19:05                 ` Michael <asper@tagan.ru>
2018-02-02 23:38                 ` 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