]> git.kaiwu.me - nginx.git/log
nginx.git
14 months agoConfigure: MSVC compatibility with PCRE2 10.45.
Thierry Bastian [Mon, 17 Feb 2025 08:01:27 +0000 (09:01 +0100)]
Configure: MSVC compatibility with PCRE2 10.45.

14 months agoCore: fix build without libcrypt.
Piotr Sikora [Wed, 12 Feb 2025 08:40:58 +0000 (10:40 +0200)]
Core: fix build without libcrypt.

libcrypt is no longer part of glibc, so it might not be available.

Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
14 months agoVersion bump.
Sergey Kandaurov [Tue, 18 Feb 2025 11:38:33 +0000 (15:38 +0400)]
Version bump.

15 months agonginx-1.27.4-RELEASE release-1.27.4
Sergey Kandaurov [Wed, 5 Feb 2025 10:24:20 +0000 (14:24 +0400)]
nginx-1.27.4-RELEASE

15 months agoSNI: added restriction for TLSv1.3 cross-SNI session resumption.
Sergey Kandaurov [Wed, 22 Jan 2025 14:55:44 +0000 (18:55 +0400)]
SNI: added restriction for TLSv1.3 cross-SNI session resumption.

In OpenSSL, session resumption always happens in the default SSL context,
prior to invoking the SNI callback.  Further, unlike in TLSv1.2 and older
protocols, SSL_get_servername() returns values received in the resumption
handshake, which may be different from the value in the initial handshake.
Notably, this makes the restriction added in b720f650b insufficient for
sessions resumed with different SNI server name.

Considering the example from b720f650b, previously, a client was able to
request example.org by presenting a certificate for example.org, then to
resume and request example.com.

The fix is to reject handshakes resumed with a different server name, if
verification of client certificates is enabled in a corresponding server
configuration.

15 months agoAdded "keepalive_min_timeout" directive.
Roman Arutyunyan [Wed, 15 Jan 2025 08:42:39 +0000 (12:42 +0400)]
Added "keepalive_min_timeout" directive.

The directive sets a timeout during which a keepalive connection will
not be closed by nginx for connection reuse or graceful shutdown.

The change allows clients that send multiple requests over the same
connection without delay or with a small delay between them, to avoid
receiving a TCP RST in response to one of them.  This excludes network
issues and non-graceful shutdown.  As a side-effect, it also addresses
the TCP reset problem described in RFC 9112, Section 9.6, when the last
sent HTTP response could be damaged by a followup TCP RST.  It is important
for non-idempotent requests, which cannot be retried by client.

It is not recommended to set keepalive_min_timeout to large values as
this can introduce an additional delay during graceful shutdown and may
restrict nginx from effective connection reuse.

15 months agoMisc: moved documentation in generated ZIP archive.
Sergey Kandaurov [Mon, 9 Dec 2024 09:21:03 +0000 (13:21 +0400)]
Misc: moved documentation in generated ZIP archive.

The recently added GitHub files now reside in the docs directory.

15 months agoConfigure: fixed --with-libatomic=DIR with recent libatomic_ops.
Sergey Kandaurov [Fri, 17 Jan 2025 13:55:21 +0000 (17:55 +0400)]
Configure: fixed --with-libatomic=DIR with recent libatomic_ops.

The build location of the resulting libatomic_ops.a was changed in v7.4.0
after converting libatomic_ops to use libtool.  The fix is to use library
from the install path, this allows building with both old and new versions.

Initially reported here:
https://mailman.nginx.org/pipermail/nginx/2018-April/056054.html

15 months agoQUIC: added missing casts in iov_base assignments.
Aleksei Bavshin [Mon, 27 Jan 2025 18:33:25 +0000 (10:33 -0800)]
QUIC: added missing casts in iov_base assignments.

This is consistent with the rest of the code and fixes build on systems
with non-standard definition of struct iovec (Solaris, Illumos).

15 months agoUpstream: fixed --with-compat build without SSL, broken by 454ad0e.
Pavel Pautov [Wed, 22 Jan 2025 02:41:16 +0000 (18:41 -0800)]
Upstream: fixed --with-compat build without SSL, broken by 454ad0e.

15 months agoSSL: avoid using mismatched certificate/key cached pairs.
Sergey Kandaurov [Wed, 8 Jan 2025 13:50:33 +0000 (17:50 +0400)]
SSL: avoid using mismatched certificate/key cached pairs.

This can happen with certificates and certificate keys specified
with variables due to partial cache update in various scenarios:
- cache expiration with only one element of pair evicted
- on-disk update with non-cacheable encrypted keys
- non-atomic on-disk update

The fix is to retry with fresh data on X509_R_KEY_VALUES_MISMATCH.

15 months agoUpstream: caching certificates and certificate keys with variables.
Sergey Kandaurov [Tue, 29 Oct 2024 14:20:53 +0000 (18:20 +0400)]
Upstream: caching certificates and certificate keys with variables.

