GHSL-2020-056: Double free in OpenSSL client
A double-free vulnerability in OpenSSL's client-side DHE key exchange processing allows a malicious server to cause the client to free the same memory twice. An attacker could potentially execute arbitrary code in the context of the client.
Originally disclosed on GitHub Security Lab
We have identified a security issue in OpenSSL in which an attacker can force a client into freeing the same memory twice in the context of a key exchange between the server and the client. The fact this vulnerability happens in the key exchange process, prior to any server certificate verification, makes the…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The function tls_process_ske_dhe assigns a raw DH pointer to an EVP_PKEY without incrementing its reference count, then on an error path frees the DH object separately and also frees the EVP_PKEY, which frees the same DH object again.
Impact
A malicious server may use this vulnerability to execute arbitrary code in the context of a client, though the impact is reduced compared with server-side issues.
What the attacker needed
Malicious server or network attacker; client connects to attacker-controlled server; no certificate verification needed
The fix
The vulnerability was fixed in the master repository before any release, so no released versions were affected.
How it was found
- Create a fake TLS server that sends a ServerKeyExchange message with a small DH prime to trigger a security check failure.
- Connect to the fake server using an OpenSSL client such as s_client.
- The client processes the key exchange, fails the security check, and frees the DH object twice, causing a crash or potential code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program frees memory, it tells the system that memory is no longer needed. A double-free happens when the program frees the same memory twice, which can corrupt the system's memory management and let an attacker run their own code. Here, a malicious server can trigger this in a connecting client during the initial handshake, before any certificate checks.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.