Skip to content

fix: Security patches for CVE-2026-42945, CVE-2026-42946, CVE-2026-42934, CVE-2026-40701 - #2027

Merged
drawing merged 4 commits into
alibaba:masterfrom
drawing:feature-fix-cve
May 15, 2026
Merged

drawing merged 4 commits into
alibaba:masterfrom
drawing:feature-fix-cve

Conversation

@drawing

@drawing drawing commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Backport security fixes from nginx 1.30.1 for four CVEs affecting the nginx core used in Tengine.

CVEs Fixed

CVE-2026-42945 - Heap buffer overflow in ngx_http_rewrite_module (Critical, CVSS 9.2)

If there were arguments in a rewrite's replacement string, the is_args flag was set and never cleared. This caused escaping to be incorrectly applied to captures evaluated in subsequent set or if directives. Since the buffer was allocated without expecting escaping, this resulted in a heap buffer overrun and possible remote code execution.

Fix: Reset e->is_args to 0 in ngx_http_script_regex_end_code().

Based on: nginx/nginx@524977e

CVE-2026-42946 - Buffer overread in ngx_http_scgi_module and ngx_http_uwsgi_module (High, CVSS 8.3)

When the first response line from an SCGI/uWSGI backend was not a valid HTTP status line, the fallback to header parsing could start with a wrong parsing state. Additionally, if the status line was split across reads, the already-processed portion was lost on fallback, leading to buffer overread.

Fix: Reset r->state to 0 on fallback, save buffer position before parsing using r->header_name_start, and restore u->buffer.pos for proper backtracking.

Based on: nginx/nginx@baef7fd and nginx/nginx@39d7d0b

CVE-2026-42934 - Buffer overread in ngx_http_charset_module (Low)

When a multi-byte UTF-8 character was split across 3+ single-byte buffers, ngx_utf8_decode() was called with the wrong byte count (last saved-array index instead of total length), and the subsequent ngx_memcpy() could read past the input buffer boundary.

Fix: Replace the for-loop with a direct ngx_memcpy() using ngx_min() to calculate the correct copy length, and pass the proper total length to ngx_utf8_decode().

Based on: nginx/nginx@54b7945

CVE-2026-40701 - Use-after-free in OCSP resolver (Medium, CVSS 6.3)

When a client SSL connection was terminated while resolving an OCSP responder hostname, the OCSP context was freed but the resolver context was not. This resulted in use-after-free when the DNS resolution completed.

Fix: Track the resolver context in ngx_ssl_ocsp_ctx_s and cancel any pending resolution in ngx_ssl_ocsp_done().

Based on: nginx/nginx@d2b8d47

Files Changed

  • src/http/ngx_http_script.c
  • src/http/modules/ngx_http_scgi_module.c
  • src/http/modules/ngx_http_uwsgi_module.c
  • src/http/modules/ngx_http_charset_filter_module.c
  • src/event/ngx_event_openssl_stapling.c

Testing

All fixes are minimal and match the official nginx 1.30.1 patches. No functional behavior changes beyond the security fixes.

drawing added 4 commits May 15, 2026 12:05
Rewrite: fixed escaping and possible buffer overrun.

If there were arguments in a rewrite's replacement string, the is_args flag
was set and incorrectly never cleared. This resulted in escaping applied
to any captures evaluated afterwards in set or if. Additionally buffer was
allocated by ngx_http_script_complex_value_code() without escaping expected,
thus this also resulted in buffer overrun and possible segfault.

Fix: reset e->is_args to 0 in ngx_http_script_regex_end_code() after each
rewrite directive completes, preventing the flag from leaking to subsequent
directives.

Based on official nginx fix: nginx/nginx@524977e

Affected: NGINX 0.6.27 - 1.30.0
CVSS: 9.2 (Critical)
…_http_uwsgi_module

Upstream: reset parsing state after invalid status line.
Upstream: fixed parsing of split status lines.

Previously, it was possible to start parsing headers with a wrong parsing
state after status line was not recognized, as a fallback used in the scgi
and uwsgi modules. Additionally, if the first response line was split across
reads and it didn't appear a status line, the portion already processed was
lost, leading to a heap memory buffer overread.

Fix: save buffer position before calling ngx_http_parse_status_line() using
r->header_name_start, reset r->state to 0 on fallback, and restore
u->buffer.pos for proper backtracking when status line parsing fails.

Based on official nginx fixes:
  nginx/nginx@baef7fd
  nginx/nginx@39d7d0b

Affected: NGINX 0.8.42 - 1.30.0
CVSS: 8.3 (High)
Charset: fix buffer over-read in recode_from_utf8().

When a multi-byte UTF-8 character was split across 3+ single-byte
buffers, the saved bytes continuation path had two related bugs:
ngx_utf8_decode() was called with the last saved-array index instead
of the byte count, causing it to report 'incomplete' even when the
sequence was already complete.
The subsequent ngx_memcpy() used that same index as the copy length,
reading past the input buffer boundary.

Fix: replace the for-loop with a direct ngx_memcpy() using ngx_min()
to calculate the correct number of bytes to copy, then pass the proper
total length to ngx_utf8_decode(). Update the incomplete-sequence path
to simply set ctx->saved_len = len since bytes are already copied.

Based on official nginx fix: nginx/nginx@54b7945

Affected: NGINX 0.3.50 - 1.30.0
CVSS: Low severity
…l_module

OCSP: resolve cleanup on connection close.

Previously, when a client SSL connection was terminated (typically due to a
timeout) while resolving an OCSP responder, the OCSP context was freed, but
the resolve context was not. This resulted in use-after-free on resolve
completion.

Fix: Add a 'resolve' field to ngx_ssl_ocsp_ctx_s to track the outstanding
DNS resolution. In ngx_ssl_ocsp_done(), cancel any pending resolution by
calling ngx_resolve_name_done() before destroying the pool. Save the resolve
pointer in ngx_ssl_ocsp_request() and clear it in both success and failure
paths of ngx_ssl_ocsp_resolve_handler().

Based on official nginx fix: nginx/nginx@d2b8d47

Affected: NGINX 1.19.0 - 1.30.0
CVSS: 6.3 (Medium)
@tengxiao

tengxiao commented Jul 6, 2026

Copy link
Copy Markdown

大佬们,请问什么时候修复一下这个漏洞CVE-2026-28755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants