diff options
| author | user.email <123011167+lukefr09@users.noreply.github.com> | 2026-02-23 19:33:57 -0600 |
|---|---|---|
| committer | Roman Arutyunyan <arutyunyan.roman@gmail.com> | 2026-02-27 19:35:04 +0400 |
| commit | c67bf9415fca91434f047d6113435e4cc699c859 (patch) | |
| tree | cd1e79261dc1913c987e1cde5492cea8efdca817 /src/event | |
| parent | f72c7453f95143cd413dbc01d1ae9a28c67b39de (diff) | |
| download | nginx-c67bf9415fca91434f047d6113435e4cc699c859.tar.gz nginx-c67bf9415fca91434f047d6113435e4cc699c859.tar.bz2 | |
QUIC: improved error handling in OpenSSL compat layer.
Previously ngx_quic_compat_create_record() could try to encrypt a TLS
record even if encryption context was missing, which resulted in a NULL
pointer dereference.
The context is created by ngx_quic_compat_set_encryption_secret() called
from the OpenSSL keylog callback. If an error occurred in that function,
the context could remain missing. This could happen under memory pressure,
if an allocation failed inside this function.
The fix is to handle errors from ngx_quic_compat_set_encryption_secret()
and set qc->error to trigger an error after SSL_do_handshake() return.
Also, a check for context is added to ngx_quic_compat_create_record()
to avoid other similar issues.
Diffstat (limited to 'src/event')
| -rw-r--r-- | src/event/quic/ngx_event_quic_openssl_compat.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/event/quic/ngx_event_quic_openssl_compat.c b/src/event/quic/ngx_event_quic_openssl_compat.c index 58298dcb8..c5f4a0f74 100644 --- a/src/event/quic/ngx_event_quic_openssl_compat.c +++ b/src/event/quic/ngx_event_quic_openssl_compat.c @@ -213,8 +213,12 @@ ngx_quic_compat_keylog_callback(const SSL *ssl, const char *line) com->method->set_read_secret((SSL *) ssl, level, cipher, secret, n); com->read_record = 0; - (void) ngx_quic_compat_set_encryption_secret(c, &com->keys, level, - cipher, secret, n); + if (ngx_quic_compat_set_encryption_secret(c, &com->keys, level, + cipher, secret, n) + != NGX_OK) + { + qc->error = NGX_QUIC_ERR_INTERNAL_ERROR; + } } ngx_explicit_memzero(secret, n); @@ -591,6 +595,10 @@ ngx_quic_compat_create_record(ngx_quic_compat_record_t *rec, ngx_str_t *res) secret = &rec->keys->secret; + if (secret->ctx == NULL) { + return NGX_ERROR; + } + ngx_memcpy(nonce, secret->iv.data, secret->iv.len); ngx_quic_compute_nonce(nonce, sizeof(nonce), rec->number); |