Caching is enabled with proxy_ssl_certificate_cache and friends.

Co-authored-by: Aleksei Bavshin <a.bavshin@nginx.com>
15 months agoSSL: cache revalidation of file based dynamic certificates.
Sergey Kandaurov [Mon, 13 Jan 2025 17:40:04 +0000 (21:40 +0400)]
SSL: cache revalidation of file based dynamic certificates.

Revalidation is based on file modification time and uniq file index,
and happens after the cache object validity time is expired.

15 months agoSSL: caching certificates and certificate keys with variables.
Sergey Kandaurov [Tue, 29 Oct 2024 12:25:11 +0000 (16:25 +0400)]
SSL: caching certificates and certificate keys with variables.

A new directive "ssl_certificate_cache max=N [valid=time] [inactive=time]"
enables caching of SSL certificate chain and secret key objects specified
by "ssl_certificate" and "ssl_certificate_key" directives with variables.

Co-authored-by: Aleksei Bavshin <a.bavshin@nginx.com>
15 months agoSSL: encrypted certificate keys are exempt from object cache.
Sergey Kandaurov [Wed, 18 Dec 2024 16:09:58 +0000 (20:09 +0400)]
SSL: encrypted certificate keys are exempt from object cache.

SSL object cache, as previously introduced in 1.27.2, did not take
into account encrypted certificate keys that might be unexpectedly
fetched from the cache regardless of the matching passphrase.  To
avoid this, caching of encrypted certificate keys is now disabled
based on the passphrase callback invocation.

A notable exception is encrypted certificate keys configured without
ssl_password_file.  They are loaded once resulting in the passphrase
prompt on startup and reused in other contexts as applicable.

15 months agoSSL: object cache inheritance from the old configuration cycle.
Sergey Kandaurov [Wed, 18 Dec 2024 16:03:35 +0000 (20:03 +0400)]
SSL: object cache inheritance from the old configuration cycle.

Memory based objects are always inherited, engine based objects are
never inherited to adhere the volatile nature of engines, file based
objects are inherited subject to modification time and file index.

The previous behaviour to bypass cache from the old configuration cycle
is preserved with a new directive "ssl_object_cache_inheritable off;".

15 months agoSlice filter: log the expected range in case of range error.
Daniel Vasquez Lopez [Thu, 21 Nov 2024 22:27:07 +0000 (14:27 -0800)]
Slice filter: log the expected range in case of range error.

16 months agoGzip: compatibility with recent zlib-ng 2.2.x versions.
Sergey Kandaurov [Mon, 23 Dec 2024 13:57:45 +0000 (17:57 +0400)]
Gzip: compatibility with recent zlib-ng 2.2.x versions.

It now uses 5/4 times more memory for the pending buffer.

Further, a single allocation is now used, which takes additional 56 bytes
for deflate_allocs in 64-bit mode aligned to 16, to store sub-allocation
pointers, and the total allocation size now padded up to 128 bytes, which
takes theoretically 200 additional bytes in total.  This fits though into
"4 * (64 + sizeof(void*))" additional space for ZALLOC used in zlib-ng
2.1.x versions.  The comment was updated to reflect this.

16 months agoYear 2025.
Roman Arutyunyan [Thu, 9 Jan 2025 13:00:14 +0000 (17:00 +0400)]
Year 2025.

16 months agoQUIC: fixed accessing a released stream.
Roman Arutyunyan [Tue, 10 Dec 2024 14:19:27 +0000 (18:19 +0400)]
QUIC: fixed accessing a released stream.

While trying to close a stream in ngx_quic_close_streams() by calling its
read event handler, the next stream saved prior to that could be destroyed
recursively.  This caused a segfault while trying to access the next stream.

The way the next stream could be destroyed in HTTP/3 is the following.
A request stream read event handler ngx_http_request_handler() could
end up calling ngx_http_v3_send_cancel_stream() to report a cancelled
request stream in the decoder stream.  If sending stream cancellation
decoder instruction fails for any reason, and the decoder stream is the
next in order after the request stream, the issue is triggered.

The fix is to postpone calling read event handlers for all streams being
closed to avoid closing a released stream.

16 months agoQUIC: ignore version negotiation packets.
Roman Arutyunyan [Fri, 13 Dec 2024 09:25:26 +0000 (13:25 +0400)]
QUIC: ignore version negotiation packets.

Previously, such packets were treated as long header packets with unknown
version 0, and a version negotiation packet was sent in response.  This
could be used to set up an infinite traffic reflect loop with another nginx
instance.

Now version negotiation packets are ignored.  As per RFC 9000, Section 6.1:

  An endpoint MUST NOT send a Version Negotiation packet in response to
  receiving a Version Negotiation packet.

16 months agoUpdated security policy to clarify experimental features.
Jordan Zebor [Mon, 23 Dec 2024 16:07:01 +0000 (08:07 -0800)]
Updated security policy to clarify experimental features.

The original security policy language did not capture the scope
as intended for experimental features and availability.

17 months agoQUIC: fixed client request timeout in 0-RTT scenarios.
nandsky [Mon, 25 Nov 2024 07:26:29 +0000 (15:26 +0800)]
QUIC: fixed client request timeout in 0-RTT scenarios.

Since 0-RTT and 1-RTT data exist in the same packet number space,
ngx_quic_discard_ctx incorrectly discards 1-RTT packets when
0-RTT keys are discarded.

The issue was introduced by 58b92177e7c3c50f77f807ab3846ad5c7bbf0ebe.

17 months agoVersion bump.
Roman Arutyunyan [Wed, 27 Nov 2024 16:01:26 +0000 (20:01 +0400)]
Version bump.

17 months agonginx-1.27.3-RELEASE release-1.27.3
Sergey Kandaurov [Tue, 26 Nov 2024 11:36:52 +0000 (15:36 +0400)]
nginx-1.27.3-RELEASE

17 months agoMail: handling of LOGIN IMAP command untagged response.
Sergey Kandaurov [Wed, 23 Oct 2024 20:52:21 +0000 (00:52 +0400)]
Mail: handling of LOGIN IMAP command untagged response.

In particular, an untagged CAPABILITY response as described in the
interim RFC 3501 internet drafts was seen in various IMAP servers.
Previously resulted in a broken connection, now an untagged response
is proxied to client.

17 months agoRealip: allowed square brackets with portless IPv6 address.
Roman Arutyunyan [Mon, 11 Nov 2024 18:28:30 +0000 (22:28 +0400)]
Realip: allowed square brackets with portless IPv6 address.

When client address is received, IPv6 address could be specified without
square brackets and without port, as well as both with the brackets and
port.  The change allows IPv6 in square brackets and no port, which was
previously considered an error.  This format conforms to RFC 3986.

The change also affects proxy_bind and friends.

17 months agoQUIC: got rid of memory copy when initializing constant values.
Sergey Kandaurov [Mon, 7 Oct 2024 14:43:48 +0000 (18:43 +0400)]
QUIC: got rid of memory copy when initializing constant values.

17 months agoQUIC: constified nonce parameter of crypto functions.
Sergey Kandaurov [Mon, 7 Oct 2024 14:19:24 +0000 (18:19 +0400)]
QUIC: constified nonce parameter of crypto functions.

This follows OpenSSL and BoringSSL API, and gives a hint to compiler
that this parameter may not be modified.

17 months agoUpstream: disallow empty path in proxy_store and friends.
Sergey Kandaurov [Thu, 21 Nov 2024 08:35:50 +0000 (12:35 +0400)]
Upstream: disallow empty path in proxy_store and friends.

Renaming a temporary file to an empty path ("") returns NGX_ENOPATH
with a subsequent ngx_create_full_path() to create the full path.
This function skips initial bytes as part of path separator lookup,
which causes out of bounds access on short strings.

The fix is to avoid renaming a temporary file to an obviously invalid
path, as well as explicitly forbid such syntax for literal values.

Although Coverity reports about potential type underflow, it is not
actually possible because the terminating '\0' is always included.

Notably, the run-time check is sufficient enough for Win32 as well.
Other short invalid values result either in NGX_ENOENT or NGX_EEXIST
and "MoveFile() .. failed" critical log messages, which involves a
separate error handling.

Prodded by Coverity (CID 1605485).

17 months agoQUIC: prevented BIO leak in case of error.
Roman Arutyunyan [Fri, 22 Nov 2024 07:38:06 +0000 (11:38 +0400)]
QUIC: prevented BIO leak in case of error.

17 months agoSSL: a new macro to set default protocol versions.
Sergey Kandaurov [Mon, 18 Nov 2024 09:39:13 +0000 (13:39 +0400)]
SSL: a new macro to set default protocol versions.

This simplifies merging protocol values after ea15896 and ebd18ec.

Further, as outlined in ebd18ec18, for libraries preceeding TLSv1.2+
support, only meaningful versions TLSv1 and TLSv1.1 are set by default.

While here, fixed indentation.

17 months agoMp4: prevent chunk index underflow.
Roman Arutyunyan [Tue, 22 Oct 2024 14:34:13 +0000 (18:34 +0400)]
Mp4: prevent chunk index underflow.

When cropping stsc atom, it's assumed that chunk index is never 0.
Based on this assumption, start_chunk and end_chunk are calculated
by subtracting 1 from it.  If chunk index is zero, start_chunk or
end_chunk may underflow, which will later trigger
"start/end time is out mp4 stco chunks" error.  The change adds an
explicit check for zero chunk index to avoid underflow and report
a proper error.

Zero chunk index is explicitly banned in ISO/IEC 14496-12, 8.7.4
Sample To Chunk Box.  It's also implicitly banned in QuickTime File
Format specification.  Description of chunk offset table references
"Chunk 1" as the first table element.

17 months agoMp4: unordered stsc chunks error for the final chunk.
Roman Arutyunyan [Wed, 2 Oct 2024 12:22:15 +0000 (16:22 +0400)]
Mp4: unordered stsc chunks error for the final chunk.

Currently an error is triggered if any of the chunk runs in stsc are
unordered.  This however does not include the final chunk run, which
ends with trak->chunks + 1.  The previous chunk index can be larger
leading to a 32-bit overflow.  This could allow to skip the validity
check "if (start_sample > n)".  This could later lead to a large
trak->start_chunk/trak->end_chunk, which would be caught later in
ngx_http_mp4_update_stco_atom() or ngx_http_mp4_update_co64_atom().

While there are no implications of the validity check being avoided,
the change still adds a check to ensure the final chunk run is ordered,
to produce a meaningful error and avoid a potential integer overflow.

17 months agoMp4: fixed handling an empty run of chunks in stsc atom.
Roman Arutyunyan [Mon, 23 Sep 2024 11:51:30 +0000 (15:51 +0400)]
Mp4: fixed handling an empty run of chunks in stsc atom.

A specially crafted mp4 file with an empty run of chunks in the stsc atom
and a large value for samples per chunk for that run, combined with a
specially crafted request, allowed to store that large value in prev_samples
and later in trak->end_chunk_samples while in ngx_http_mp4_crop_stsc_data().
Later in ngx_http_mp4_update_stsz_atom() this could result in buffer
overread while calculating trak->end_chunk_samples_size.

Now the value of samples per chunk specified for an empty run is ignored.

17 months agoFixed missing double quote.
Nathan Mentze [Wed, 20 Nov 2024 00:13:52 +0000 (18:13 -0600)]
Fixed missing double quote.

17 months agoSSL: error message default in object caching API.
Sergey Kandaurov [Mon, 28 Oct 2024 20:50:40 +0000 (00:50 +0400)]
SSL: error message default in object caching API.

This change initializes the "err" variable, used to produce a meaningful
diagnostics on error path, to a good safe value.

17 months agoOn DragonFly BSD 5.8+, TCP_KEEPIDLE and TCP_KEEPINTVL are in secs.
Andy Pan [Tue, 15 Oct 2024 09:20:20 +0000 (17:20 +0800)]
On DragonFly BSD 5.8+, TCP_KEEPIDLE and TCP_KEEPINTVL are in secs.

17 months agoFixed link to contributing guidelines.
Dan Callahan [Fri, 6 Sep 2024 15:57:50 +0000 (16:57 +0100)]
Fixed link to contributing guidelines.

Absolute paths in links end up being rooted at github.com.
The contributing guidelines link is broken unless we use the full URL.
Also, remove superfluous "monospace formatting" for the link.

17 months agoUwsgi: added create_loc_conf comments.
Sergey Kandaurov [Tue, 8 Oct 2024 14:24:34 +0000 (18:24 +0400)]
Uwsgi: added create_loc_conf comments.

17 months agoSCGI: added create_loc_conf comments.
Sergey Kandaurov [Tue, 8 Oct 2024 14:24:00 +0000 (18:24 +0400)]
SCGI: added create_loc_conf comments.

17 months agoFastCGI: fixed create_loc_conf comments after 05b1a8f1e.
Sergey Kandaurov [Tue, 8 Oct 2024 13:48:15 +0000 (17:48 +0400)]
FastCGI: fixed create_loc_conf comments after 05b1a8f1e.

17 months agoSSL: fixed MSVC compilation after ebd18ec1812b.
蕭澧邦 [Sun, 3 Nov 2024 06:36:17 +0000 (14:36 +0800)]
SSL: fixed MSVC compilation after ebd18ec1812b.

MSVC generates a compilation error in case #if/#endif is used in a macro
parameter.

18 months agoUpstream: copy upstream zone DNS valid time during config reload.
Mini Hawthorne [Wed, 12 Jul 2023 19:20:45 +0000 (12:20 -0700)]
Upstream: copy upstream zone DNS valid time during config reload.

Previously, all upstream DNS entries would be immediately re-resolved
on config reload.  With a large number of upstreams, this creates
a spike of DNS resolution requests.  These spikes can overwhelm the
DNS server or cause drops on the network.

This patch retains the TTL of previous resolutions across reloads
by copying each upstream's name's expiry time across configuration
cycles.  As a result, no additional resolutions are needed.

18 months agoUpstream: per-upstream resolver.
Vladimir Homutov [Fri, 18 Oct 2019 13:33:15 +0000 (16:33 +0300)]
Upstream: per-upstream resolver.

The "resolver" and "resolver_timeout" directives can now be specified
directly in the "upstream" block.

18 months agoUpstream: pre-resolve servers on reload.
Ruslan Ermilov [Fri, 3 Nov 2017 19:22:23 +0000 (22:22 +0300)]
Upstream: pre-resolve servers on reload.

