openssl / openssl/openssl

Segfault when calling SSL_get0_group_name() before handshake

Open
#32,379 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

branch: 3.4 branch: 3.5 branch: 3.6 branch: 4.0 branch: master help wanted triaged: bug
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:

https://github.com/openssl/openssl/blob/d9f5cb8965cb56414b97a95a101dc68e08f26476/ssl/s3_lib.c#L5665-L5668

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.