Commit graph

8561 commits

Author SHA1 Message Date
Aleksei Bavshin
abc72c5a57 SSL: compatibility with renamed error codes in OpenSSL 4.0.
Some checks failed
buildbot / buildbot (push) Has been cancelled
SSL_R_SSL3_SESSION_ID_TOO_LONG is no longer available when building
OpenSSL 4.0 with no-deprecated.  Added the new name as a fallback.
2026-04-14 11:26:42 -06:00
Maxim Dounin
aa09c19992 SSL: logging level of "invalid alert" errors.
The SSL_R_INVALID_ALERT ("invalid alert") errors are reported by OpenSSL
1.1.1 or newer if the client sends a malformed alert.  These errors are
now logged at the "info" level.

Signed-off-by: Aleksei Bavshin <a.bavshin@nginx.com>
Origin: <https://freenginx.org/hg/nginx/rev/d89e0386b695>
2026-04-14 11:26:42 -06:00
Maxim Dounin
06c9d63fc8 SSL: logging level of all "SSL alert number N" errors.
Errors about alerts received from peers are generated by OpenSSL by adding
peer-provided alert description (from 0 to 255) to SSL_AD_REASON_OFFSET.
All such errors, including ones for unknown alerts, are now logged at the
"info" level, as these can be caused by a misbehaving client.

Signed-off-by: Aleksei Bavshin <a.bavshin@nginx.com>
Origin: <https://freenginx.org/hg/nginx/rev/f5423ee155fe>
2026-04-14 11:26:42 -06:00
Sergey Kandaurov
bbaac1d43f Updated OpenSSL used for win32 builds 2026-04-14 16:57:41 +04:00
Roman Arutyunyan
d3a76322cf Restrict connection-specific headers in HTTP/2 and HTTP/3
Some checks are pending
buildbot / buildbot (push) Waiting to run
As per RFC 9113 and RFC 9114, any message containing such headers MUST be
treated as malformed.

As per RFC 9110, Section 7.6.1, the following headers are considered
connection-specific:

- Connection
- Proxy-Connection
- Keep-Alive
- TE
- Transfer-Encoding
- Upgrade

The only exception is the TE header field, which MAY be present in a
request header, but it MUST NOT contain any value other than "trailers".
2026-04-14 09:53:13 +04:00
Roman Arutyunyan
00979ba9d8 Remove Proxy-Connection HTTP upstream header
As per RFC 9110, this header SHOULD be removed by a proxy.

Also, as per RFC 9113, this header MUST be removed when proxying to an
HTTP/2 backend.
2026-04-14 09:53:13 +04:00
Andrew Clayton
b761b0485b GH: add a workflow to check for the 'version bump' commit
Some checks are pending
buildbot / buildbot (push) Waiting to run
This checks pull-requests to make sure the 'Version bump' commit is
immediately after the last release commit/tag.

The check includes the commits in the pull-request, so if a pull-request
is adding this commit it will accept it and also if there are other
commits in the pull-request, as long as the 'Version bump' commit is
first.
2026-04-13 14:20:23 +01:00
Andrew Clayton
9772267278 Version bump 2026-04-13 14:20:23 +01:00
Sergey Kandaurov
5eaf45f11e nginx-1.29.8-RELEASE
Some checks failed
buildbot / buildbot (push) Has been cancelled
2026-04-07 15:37:12 +04:00
David Carlier
1709bffe6e Upstream: reset early_hints_length on upstream reinit.
Some checks are pending
buildbot / buildbot (push) Waiting to run
When a request was retried to a new upstream after receiving 103
Early Hints from the previous one, the accumulated early_hints_length
was not reset, causing valid early hints from the next upstream to be
incorrectly rejected as "too big".
2026-04-06 20:59:00 +04:00
Zoey
067d766f21 Fix $request_port and $is_request_port in subrequests
Some checks are pending
buildbot / buildbot (push) Waiting to run
Closes #1247.
2026-04-06 14:53:54 +04:00
Maxim Dounin
365694160a Added max_headers directive.
The directive limits the number of request headers accepted from clients.
While the total amount of headers is believed to be sufficiently limited
by the existing buffer size limits (client_header_buffer_size and
large_client_header_buffers), the additional limit on the number of headers
might be beneficial to better protect backend servers.

Requested by Maksim Yevmenkin.

Signed-off-by: Elijah Zupancic <e.zupancic@f5.com>
Origin: <199dc0d6b0>
2026-04-06 14:08:36 +04:00
David Korczynski
06c30ec29d Upstream: fix integer underflow in charset parsing
The issue described below was only reproducible prior to
7924a4ec6c

When parsing the `charset` parameter in the `Content-Type` header within
`ngx_http_upstream_copy_content_type`, an input such as `charset="`
resulted in an integer underflow.

In this scenario, both `p` and `last` point to the position immediately
following the opening quote. The logic to strip a trailing quote checked
`*(last - 1)` without verifying that `last > p`. This caused `last` to
be decremented to point to the opening quote itself, making `last < p`.

The subsequent length calculation `r->headers_out.charset.len = last - p`
resulted in -1, which wrapped to `SIZE_MAX` as `len` is a `size_t`. This
invalid length was later passed to `ngx_cpymem` in `ngx_http_header_filter`,
leading to an out-of-bounds memory access (detected as
`negative-size-param` by AddressSanitizer).

The fix ensures `last > p` before attempting to strip a trailing quote,
correctly resulting in a zero-length charset for malformed input.

The oss-fuzz payload that triggers this issue holds multiple 103 status
lines, and it's a sequence of 2 of those Content-Type headers that
trigger the ASAN report.

Co-authored-by: CodeMender <codemender-patching@google.com>
Fixes: https://issues.oss-fuzz.com/issues/486561029

Signed-off-by: David Korczynski <david@adalogics.com>
2026-04-06 14:07:18 +04:00
Eugene Grebenschikov
2ff1a969f3 Removed CLOCK_MONOTONIC_FAST support.
Some checks failed
buildbot / buildbot (push) Has been cancelled
CLOCK_MONOTONIC_FAST, like CLOCK_MONOTONIC_COARSE, has low accuracy. It
shows noticeable timing variation for short intervals, which is visible
in metrics like $upstream_response_time for fast upstream responses.
This change complements the work started in commit f29d7ade5.
In addition to the reasons described in f29d7ade5, the performance of
CLOCK_MONOTONIC is good enough on modern hardware when using a TSC
timecounter. This is especially true when it is accessed through a
shared page, as implemented in FreeBSD 10.0 (see git commits
869fd80fd449 and aea810386d8e for details).

Co-authored-by: Sergey Kandaurov <pluknet@nginx.com>
2026-04-03 11:57:21 -07:00
Sergey Kandaurov
7924a4ec6c Upstream: fixed processing multiple 103 (early hints) responses.
Some checks are pending
buildbot / buildbot (push) Waiting to run
The second 103 response in a row was treated as the final response header.
2026-04-02 20:54:32 +04:00
xuruidong
9fd94af4dd Update CONTRIBUTING.md
Some checks failed
buildbot / buildbot (push) Has been cancelled
2026-03-31 15:36:50 +01:00
Sergey Kandaurov
0d025b4a94 SSL: compatibility with OpenSSL 4.0.
Some checks are pending
buildbot / buildbot (push) Waiting to run
X509_get_issuer_name() and X509_get_subject_name() were changed to return
a const value.  Since it is passed to functions with a non const argument
in older versions, the const modifier is conditionally compiled as needed.

ASN1_INTEGER was made opaque.  ASN1_STRING accessors are used to preserve
the behaviour.  ASN1_STRING_get0_data() compat shim is provided for OpenSSL
< 1.1.0 where it does not exist.
2026-03-31 12:32:19 +04:00
Sergey Kandaurov
390767e6ec Version bump. 2026-03-31 12:32:19 +04:00
Eugene Grebenschikov
0de6e878ba Fixed the "include" directive inside the "geo" block.
Some checks failed
buildbot / buildbot (push) Has been cancelled
The "include" directive should be able to include multiple files if
given a filename mask.

Completes remaining changes introduced in da4ffd8.

Closes: https://github.com/nginx/nginx/issues/1165
2026-03-24 11:20:16 -07:00
Roman Arutyunyan
5ac6f49371 nginx-1.29.7-RELEASE 2026-03-24 19:38:34 +04:00
Sergey Kandaurov
18711f7754 Stream: fixed client certificate validation with OCSP.
Check for OCSP status was missed in 581cf2267, resulting
in a broken validation.

Reported by Mufeed VH of Winfunc Research.
2026-03-24 19:28:20 +04:00
Sergey Kandaurov
9bc13718fe Mail: fixed clearing s->passwd in auth http requests.
Some checks are pending
buildbot / buildbot (push) Waiting to run
Previously, it was not properly cleared retaining length as part of
authenticating with CRAM-MD5 and APOP methods that expect to receive
password in auth response.  This resulted in null pointer dereference
and worker process crash in subsequent auth attempts with CRAM-MD5.

Reported by Arkadi Vainbrand.
2026-03-24 18:46:36 +04:00
Roman Arutyunyan
6f3145006b Mail: host validation.
Now host name resolved from client address is validated to only contain
the characters specified in RFC 1034, Section 3.5.  The validation allows
to avoid injections when using the resolved host name in auth_http and
smtp proxy.

Reported by Asim Viladi Oglu Manizada, Colin Warren,
Xiao Liu (Yunnan University), Yuan Tan (UC Riverside), and
Bird Liu (Lanzhou University).
2026-03-24 18:46:08 +04:00
Roman Arutyunyan
9739e755b8 Dav: destination length validation for COPY and MOVE.
Previously, when alias was used in a location with Dav COPY or MOVE
enabled, and the destination URI was shorter than the alias, integer
underflow could happen in ngx_http_map_uri_to_path(), which could
result in heap buffer overwrite, followed by a possible segfault.
With some implementations of memcpy(), the segfault could be avoided
and the overwrite could result in a change of the source or destination
file names to be outside of the location root.

Reported by Calif.io in collaboration with Claude and Anthropic Research.
2026-03-24 18:45:25 +04:00
Roman Arutyunyan
3568812cf9 Mp4: fixed possible integer overflow on 32-bit platforms.
Previously, a 32-bit overflow could happen while validating atom entries
count.  This allowed processing of an invalid atom with entrires beyond
its boundaries with reads and writes outside of the allocated mp4 buffer.

Reported by Prabhav Srinath (sprabhav7).
2026-03-24 18:44:57 +04:00
Roman Arutyunyan
7725c372c2 Mp4: avoid zero size buffers in output.
Previously, data validation checks did not cover the cases when the output
contained empty buffers.  Such buffers are considered illegal and produce
"zero size buf in output" alerts.  The change rejects the mp4 files which
produce such alerts.

Also, the change fixes possible buffer overread and overwrite that could
happen while processing empty stco and co64 atoms, as reported by
Pavel Kohout (Aisle Research) and Tim Becker.
2026-03-24 18:12:29 +04:00
Roman Arutyunyan
d787755d50 Upstream keepalive: fixed parameter parsing. 2026-03-24 15:38:16 +04:00
Roman Semenov
6bb27a6312 Proxy: enabled HTTP/1.1 by default for upstream connections.
Updates the proxy module to use HTTP/1.1 as the default protocol when
communicating with upstream servers. This change unlocks features
such as persistent connections and chunked transfer encoding. Configurations
that require HTTP/1.0 can still override the protocol explicitly.
2026-03-24 14:28:52 +04:00
Roman Semenov
4fbe4b6274 Upstream: enabled keepalive by default for explicit upstreams.
Keepalive is now automatically enabled in the "local" mode for upstreams
defined in configuration files. Cached keepalive connections are no longer
shared between different locations referencing the same explicit upstream
unless keepalive is explicitly configured without the "local" parameter.

To disable keepalive entirely, use keepalive 0; inside the upstream block.
To allow sharing cached connections between locations, configure
keepalive <max_cached>; without the "local" parameter.
2026-03-24 14:28:52 +04:00
Roman Semenov
c5d36eac33 Upstream keepalive: distinguish cached connections by location.
The new "local" parameter prevents sharing cached keepalive connections
between location blocks. Connections are now reused only within the same
location.
2026-03-24 14:28:52 +04:00
Dmitry Plotnikov
c6c77e8875 Added COMPAT section to ngx_log_t.
Some checks are pending
buildbot / buildbot (push) Waiting to run
2026-03-23 09:38:11 -07:00
Sergey Kandaurov
920dc099c1 The "multipath" parameter of the "listen" directive.
Some checks failed
buildbot / buildbot (push) Has been cancelled
When configured, it enables Multipath TCP support on a listen socket.
As of now it works on Linux starting with Linux 5.6 and glibc 2.32,
where it is enabled with an IPPROTO_MPTCP socket(2) protocol.

To avoid EADDRINUSE errors in bind() and listen() when transitioning
between sockets with different protocols, SO_REUSEPORT is set on both
sockets.  See f7f1607bf for potential implications.

Based on previous work by Maxime Dourov and Anthony Doeraene.
2026-03-19 01:13:51 +04:00
David Carlier
a29476464c gRPC: reset buffer chains on upstream reinit.
Some checks failed
buildbot / buildbot (push) Has been cancelled
Previously, ctx->out was not cleared in ngx_http_grpc_reinit_request(),
which could cause queued HTTP/2 control frames (SETTINGS ACK, PING ACK,
WINDOW_UPDATE) to be sent on next upstream.

Additionally, ctx->in and ctx->busy needs to be cleared to avoid similar
problems with buffered request body fixed in cd12dc4f1.
2026-03-16 11:38:06 +04:00
David Carlier
bcd1a01d3b Proxy: reset pending control frames on HTTP/2 upstream reinit.
Previously, ctx->out was not cleared in ngx_http_proxy_v2_reinit_request(),
which could cause stale HTTP/2 control frames (SETTINGS ACK, PING ACK,
WINDOW_UPDATE) queued for the old upstream connection to be sent to a new
upstream connection during a retry.
2026-03-16 11:37:33 +04:00
Roman Arutyunyan
e23e7dd83a Proxy authentication definitions.
Some checks failed
buildbot / buildbot (push) Has been cancelled
2026-03-11 19:33:12 +04:00
Roman Arutyunyan
60d0329a20 Version bump. 2026-03-11 19:32:17 +04:00
Sergey Kandaurov
cb85fbbfba nginx-1.29.6-RELEASE
Some checks failed
buildbot / buildbot (push) Has been cancelled
2026-03-10 19:29:07 +04:00
Sergey Kandaurov
c20777a1e9 Fixed typos. 2026-03-10 19:29:07 +04:00
Sergey Kandaurov
55689299d9 Updated zlib used for win32 builds. 2026-03-10 19:29:07 +04:00
Aleksei Bavshin
52cda2849c Sticky: fixed expiration of learned sessions after reload.
Some checks failed
buildbot / buildbot (push) Has been cancelled
Previously, the expiration timer for learned session was not started
until a new session is created.  This could lead to the sessions being
active past the expiration time.
2026-03-09 11:08:30 -06:00
Vladimir Kokshenev
0380586e69 Sticky: samesite=<strict|lax|none> cookie flags.
Adds new options for the "sticky cookie" directive to set
samesite=<strict|lax|none> cookie flags.
2026-03-09 11:08:30 -06:00
Vladimir Homutov
8021cb02de Sticky: added the "header" parameter in the learn mode.
With this parameter set, sessions are learned after receiving upstream headers.
2026-03-09 11:08:30 -06:00
Vladimir Homutov
7acbe17776 Sticky: added the "max-age" attribute to cookie.
RFC 6265 defines "Max-Age" cookie attribute in section 5.2.2.

If the "expires" option is passed to the "sticky" directive, "max-age"
attribute will appear in cookies set by the module with corresponding
value in seconds.

For the special "max" value of the "expires" option, corresponding "max-age"
attribute value will be set to 315360000 seconds (10 years, similar to
how its done in headers_filter module for the "Cache-Control" header).
2026-03-09 11:08:30 -06:00
Vladimir Homutov
c988a6e2c1 Sticky: added variables support to cookie domain. 2026-03-09 11:08:30 -06:00
Vladimir Homutov
6c13f0468b Sticky: added "httponly" and "secure" attributes.
The attributes are described in RFC6265, sections 4.1.2.5 and 4.1.2.6
respectively.
2026-03-09 11:08:30 -06:00
Vladimir Homutov
d12dd2405d Sticky: added "draining" peer state.
While peer is draining, only sticky requests are served and the peer is never
selected to process new requests.

Co-authored-by: Ruslan Ermilov <ru@nginx.com>
2026-03-09 11:08:30 -06:00
Aleksei Bavshin
c5036ad30c Upstream: introduced a new macro for down value. 2026-03-09 11:08:30 -06:00
Vladimir Homutov
af7137c88a Sticky: added the "learn" mode.
In this mode, nginx "learns" which client uses which proxied server by
analyzing headers of client requests and proxied server responses.

For example, a proxied server may start sessions by issuing the "Set-Cookie"
header field to set cookie 'sid' and returning clients will bring the cookie
with the same name.

The following configuration may be used to handle this case:

upstream u1 {
    server 127.0.0.1:8080;
    server 127.0.0.1:8081;

    sticky learn timeout=10m zone=sess:1m
           create=$upstream_cookie_sid
           lookup=$cookie_sid;
}

Co-authored-by: Ruslan Ermilov <ru@nginx.com>
Co-authored-by: Maxim Dounin <mdounin@mdounin.ru>
2026-03-09 11:08:30 -06:00
Vladimir Homutov
104734f218 Upstream: added sticky sessions support for upstreams.
Sticky sessions allow to route the same client to the same upstream server.

- upstream structures are extended to keep session-related information

- existing balancing modules are updated to provide an id of the selected
  server (SID) in pc->sid, and to select the server, given it's SID.

- other balancing modules are allowed to set the pc->hint value to choose
  the desired peer.  The sticky module will not change the hint if it's
  already set.

- the feature is enabled by default and can be disabled with the
  "--without-http_upstream_sticky" switch of the configure script.

The following configuration can be used to enable sticky sessions for
supported balancing modules:

    upstream u1 {
        server 127.0.0.1:8080;
        server 127.0.0.1:8081;

        sticky cookie server_id expires=1h domain=.example.com path=/;
    }

Co-authored-by: Ruslan Ermilov <ru@nginx.com>
Co-authored-by: Roman Arutyunyan <arut@nginx.com>
Co-authored-by: Maxim Dounin <mdounin@mdounin.ru>
2026-03-09 11:08:30 -06:00
Sergey Kandaurov
dff46cd1ae Mail: fixed type overflow in IMAP literal length parser.
Some checks failed
buildbot / buildbot (push) Has been cancelled
The overflow is safe, because the maximum length of literals
is limited with the "imap_client_buffer" directive.

Reported by Bartłomiej Dmitruk.
2026-03-04 12:08:09 +04:00