Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d1ecd6

Browse files
committed
Reset OpenSSL randomness state in each postmaster child process.
Previously, if the postmaster initialized OpenSSL's PRNG (which it will dowhen ssl=on in postgresql.conf), the same pseudo-random state would beinherited by each forked child process. The problem is masked to aconsiderable extent if the incoming connection uses SSL encryption, butwhen it does not, identical pseudo-random state is made available tofunctions like contrib/pgcrypto. The process's PID does get mixed into anyrequested random output, but on most systems that still only results in 32Kor so distinct random sequences available across all Postgres sessions.This might allow an attacker who has database access to guess the resultsof "secure" operations happening in another session.To fix, forcibly reset the PRNG after fork(). Each child process that hasneed for random numbers from OpenSSL's generator will thereby be forced togo through OpenSSL's normal initialization sequence, which should providemuch greater variability of the sequences. There are other ways we mightdo this that would be slightly cheaper, but this approach seems the mostfuture-proof against SSL-related code changes.This has been assignedCVE-2013-1900, but since the issue and the patchhave already been publicized on pgsql-hackers, there's no point in tryingto hide this commit.Back-patch to all supported branches.Marko Kreen
1 parent40e873d commit0d1ecd6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎src/backend/postmaster/fork_process.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include<sys/stat.h>
1818
#include<sys/time.h>
1919
#include<unistd.h>
20+
#ifdefUSE_SSL
21+
#include<openssl/rand.h>
22+
#endif
2023

2124
#ifndefWIN32
2225
/*
@@ -124,6 +127,13 @@ fork_process(void)
124127
}
125128
}
126129
#endif/* LINUX_OOM_ADJ */
130+
131+
/*
132+
* Make sure processes do not share OpenSSL randomness state.
133+
*/
134+
#ifdefUSE_SSL
135+
RAND_cleanup();
136+
#endif
127137
}
128138

129139
returnresult;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp