summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2025-02-05nginx-1.26.3-RELEASErelease-1.26.3Sergey Kandaurov1-0/+81
2025-02-05SNI: added restriction for TLSv1.3 cross-SNI session resumption.Sergey Kandaurov2-4/+50
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.
2025-02-05Updated OpenSSL used for win32 builds.Sergey Kandaurov1-1/+1
2025-02-05Configure: fixed --with-libatomic=DIR with recent libatomic_ops.Sergey Kandaurov2-5/+10
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
2025-02-05QUIC: added missing casts in iov_base assignments.Aleksei Bavshin1-2/+2
This is consistent with the rest of the code and fixes build on systems with non-standard definition of struct iovec (Solaris, Illumos).
2025-02-05Gzip: compatibility with recent zlib-ng 2.2.x versions.Sergey Kandaurov1-3/+5
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.
2025-02-05QUIC: prevented BIO leak in case of error.Roman Arutyunyan1-0/+1
2025-02-05QUIC: fixed accessing a released stream.Roman Arutyunyan1-5/+13
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.
2025-02-05QUIC: ignore version negotiation packets.Roman Arutyunyan1-0/+5
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.
2025-02-05Mp4: prevent chunk index underflow.Roman Arutyunyan1-0/+6
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.
2025-02-05Mp4: unordered stsc chunks error for the final chunk.Roman Arutyunyan1-0/+7
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.
2025-02-05Mp4: fixed handling an empty run of chunks in stsc atom.Roman Arutyunyan1-1/+4
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.
2025-02-05Configure: MSVC compatibility with PCRE2 10.43.Thierry Bastian1-1/+2
2025-02-05Moved LICENSE and README to root.Roman Arutyunyan3-2/+0
2025-02-05Switched GNUmakefile from hg to git.Roman Arutyunyan1-5/+5
2025-02-05Version bump.Sergey Kandaurov1-2/+2
2024-08-12release-1.26.2 tagSergey Kandaurov1-0/+1
2024-08-12nginx-1.26.2-RELEASErelease-1.26.2Sergey Kandaurov1-0/+18
2024-08-12Updated OpenSSL used for win32 builds.Sergey Kandaurov1-1/+1
2024-08-12Mp4: rejecting unordered chunks in stsc atom.Roman Arutyunyan1-0/+7
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.
2024-08-12Mp4: fixed buffer underread while updating stsz atom.Roman Arutyunyan1-3/+4
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.
2024-08-09Typo fixed.Sergey Kandaurov1-2/+2
2024-08-12Version bump.Sergey Kandaurov1-2/+2
2024-05-28release-1.26.1 tagSergey Kandaurov1-0/+1
2024-05-28nginx-1.26.1-RELEASErelease-1.26.1Sergey Kandaurov1-0/+56
2024-05-28HTTP/3: fixed handling of zero-length literal field line.Sergey Kandaurov1-0/+3
Previously, st->value was passed with NULL data pointer to header handlers.
2024-05-28QUIC: ngx_quic_buffer_t use-after-free protection.Roman Arutyunyan1-0/+1
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.
2024-05-28QUIC: ignore CRYPTO frames after handshake completion.Roman Arutyunyan1-0/+5
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.
2024-05-28HTTP/3: fixed dynamic table overflow.Roman Arutyunyan1-1/+1
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.
2024-05-28HTTP/3: decoder stream pre-creation.Roman Arutyunyan3-9/+17
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.
2024-05-28QUIC: client transport parameter data length checking.Sergey Kandaurov1-0/+8
2024-05-23Optimized chain link usage (ticket #2614).Roman Arutyunyan6-14/+45
Previously chain links could sometimes be dropped instead of being reused, which could result in increased memory consumption during long requests. A similar chain link issue in ngx_http_gzip_filter_module was fixed in da46bfc484ef (1.11.10). Based on a patch by Sangmin Lee.
2024-05-16Configure: fixed building libatomic test.Edgar Bonet1-1/+1
Using "long *" instead of "AO_t *" leads either to -Wincompatible-pointer-types or -Wpointer-sign warnings, depending on whether long and size_t are compatible types (e.g., ILP32 versus LP64 data models). Notably, -Wpointer-sign warnings are enabled by default in Clang only, and -Wincompatible-pointer-types is an error starting from GCC 14. Signed-off-by: Edgar Bonet <bonet@grenoble.cnrs.fr>
2024-05-28Version bump.Sergey Kandaurov1-2/+2
2024-04-23release-1.26.0 tagRoman Arutyunyan1-0/+1
2024-04-23nginx-1.26.0-RELEASErelease-1.26.0Roman Arutyunyan1-0/+14
2024-04-23Stable branch.Roman Arutyunyan1-2/+2
2024-04-16release-1.25.5 tagRoman Arutyunyan1-0/+1
2024-04-16nginx-1.25.5-RELEASErelease-1.25.5Roman Arutyunyan1-0/+77
2024-04-11Stream pass: limited the number of passes per connection.Roman Arutyunyan1-0/+51
Previously a cycle in pass configuration resulted in stack overflow.
2024-04-10QUIC: fixed close timer processing with early data.Vladimir Khomutov1-1/+4
The ngx_quic_run() function uses qc->close timer to limit the handshake duration. Normally it is removed by ngx_quic_do_init_streams() which is called once when we are done with initial SSL processing. The problem happens when the client sends early data and streams are initialized in the ngx_quic_run() -> ngx_quic_handle_datagram() call. The order of set/remove timer calls is now reversed; the close timer is set up and the timer fires when assigned, starting the unexpected connection close process. The fix is to skip setting the timer if streams were initialized during handling of the initial datagram. The idle timer for quic is set anyway, and stream-related timeouts are managed by application layer.
2024-02-26Configure: allow cross-compiling to Windows using Clang.Piotr Sikora1-1/+1
Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2024-02-26Configure: fixed "make install" when cross-compiling to Windows.Piotr Sikora1-1/+1
Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2024-02-26Configure: added support for Homebrew on Apple Silicon.Piotr Sikora5-0/+84
Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2024-03-27Configure: set cache line size for more architectures.Sergey Kandaurov1-0/+15
Based on a patch by Piotr Sikora.
2024-02-26Detect cache line size at runtime on macOS.Piotr Sikora2-6/+15
Notably, Apple Silicon CPUs have 128 byte cache line size, which is twice the default configured for generic aarch64. Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2024-02-26Configure: fixed Linux crypt_r() test to add libcrypt.Sergey Kandaurov1-0/+4
Previously, the resulting binary was successfully linked because libcrypt was added in a separate test for crypt(). Patch by Piotr Sikora.
2024-02-26Win32: fixed unique file index calculations.Piotr Sikora1-1/+2
The old code was breaking strict aliasing rules. Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2024-02-26Rewrite: fixed "return" directive without response text.Piotr Sikora1-0/+1
Previously, the response text wasn't initialized and the rewrite module was sending response body set to NULL. Found with UndefinedBehaviorSanitizer (pointer-overflow). Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2024-03-18Fixed undefined behaviour with IPv4-mapped IPv6 addresses.Sergey Kandaurov7-9/+9
Previously, it could result when left-shifting signed integer due to implicit integer promotion, such that the most significant bit appeared on the sign bit. In practice, though, this results in the same left value as with an explicit cast, at least on known compilers, such as GCC and Clang. The reason is that in_addr_t, which is equivalent to uint32_t and same as "unsigned int" in ILP32 and LP64 data type models, has the same type width as the intermediate after integer promotion, so there's no side effects such as sign-extension. This explains why adding an explicit cast does not change object files in practice. Found with UndefinedBehaviorSanitizer (shift). Based on a patch by Piotr Sikora.