oss-sec mailing list archives
PostgreSQL - Predictable cancel key
From: Bastian Blank <waldi () debian org>
Date: Sat, 13 Jun 2015 11:33:51 +0200
Hi
PostgreSQL postmaster uses predictable random numbers from random().
The PRNG is seeded once during its lifetime with srandom(). The seed is
generated as following, also zero is explicitely excluded:
| random_seed = random_start_time.tv_usec ^
| ((random_stop_time.tv_usec << 16) |
| ((random_stop_time.tv_usec >> 16) & 0xffff));
So we have at most 1,000,000 different seeds.
A so called cancel key is generated with random() for every new backend
used by client connections and for autovacuum childs. This key together
with the PID is used for asynchronous cancelation of queries in client
backends. This values are transmitted to the client after successful
authentication.
The information needed to cancel other queries is the (sequential, at
least on Linux) pid and a predicable (secret) key.
Another set of four calles to random() are used to generate the salt for
the md5-authentication. This value is given to the client before the
authentication. One call per byte is done, excluding zero bytes:
| md5Salt[0] = (random() % 255) + 1;
| md5Salt[1] = (random() % 255) + 1;
| md5Salt[2] = (random() % 255) + 1;
| md5Salt[3] = (random() % 255) + 1;
Timeline:
- 2015-02-13: Reported upstream, considered no problem
- 2015-06-13: Published
Regards,
Bastian
--
A princess should not be afraid -- not with a brave knight to protect her.
-- McCoy, "Shore Leave", stardate 3025.3
Current thread:
- PostgreSQL - Predictable cancel key Bastian Blank (Jun 13)
- Re: PostgreSQL - Predictable cancel key Pierre Schweitzer (Jun 15)
- Re: PostgreSQL - Predictable cancel key Bastian Blank (Jun 15)
- Re: PostgreSQL - Predictable cancel key Pierre Schweitzer (Jun 16)
- Re: PostgreSQL - Predictable cancel key Michael Samuel (Jun 16)
- Re: PostgreSQL - Predictable cancel key Pierre Schweitzer (Jun 17)
- Re: PostgreSQL - Predictable cancel key Bastian Blank (Jun 15)
- Re: PostgreSQL - Predictable cancel key Pierre Schweitzer (Jun 15)