After configuration is reloaded, it may take some time for the
re-resolvable upstream servers to resolve and become available
as peers.  During this time, client requests might get dropped.

Such servers are now pre-resolved using the "cache" of already
resolved peers from the old shared memory zone.

18 months agoCore: inheritance of non-reusable shared memory zones.
Ruslan Ermilov [Fri, 3 Nov 2017 19:22:21 +0000 (22:22 +0300)]
Core: inheritance of non-reusable shared memory zones.

When re-creating a non-reusable zone, make the pointer to the old zone
available during the new zone initialization.

18 months agoUpstream: construct upstream peers from DNS SRV records.
Dmitry Volyntsev [Thu, 17 Mar 2016 15:42:31 +0000 (18:42 +0300)]
Upstream: construct upstream peers from DNS SRV records.

18 months agoUpstream: re-resolvable servers.
Ruslan Ermilov [Sat, 15 Feb 2014 11:12:34 +0000 (15:12 +0400)]
Upstream: re-resolvable servers.

Specifying the upstream server by a hostname together with the
"resolve" parameter will make the hostname to be periodically
resolved, and upstream servers added/removed as necessary.

This requires a "resolver" at the "http" configuration block.

The "resolver_timeout" parameter also affects when the failed
DNS requests will be attempted again.  Responses with NXDOMAIN
will be attempted again in 10 seconds.

Upstream has a configuration generation number that is incremented each
time servers are added/removed to the primary/backup list.  This number
is remembered by the peer.init method, and if peer.get detects a change
in configuration, it returns NGX_BUSY.

Each server has a reference counter.  It is incremented by peer.get and
decremented by peer.free.  When a server is removed, it is removed from
the list of servers and is marked as "zombie".  The memory allocated by
a zombie peer is freed only when its reference count becomes zero.

Co-authored-by: Roman Arutyunyan <arut@nginx.com>
Co-authored-by: Sergey Kandaurov <pluknet@nginx.com>
Co-authored-by: Vladimir Homutov <vl@nginx.com>
18 months agoSSL: disabled TLSv1 and TLSv1.1 by default.
Sergey Kandaurov [Wed, 9 Oct 2024 16:28:00 +0000 (20:28 +0400)]
SSL: disabled TLSv1 and TLSv1.1 by default.

TLSv1 and TLSv1.1 are formally deprecated and forbidden to negotiate due
to insufficient security reasons outlined in RFC 8996.

TLSv1 and TLSv1.1 are disabled in BoringSSL e95b0cad9 and LibreSSL 3.8.1
in the way they cannot be enabled in nginx configuration.  In OpenSSL 3.0,
they are only permitted at security level 0 (disabled by default).

The support is dropped in Chrome 84, Firefox 78, and deprecated in Safari.

This change disables TLSv1 and TLSv1.1 by default for OpenSSL 1.0.1 and
newer, where TLSv1.2 support is available.  For older library versions,
which do not have alternatives, these protocol versions remain enabled.

18 months agoUpdated security policy to include disclosure details.
jzebor-at-f5 [Fri, 11 Oct 2024 16:48:53 +0000 (09:48 -0700)]
Updated security policy to include disclosure details.

18 months agoConfigure: MSVC compatibility with PCRE2 10.43.
Thierry Bastian [Wed, 9 Oct 2024 07:18:49 +0000 (09:18 +0200)]
Configure: MSVC compatibility with PCRE2 10.43.

19 months agoQUIC: prevent deleted stream frame retransmissions.
nandsky [Mon, 30 Sep 2024 12:51:17 +0000 (20:51 +0800)]
QUIC: prevent deleted stream frame retransmissions.

Since a2a513b93cae, stream frames no longer need to be retransmitted after it
was deleted.  The frames which were retransmitted before, could be stream data
frames sent prior to a RESET_STREAM. Such retransmissions are explicitly
prohibited by RFC 9000, Section 19.4.

19 months agoVersion bump.
Sergey Kandaurov [Mon, 7 Oct 2024 15:10:39 +0000 (19:10 +0400)]
Version bump.

19 months agonginx-1.27.2-RELEASE release-1.27.2
Sergey Kandaurov [Tue, 1 Oct 2024 19:59:48 +0000 (23:59 +0400)]
nginx-1.27.2-RELEASE

19 months agoUpdated OpenSSL used for win32 builds.
Sergey Kandaurov [Tue, 1 Oct 2024 15:23:45 +0000 (19:23 +0400)]
Updated OpenSSL used for win32 builds.

19 months agoSSL: caching CA certificates.
Sergey Kandaurov [Mon, 9 Sep 2024 15:05:58 +0000 (19:05 +0400)]
SSL: caching CA certificates.

This can potentially provide a large amount of savings,
because CA certificates can be quite large.

Based on previous work by Mini Hawthorne.

