---
title: "CWE-593: Authentication Bypass: OpenSSL CTX Object Modified after SSL Objects are Created"
url: https://radicalnotion.ai/cwe/cwe-593
type: cwe
description: "The product modifies the SSL context after connection creation has begun."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-593: Authentication Bypass: OpenSSL CTX Object Modified after SSL Objects are Created

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

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

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Bypass Protection Mechanism | No authentication takes place in this process, bypassing an assumed protection of encryption. |
| Confidentiality | Read Application Data | 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. The encrypted communication between a user and a trusted host may be subject to a sniffing attack. |

## Potential mitigations

### Architecture and Design

Use a language or a library that provides a cryptography framework at a higher level of abstraction.

### Implementation

Most SSL\_CTX functions have SSL counterparts that act on SSL-type objects.

### Implementation

Applications should set up an SSL\_CTX completely, before creating SSL objects from it.

## Demonstrative examples

### Example 1

The following example demonstrates the weakness.

Bad code:

```c
#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");
}
```

## Related attack patterns (CAPEC)

- [CAPEC-94](https://radicalnotion.ai/capec/capec-94): Adversary in the Middle (AiTM)

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-666](https://radicalnotion.ai/cwe/cwe-666) | Operation on Resource in Wrong Phase of Lifetime |
| Parent | [CWE-1390](https://radicalnotion.ai/cwe/cwe-1390) | Weak Authentication |

## Frequently asked questions

### What is CWE-593?

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

### How do you prevent CWE-593?

Use a language or a library that provides a cryptography framework at a higher level of abstraction.

### What are the consequences of CWE-593?

Exploiting CWE-593 can lead to: Bypass Protection Mechanism, Read Application Data.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/593.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-593). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
