Segfault when calling SSL_get0_group_name() before handshake
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 30.8k
- Forks
- 11.5k
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
In master, if SSL_get0_group_name() is called before a session is established, then the sc->session->kex_group ends up dereferencing a null pointer:
There was mention of this in the original PR, and it was going to get fixed, but I think the fix never made it in?
https://github.com/openssl/openssl/pull/20866#discussion_r1185803863
What happens if the handshake hasn't been initiated or completed yet? If this returns NULL in that case, it would be good to mention it.
Good point, I'm not actually sure if it would return NULL or just break. I will make sure it returns NULL and update the doc to reflect it.
The docs do say:
If SSL_get0_group_name() returns NULL, an error occurred; possibly no TLS session has been established.
A reproducer:
root@555367a36240:/# cat repro.c
#include <stdio.h>
#include <openssl/ssl.h>
int main(void)
{
SSL_CTX *ctx;
SSL *ssl;
fprintf(stderr, "Headers: %s\n", OPENSSL_VERSION_TEXT);
fprintf(stderr, "Library: %s\n",
OpenSSL_version(OPENSSL_VERSION));
ctx = SSL_CTX_new(TLS_client_method());
ssl = SSL_new(ctx);
SSL_get0_group_name(ssl);
}
root@555367a36240:/# ./repro
Headers: OpenSSL 3.5.5 27 Jan 2026
Library: OpenSSL 3.5.5 27 Jan 2026
Segmentation fault ./repro
root@555367a36240:/#
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ssl/s3_lib.c at the linked lines and the SSL_get0_group_name() API documentation; use the provided repro.c to reproduce the pre-handshake crash. Done means the call follows the documented NULL behavior without a segfault, with the documented behavior and relevant coverage verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100