19 months agoSSL: caching CRLs.
Sergey Kandaurov [Mon, 9 Sep 2024 15:05:31 +0000 (19:05 +0400)]
SSL: caching CRLs.

Based on previous work by Mini Hawthorne.

19 months agoSSL: caching certificate keys.
Sergey Kandaurov [Mon, 9 Sep 2024 15:04:18 +0000 (19:04 +0400)]
SSL: caching certificate keys.

EVP_KEY objects are a reference-counted container for key material, shallow
copies and OpenSSL stack management aren't needed as with certificates.

Based on previous work by Mini Hawthorne.

19 months agoSSL: caching certificates.
Sergey Kandaurov [Mon, 9 Sep 2024 15:03:52 +0000 (19:03 +0400)]
SSL: caching certificates.

Certificate chains are now loaded once.

The certificate cache provides each chain as a unique stack of reference
counted elements.  This shallow copy is required because OpenSSL stacks
aren't reference counted.

Based on previous work by Mini Hawthorne.

19 months agoSSL: object caching.
Sergey Kandaurov [Mon, 9 Sep 2024 15:03:20 +0000 (19:03 +0400)]
SSL: object caching.

Added ngx_openssl_cache_module, which indexes a type-aware object cache.
It maps an id to a unique instance, and provides references to it, which
are dropped when the cycle's pool is destroyed.

The cache will be used in subsequent patches.

Based on previous work by Mini Hawthorne.

19 months agoSSL: moved certificate storage out of exdata.
Sergey Kandaurov [Mon, 9 Sep 2024 15:02:27 +0000 (19:02 +0400)]
SSL: moved certificate storage out of exdata.

Instead of cross-linking the objects using exdata, pointers to configured
certificates are now stored in ngx_ssl_t, and OCSP staples are now accessed
with rbtree in it.  This allows sharing these objects between SSL contexts.

Based on previous work by Mini Hawthorne.

19 months agoFixed a typo of bpf makefile debug option.
tzssangglass [Mon, 9 Sep 2024 15:22:34 +0000 (23:22 +0800)]
Fixed a typo of bpf makefile debug option.

19 months agoAdded new primary README.md file.
Michael Vernik [Sun, 1 Sep 2024 05:42:09 +0000 (22:42 -0700)]
Added new primary README.md file.

19 months agoSSL: optional ssl_client_certificate for ssl_verify_client.
Sergey Kandaurov [Fri, 20 Sep 2024 10:08:42 +0000 (14:08 +0400)]
SSL: optional ssl_client_certificate for ssl_verify_client.

Starting from TLSv1.1 (as seen since draft-ietf-tls-rfc2246-bis-00),
the "certificate_authorities" field grammar of the CertificateRequest
message was redone to allow no distinguished names.  In TLSv1.3, with
the restructured CertificateRequest message, this can be similarly
done by optionally including the "certificate_authorities" extension.
This allows to avoid sending DNs at all.

In practice, aside from published TLS specifications, all supported
SSL/TLS libraries allow to request client certificates with an empty
DN list for any protocol version.  For instance, when operating in
TLSv1, this results in sending the "certificate_authorities" list as
a zero-length vector, which corresponds to the TLSv1.1 specification.
Such behaviour goes back to SSLeay.

