Browse Source

Add size limit to X509_NAME structure.

This adds an explicit limit to the size of an X509_NAME structure. Some
part of OpenSSL (e.g. TLS) already effectively limit the size due to
restrictions on certificate size.

See also upstream's 65cb92f4da37a3895437f0c9940ee0bcf9f28c8a, although this is
different from upstream's. Upstream's version bounds both the X509_NAME *and*
any data after it in the immediately containing structure. While adding a bound
on all of crypto/asn1 is almost certainly a good idea (will look into that for
a follow-up), it seems bizarre and unnecessary to have X509_NAME affect its
parent.

Change-Id: Ica2136bcd1455d7c501ccc6ef2a19bc5ed042501
Reviewed-on: https://boringssl-review.googlesource.com/7846
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
David Benjamin 8 years ago
committed by Adam Langley
parent
commit
e31e0123ea
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      crypto/x509/x_name.c

+ 11
- 0
crypto/x509/x_name.c View File

@@ -71,6 +71,13 @@
typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY;
DECLARE_STACK_OF(STACK_OF_X509_NAME_ENTRY)

/*
* Maximum length of X509_NAME: much larger than anything we should
* ever see in practice.
*/

#define X509_NAME_MAX (1024 * 1024)

static int x509_name_ex_d2i(ASN1_VALUE **val,
const unsigned char **in, long len,
const ASN1_ITEM *it,
@@ -208,6 +215,10 @@ static int x509_name_ex_d2i(ASN1_VALUE **val,
int ret;
STACK_OF(X509_NAME_ENTRY) *entries;
X509_NAME_ENTRY *entry;
/* Bound the size of an X509_NAME we are willing to parse. */
if (len > X509_NAME_MAX) {
len = X509_NAME_MAX;
}
q = p;

/* Get internal representation of Name */


Loading…
Cancel
Save