Skip site navigation (1) Skip section navigation (2)

pgsql: Remove arbitrary limitation on length of common name in SSLcert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Remove arbitrary limitation on length of common name in SSLcert
Date: 2012-02-23 23:04:46
Message-ID: E1S0hiQ-00087r-3P@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Remove arbitrary limitation on length of common name in SSL certificates.

Both libpq and the backend would truncate a common name extracted from a
certificate at 32 bytes.  Replace that fixed-size buffer with dynamically
allocated string so that there is no hard limit.  While at it, remove the
code for extracting peer_dn, which we weren't using for anything; and
don't bother to store peer_cn longer than we need it in libpq.

This limit was not so terribly unreasonable when the code was written,
because we weren't using the result for anything critical, just logging it.
But now that there are options for checking the common name against the
server host name (in libpq) or using it as the user's name (in the server),
this could result in undesirable failures.  In the worst case it even seems
possible to spoof a server name or user name, if the correct name is
exactly 32 bytes and the attacker can persuade a trusted CA to issue a
certificate in which that string is a prefix of the certificate's common
name.  (To exploit this for a server name, he'd also have to send the
connection astray via phony DNS data or some such.)  The case that this is
a realistic security threat is a bit thin, but nonetheless we'll treat it
as one.

Back-patch to 8.4.  Older releases contain the faulty code, but it's not
a security problem because the common name wasn't used for anything
interesting.

Reported and patched by Heikki Linnakangas

Security: CVE-2012-0867

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e6fcb03dc0de1771f7d408b5df1738272e6f98e5

Modified Files
--------------
src/backend/libpq/be-secure.c    |   59 ++++++++++++++--------
src/include/libpq/libpq-be.h     |    3 +-
src/interfaces/libpq/fe-secure.c |  106 +++++++++++++++++++++++--------------
src/interfaces/libpq/libpq-int.h |    2 -
4 files changed, 105 insertions(+), 65 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2012-02-23 23:04:47
Subject: pgsql: Convert newlines to spaces in names written in pg_dumpcomments.
Previous:From: Tom LaneDate: 2012-02-23 23:04:45
Subject: pgsql: Convert newlines to spaces in names written in pg_dumpcomments.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group