The change relaxes the requirement to specify at least one trusted CA
certificate in the ssl_client_certificate directive, which resulted in
sending DNs of these certificates (closes #142).  Instead, all trusted
CA certificates can be specified now using the ssl_trusted_certificate
directive if needed.  A notable difference that certificates specified
in ssl_trusted_certificate are always loaded remains (see 3648ba7db).

Co-authored-by: Praveen Chaudhary <praveenc@nvidia.com>
19 months agoProxy: proxy_pass_trailers directive.
Sergey Kandaurov [Tue, 10 Sep 2024 12:48:11 +0000 (16:48 +0400)]
Proxy: proxy_pass_trailers directive.

The directive allows to pass upstream response trailers to client.

20 months agoFixed a typo in win-utf.
Shaikh Yaser [Thu, 5 Sep 2024 15:17:54 +0000 (20:47 +0530)]
Fixed a typo in win-utf.

20 months agoAdded CI based on GitHub Actions.
Konstantin Pavlov [Thu, 18 Jul 2024 20:42:43 +0000 (13:42 -0700)]
Added CI based on GitHub Actions.

Pushes to master and stable branches will result in buildbot-like checks
on multiple OSes and architectures.

Pull requests will be checked on a public Ubuntu GitHub runner.

20 months agoAdded GitHub templates.
Maryna Herasimovich [Thu, 29 Aug 2024 20:06:48 +0000 (13:06 -0700)]
Added GitHub templates.

20 months agoAdded contributing guidelines.
Maryna Herasimovich [Thu, 29 Aug 2024 03:43:08 +0000 (20:43 -0700)]
Added contributing guidelines.

20 months agoAdded security policy.
Maryna Herasimovich [Thu, 29 Aug 2024 03:51:54 +0000 (20:51 -0700)]
Added security policy.

20 months agoAdded Code of Conduct.
Maryna Herasimovich [Thu, 29 Aug 2024 03:13:13 +0000 (20:13 -0700)]
Added Code of Conduct.

20 months agoRemoved C-style comments from LICENSE.
Roman Arutyunyan [Thu, 29 Aug 2024 13:14:25 +0000 (17:14 +0400)]
Removed C-style comments from LICENSE.

20 months agoMoved LICENSE and README to root.
Roman Arutyunyan [Thu, 29 Aug 2024 12:24:03 +0000 (16:24 +0400)]
Moved LICENSE and README to root.

20 months agoSwitched GNUmakefile from hg to git.
Roman Arutyunyan [Thu, 29 Aug 2024 12:03:58 +0000 (16:03 +0400)]
Switched GNUmakefile from hg to git.

20 months agoRemoved .hgtags file.
Roman Arutyunyan [Thu, 29 Aug 2024 12:03:27 +0000 (16:03 +0400)]
Removed .hgtags file.

20 months agoStream: OCSP stapling. default
Sergey Kandaurov [Thu, 22 Aug 2024 10:57:46 +0000 (14:57 +0400)]
Stream: OCSP stapling.

20 months agoStream: client certificate validation with OCSP.
Sergey Kandaurov [Thu, 22 Aug 2024 10:57:45 +0000 (14:57 +0400)]
Stream: client certificate validation with OCSP.

20 months agoVersion bump.
Sergey Kandaurov [Tue, 20 Aug 2024 17:18:30 +0000 (21:18 +0400)]
Version bump.

20 months agorelease-1.27.1 tag
Sergey Kandaurov [Mon, 12 Aug 2024 14:21:01 +0000 (18:21 +0400)]
release-1.27.1 tag

20 months agonginx-1.27.1-RELEASE release-1.27.1
Sergey Kandaurov [Mon, 12 Aug 2024 14:20:52 +0000 (18:20 +0400)]
nginx-1.27.1-RELEASE

20 months agoUpdated OpenSSL used for win32 builds.
Sergey Kandaurov [Mon, 12 Aug 2024 14:20:49 +0000 (18:20 +0400)]
Updated OpenSSL used for win32 builds.

20 months agoMp4: rejecting unordered chunks in stsc atom.
Roman Arutyunyan [Mon, 12 Aug 2024 14:20:45 +0000 (18:20 +0400)]
Mp4: rejecting unordered chunks in stsc atom.

Unordered chunks could result in trak->end_chunk smaller than trak->start_chunk
in ngx_http_mp4_crop_stsc_data().  Later in ngx_http_mp4_update_stco_atom()
this caused buffer overread while trying to calculate trak->end_offset.

20 months agoMp4: fixed buffer underread while updating stsz atom.
Roman Arutyunyan [Mon, 12 Aug 2024 14:20:43 +0000 (18:20 +0400)]
Mp4: fixed buffer underread while updating stsz atom.

While cropping an stsc atom in ngx_http_mp4_crop_stsc_data(), a 32-bit integer
overflow could happen, which could result in incorrect seeking and a very large
value stored in "samples".  This resulted in a large invalid value of
trak->end_chunk_samples.  This value is further used to calculate the value of
trak->end_chunk_samples_size in ngx_http_mp4_update_stsz_atom().  While doing
this, a large invalid value of trak->end_chunk_samples could result in reading
memory before stsz atom start.  This could potentially result in a segfault.

21 months agoStream ssl_preread: do not reallocate a parsed SNI host.
Sergey Kandaurov [Fri, 9 Aug 2024 15:12:26 +0000 (19:12 +0400)]
Stream ssl_preread: do not reallocate a parsed SNI host.

We own this memory from the session pool.

21 months agoQUIC: zero out existing keying material only.
Sergey Kandaurov [Fri, 9 Aug 2024 15:12:26 +0000 (19:12 +0400)]
QUIC: zero out existing keying material only.

Previously, this used to have extra ngx_explicit_memzero() calls
from within ngx_quic_keys_cleanup(), which might be suboptimal.

21 months agoQUIC: discarding 0-RTT keys.
Sergey Kandaurov [Fri, 9 Aug 2024 15:12:25 +0000 (19:12 +0400)]
QUIC: discarding 0-RTT keys.

For simplicity, this is done on successful decryption of a 1-RTT packet.

21 months agoTypo fixed.
Sergey Kandaurov [Fri, 9 Aug 2024 15:12:23 +0000 (19:12 +0400)]
Typo fixed.

21 months agoVersion bump.
Sergey Kandaurov [Fri, 9 Aug 2024 14:01:42 +0000 (18:01 +0400)]
Version bump.

21 months agoHTTP/2: close connections initialized during graceful shutdown.
Kasei Wang [Thu, 18 Jul 2024 13:43:25 +0000 (17:43 +0400)]
HTTP/2: close connections initialized during graceful shutdown.

In some rare cases, graceful shutdown may happen while initializing an HTTP/2
connection.  Previously, such a connection ignored the shutdown and remained
active.  Now it is gracefully closed prior to processing any streams to
eliminate the shutdown delay.

22 months agoStream: allow servers with no handler.
Roman Arutyunyan [Thu, 27 Jun 2024 13:29:56 +0000 (17:29 +0400)]
Stream: allow servers with no handler.

Previously handlers were mandatory.  However they are not always needed.
For example, a server configured with ssl_reject_handshake does not need a
handler.  Such servers required a fake handler to pass the check.  Now handler
absence check is moved to runtime.  If handler is missing, the connection is
closed with 500 code.

23 months agorelease-1.27.0 tag
Sergey Kandaurov [Tue, 28 May 2024 13:22:30 +0000 (17:22 +0400)]
release-1.27.0 tag

23 months agonginx-1.27.0-RELEASE release-1.27.0
Sergey Kandaurov [Tue, 28 May 2024 13:19:38 +0000 (17:19 +0400)]
nginx-1.27.0-RELEASE

23 months agoHTTP/3: fixed handling of zero-length literal field line.
Sergey Kandaurov [Tue, 28 May 2024 13:20:45 +0000 (17:20 +0400)]
HTTP/3: fixed handling of zero-length literal field line.

Previously, st->value was passed with NULL data pointer to header handlers.

23 months agoQUIC: ngx_quic_buffer_t use-after-free protection.
Roman Arutyunyan [Tue, 28 May 2024 13:19:21 +0000 (17:19 +0400)]
QUIC: ngx_quic_buffer_t use-after-free protection.

Previously the last chain field of ngx_quic_buffer_t could still reference freed
chains and buffers after calling ngx_quic_free_buffer().  While normally an
ngx_quic_buffer_t object should not be used after freeing, resetting last_chain
field would prevent a potential use-after-free.

23 months agoQUIC: ignore CRYPTO frames after handshake completion.
Roman Arutyunyan [Tue, 28 May 2024 13:19:08 +0000 (17:19 +0400)]
QUIC: ignore CRYPTO frames after handshake completion.

Sending handshake-level CRYPTO frames after the client's Finished message could
lead to memory disclosure and a potential segfault, if those frames are sent in
one packet with the Finished frame.

23 months agoHTTP/3: fixed dynamic table overflow.
Roman Arutyunyan [Tue, 28 May 2024 13:18:50 +0000 (17:18 +0400)]
HTTP/3: fixed dynamic table overflow.

While inserting a new entry into the dynamic table, first the entry is added,
and then older entries are evicted until table size is within capacity.  After
the first step, the number of entries may temporarily exceed the maximum
calculated from capacity by one entry, which previously caused table overflow.

The easiest way to trigger the issue is to keep adding entries with empty names
and values until first eviction.

The issue was introduced by 987bee4363d1.

23 months agoHTTP/3: decoder stream pre-creation.
Roman Arutyunyan [Tue, 28 May 2024 13:18:28 +0000 (17:18 +0400)]
HTTP/3: decoder stream pre-creation.

Previously a decoder stream was created on demand for sending Section
Acknowledgement, Stream Cancellation and Insert Count Increment.  If conditions
for sending any of these instructions never happen, a decoder stream is not
created at all.  These conditions include client not using the dynamic table and
no streams abandoned by server (RFC 9204, Section 2.2.2.2).  However RFC 9204,
Section 4.2 defines only one condition for not creating a decoder stream:

   An endpoint MAY avoid creating a decoder stream if its decoder sets
   the maximum capacity of the dynamic table to zero.

The change enables pre-creation of the decoder stream at HTTP/3 session
initialization if maximum dynamic table capacity is not zero.  Note that this
value is currently hardcoded to 4096 bytes and is not configurable, so the
stream is now always created.

Also, the change fixes a potential stack overflow when creating a decoder
stream in ngx_http_v3_send_cancel_stream() while draining a request stream by
ngx_drain_connections().  Creating a decoder stream involves calling
ngx_get_connection(), which calls ngx_drain_connections(), which will drain the
same request stream again.  If client's MAX_STREAMS for uni stream is high
enough, these recursive calls will continue until we run out of stack.
Otherwise, decoder stream creation will fail at some point and the request
stream connection will be drained.  This may result in use-after-free, since
this connection could still be referenced up the stack.

23 months agoQUIC: client transport parameter data length checking.
Sergey Kandaurov [Tue, 28 May 2024 13:17:19 +0000 (17:17 +0400)]
QUIC: client transport parameter data length checking.

2 years agoUpstream: variables support in proxy_limit_rate and friends.
J Carter [Sat, 25 Nov 2023 21:57:09 +0000 (21:57 +0000)]
Upstream: variables support in proxy_limit_rate and friends.