Authentication Bypass: OpenSSL CTX Object Modified after SSL Objects are Created

The product modifies the SSL context after connection creation has begun.


Description

If the program modifies the SSL_CTX object after creating SSL objects from it, there is the possibility that older SSL objects created from the original context could all be affected by that change.

Demonstrations

The following examples help to illustrate the nature of this weakness and describe methods or techniques which can be used to mitigate the risk.

Note that the examples here are by no means exhaustive and any given weakness may have many subtle varieties, each of which may require different detection methods or runtime controls.

Example One

The following example demonstrates the weakness.

#define CERT "secret.pem"
#define CERT2 "secret2.pem"

int main(){

  SSL_CTX *ctx;
  SSL *ssl;
  init_OpenSSL();
  seed_prng();

  ctx = SSL_CTX_new(SSLv23_method());

  if (SSL_CTX_use_certificate_chain_file(ctx, CERT) != 1)
    int_error("Error loading certificate from file");


  if (SSL_CTX_use_PrivateKey_file(ctx, CERT, SSL_FILETYPE_PEM) != 1)
    int_error("Error loading private key from file");


  if (!(ssl = SSL_new(ctx)))
    int_error("Error creating an SSL context");


  if ( SSL_CTX_set_default_passwd_cb(ctx, "new default password" != 1))
    int_error("Doing something which is dangerous to do anyways");


  if (!(ssl2 = SSL_new(ctx)))
    int_error("Error creating an SSL context");


}

See Also

Comprehensive Categorization: Access Control

Weaknesses in this category are related to access control.

Authenticate Actors

Weaknesses in this category are related to the design and architecture of authentication components of the system. Frequently these deal with verifying the entity is i...

SFP Secondary Cluster: Digital Certificate

This category identifies Software Fault Patterns (SFPs) within the Digital Certificate cluster.

Comprehensive CWE Dictionary

This view (slice) covers all the elements in CWE.

Weaknesses Introduced During Implementation

This view (slice) lists weaknesses that can be introduced during implementation.


Common Weakness Enumeration content on this website is copyright of The MITRE Corporation unless otherwise specified. Use of the Common Weakness Enumeration and the associated references on this website are subject to the Terms of Use as specified by The MITRE Corporation.