summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-12-09QUIC: fixed possible segfault on handshake failures.Jan Svojanovsky1-0/+6
When using OpenSSL 3.5, the crypto_release_rcd QUIC callback can be called late, after the QUIC connection was already closed on handshake failure, resulting in a segmentation fault. For instance, it happened if a client Finished message didn't align with a record boundary.
2025-12-08Proxy: cache support for HTTP/2.Zhidao HONG1-25/+52
2025-12-08Proxy: buffering support for HTTP/2.Zhidao HONG1-0/+142
2025-12-08Proxy: extracted control frame and skip functions for HTTP/2.Zhidao HONG1-192/+150
2025-12-08Proxy: extracted ngx_http_proxy_v2_process_frames() function.Zhidao HONG1-72/+93
2025-12-08Proxy: added HTTP/2 proxy module.Zhidao HONG3-2/+4027
The module allows to use HTTP/2 protocol for proxying. HTTP/2 proxying is enabled by specifying "proxy_http_version 2". Example: server { listen 8000; location / { proxy_http_version 2; proxy_pass https://127.0.0.1:8443; } } server { listen 8443 ssl; http2 on; ssl_certificate certs/example.com.crt; ssl_certificate_key certs/example.com.key; location / { return 200 foo; } }
2025-12-08Proxy: refactored for HTTP/2 support.Roman Arutyunyan2-107/+182
2025-12-08Upstream: add support for connection level ALPN protocol negotiation.Zhidao HONG2-0/+18
This commit is prepared for HTTP/2 and HTTP/3 support. The ALPN protocol is now set per-connection in ngx_http_upstream_ssl_init_connection(), allowing proper protocol negotiation for each individual upstream connection regardless of SSL context sharing.
2025-12-06Disabled bare LF in chunked transfer encoding.Sergey Kandaurov2-29/+24
Chunked transfer encoding, since originally introduced in HTTP/1.1 in RFC 2068, is specified to use CRLF as the only line terminator. Although tolerant applications may recognize a single LF, formally this covers the start line and fields, and doesn't apply to chunks. Strict chunked parsing is reaffirmed as intentional in RFC errata ID 7633, notably "because it does not have to retain backwards compatibility with 1.0 parsers". A general RFC 2616 recommendation to tolerate deviations whenever interpreted unambiguously doesn't apply here, because chunked body is used to determine HTTP message framing; a relaxed parsing may cause various security problems due to a broken delimitation. For instance, this is possible when receiving chunked body from intermediates that blindly parse chunk-ext or a trailer section until CRLF, and pass it further without re-coding.
2025-12-04SSL: avoid warning when ECH is not configured and not supported.QirunGao1-3/+6
2025-12-01Add basic ECH shared-mode via OpenSSL.sftcd6-0/+221
2025-11-26Proxy: fixed segfault in URI change.Sergey Kandaurov1-3/+4
If request URI was shorter than location prefix, as after replacement with try_files, location length was used to copy the remaining URI part leading to buffer overread. The fix is to replace full request URI in this case. In the following configuration, request "/123" is changed to "/" when sent to backend. location /1234 { try_files /123 =404; proxy_pass http://127.0.0.1:8080/; } Closes #983 on GitHub.
2025-11-26Changed interface of ngx_http_validate_host().Sergey Kandaurov5-57/+31
This allows to process a port subcomponent and save it in r->port in a unified way, similar to r->headers_in.server. For HTTP/1.x request line in the absolute form, r->host_end now includes a port subcomponent, which is also consistent with HTTP/2 and HTTP/3.
2025-11-26Improved host header validation.Sergey Kandaurov2-64/+266
Validation is rewritten to follow RFC 3986 host syntax, based on ngx_http_parse_request_line(). The following is now rejected: - the rest of gen-delims "#", "?", "@", "[", "]" - other unwise delims <">, "<", ">", "\", "^", "`', "{", "|", "}" - IP literals with a trailing dot, missing closing bracket, or pct-encoded - a port subcomponent with invalid values - characters in upper half
2025-11-19HTTP/2: extended guard for NULL buffer and zero length.Sergey Kandaurov1-6/+5
In addition to moving memcpy() under the length condition in 15bf6d8cc, which addressed a reported UB due to string function conventions, this is repeated for advancing an input buffer, to make the resulting code more clean and readable. Additionally, although considered harmless for both string functions and additive operators, as previously discussed in GitHub PR 866, this fixes the main source of annoying sanitizer reports in the module. Prodded by UndefinedBehaviorSanitizer (pointer-overflow).
2025-11-10SSL: fixed build with BoringSSL, broken by 38a701d88.Sergey Kandaurov1-1/+1
2025-11-10SSL: ngx_ssl_set_client_hello_callback() error handling.Sergey Kandaurov4-9/+26
The function interface is changed to follow a common approach to other functions used to setup SSL_CTX, with an exception of "ngx_conf_t *cf" since it is not bound to nginx configuration. This is required to report and propagate SSL_CTX_set_ex_data() errors, as reminded by Coverity (CID 1668589).
2025-11-06Version bump.Sergey Kandaurov1-2/+2
2025-10-28Modules compatibility: increased compat section size.Roman Arutyunyan1-1/+1
2025-10-28Fixed compilation warnings on Windows after c93a0c48af87.Roman Arutyunyan1-2/+2
2025-10-27OCSP: fixed invalid type for the 'ssl_ocsp' directive.Roman Semenov2-2/+2
2025-10-25Headers filter: inheritance control for add_header and add_trailer.Roman Arutyunyan1-4/+70
The new directives add_header_inherit and add_trailer_inherit allow to alter inheritance rules for the values specified in the add_header and add_trailer directives in a convenient way. The "merge" parameter enables appending the values from the previous level to the current level values. The "off" parameter cancels inheritance of the values from the previous configuration level, similar to add_header "" (2194e75bb). The "on" parameter (default) enables the standard inheritance behaviour, which is to inherit values from the previous level only if there are no directives on the current level. The inheritance rules themselves are inherited in a standard way. Thus, for example, "add_header_inherit merge;" specified at the top level will be inherited in all nested levels recursively unless redefined below.
2025-10-24Geo: the "volatile" parameter.Dmitry Plotnikov2-0/+24
Similar to map's volatile parameter, creates a non-cacheable geo variable.
2025-10-24SSL: $ssl_sigalg, $ssl_client_sigalg.Sergey Kandaurov4-0/+68
Variables contain the IANA name of the signature scheme[1] used to sign the TLS handshake. Variables are only meaningful when using OpenSSL 3.5 and above, with older versions they are empty. Moreover, since this data isn't stored in a serialized session, variables are only available for new sessions. [1] https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml Requested by willmafh.
2025-10-24Upstream: reset local address in case of error.Roman Arutyunyan2-0/+4
After f10bc5a763bb the address was set to NULL only when local address was not specified at all. In case complex value evaluated to an empty or invalid string, local address remained unchanged. Currenrly this is not a problem since the value is only set once. This change is a preparation for being able to change the local address after initial setting.
2025-10-23CONNECT method support for HTTP/1.1.Roman Arutyunyan4-3/+50
The change allows modules to use the CONNECT method with HTTP/1.1 requests. To do so, they need to set the "allow_connect" flag in the core server configuration.
2025-10-23Added $request_port and $is_request_port variables.Roman Arutyunyan6-3/+98
The $request_port variable contains the port passed by the client in the request line (for HTTP/1.x) or ":authority" pseudo-header (for HTTP/2 and HTTP/3). If the request line contains no host, or ":authority" is missing, then $request_port is taken from the "Host" header, similar to the $host variable. The $is_request_port variable contains ":" if $request_port is non-empty, and is empty otherwise.
2025-10-08SSL: support for compressed server certificates with BoringSSL.Sergey Kandaurov2-0/+190
BoringSSL/AWS-LC provide two callbacks for each compression algorithm, which may be used to compress and decompress certificates in runtime. This change implements compression support with zlib, as enabled with the ssl_certificate_compression directive. Compressed certificates are stored in certificate exdata and reused in subsequent connections. Notably, AWS-LC saves an X509 pointer in SSL connection, which allows to use it from SSL_get_certificate() for caching purpose. In contrast, BoringSSL reconstructs X509 on-the-fly, though given that it doesn't support multiple certificates, always replacing previously configured certificates, we use the last configured one from ssl->certs, instead.
2025-10-08SSL: disabled using certificate compression with OCSP stapling.Sergey Kandaurov2-2/+14
OCSP response in TLSv1.3 is sent in the Certificate message. This is incompatible with pre-compression of the configured certificates.
2025-10-08Version bump.Sergey Kandaurov1-2/+2
2025-10-06SSL: fixed "key values mismatch" with object cache inheritance.Sergey Kandaurov2-12/+63
In rare cases, it was possible to get into this error state on reload with improperly updated file timestamps for certificate and key pairs. The fix is to retry on X509_R_KEY_VALUES_MISMATCH, similar to 5d5d9adcc. Additionally, loading SSL certificate is updated to avoid certificates discarded on retry to appear in ssl->certs and in extra chain.
2025-09-26Mail: xtext encoding (RFC 3461) in XCLIENT LOGIN.Sergey Kandaurov3-4/+43
The XCLIENT command uses xtext encoding for attribute values, as specified in https://www.postfix.org/XCLIENT_README.html. Reported by Igor Morgenstern of Aisle Research.
2025-09-26Upstream: overflow detection in Cache-Control delta-seconds.Sergey Kandaurov1-34/+47
Overflowing calculations are now aligned to the greatest positive integer as specified in RFC 9111, Section 1.2.2.
2025-09-25SSL: AWS-LC compatibility.Sergey Kandaurov3-3/+4
2025-09-25QUIC: a new macro to differentiate BoringSSL specific EVP API.Sergey Kandaurov2-16/+18
2025-09-25QUIC: localized OpenSSL headers used for QUIC protection.Sergey Kandaurov2-8/+6
2025-09-25SNI: support for early ClientHello callback with BoringSSL.Sergey Kandaurov4-0/+49
This brings feature parity with OpenSSL after the previous change, making it possible to set SSL protocols per virtual server.
2025-09-25SNI: using the ClientHello callback.Sergey Kandaurov5-71/+165
The change introduces an SNI based virtual server selection during early ClientHello processing. The callback is available since OpenSSL 1.1.1; for older OpenSSL versions, the previous behaviour is kept. Using the ClientHello callback sets a reasonable processing order for the "server_name" TLS extension. Notably, session resumption decision now happens after applying server configuration chosen by SNI, useful with enabled verification of client certificates, which brings consistency with BoringSSL behaviour. The change supersedes and reverts a fix made in 46b9f5d38 for TLSv1.3 resumed sessions. In addition, since the callback is invoked prior to the protocol version negotiation, this makes it possible to set "ssl_protocols" on a per-virtual server basis. To keep the $ssl_server_name variable working with TLSv1.2 resumed sessions, as previously fixed in fd97b2a80, a limited server name callback is preserved in order to acknowledge the extension. Note that to allow third-party modules to properly chain the call to ngx_ssl_client_hello_callback(), the servername callback function is passed through exdata.
2025-09-18Fixed inaccurate index directive error report.willmafh1-1/+1
2025-09-12QUIC: fixed ssl_reject_handshake error handling.Sergey Kandaurov1-11/+16
This was broken in 7468a10b6 (1.29.0), resulting in a missing diagnostics and SSL error queue not cleared for SSL handshakes rejected by SNI, seen as "ignoring stale global SSL error" alerts, for instance, when doing SSL shutdown of a long standing connection after rejecting another one by SNI. The fix is to move the qc->error check after c->ssl->handshake_rejected is handled first, to make the error queue cleared. Although not practicably visible as needed, this is accompanied by clearing the error queue under the qc->error case as well, to be on the safe side. As an implementation note, due to the way of handling invalid transport parameters for OpenSSL 3.5 and above, which leaves a passed pointer not advanced on error, SSL_get_error() may return either SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE depending on a library. To cope with that, both qc->error and c->ssl->handshake_rejected checks were moved out of "sslerr != SSL_ERROR_WANT_READ". Also, this reconstructs a missing "SSL_do_handshake() failed" diagnostics for the qc->error case, replacing using ngx_ssl_connection_error() with ngx_connection_error(). It is made this way to avoid logging at the crit log level because qc->error set is expected to have an empty error queue. Reported and tested by Vladimir Homutov.
2025-08-13Version bump.Sergey Kandaurov1-2/+2
2025-08-13Mail: logging upstream to the error log with "smtp_auth none;".Sergey Kandaurov1-6/+4
Previously, it was never logged because of missing login.
2025-08-13Mail: reset stale auth credentials with "smtp_auth none;".Sergey Kandaurov2-1/+7
They might be reused in a session if an SMTP client proceeded unauthenticated after previous invalid authentication attempts. This could confuse an authentication server when passing stale credentials along with "Auth-Method: none". The condition to send the "Auth-Salt" header is similarly refined.
2025-08-13Mail: improved error handling in plain/login/cram-md5 auth methods.Sergey Kandaurov1-16/+22
Previously, login and password storage could be left in inconsistent state in a session after decoding errors.
2025-08-11Auth basic: fixed file descriptor leak on memory allocation error.Sergey Kandaurov1-1/+2
Found by Coverity (CID 1662016).
2025-08-03SSL: support for compressed server certificates with OpenSSL.Sergey Kandaurov8-0/+89
The ssl_certificate_compression directive allows to send compressed server certificates. In OpenSSL, they are pre-compressed on startup. To simplify configuration, the SSL_OP_NO_TX_CERTIFICATE_COMPRESSION option is automatically cleared if certificates were pre-compressed. SSL_CTX_compress_certs() may return an error in legitimate cases, e.g., when none of compression algorithms is available or if the resulting compressed size is larger than the original one, thus it is silently ignored. Certificate compression is supported in Chrome with brotli only, in Safari with zlib only, and in Firefox with all listed algorithms. It is supported since Ubuntu 24.10, which has OpenSSL with enabled zlib and zstd support. The actual list of algorithms supported in OpenSSL depends on how the library was configured; it can be brotli, zlib, zstd as listed in RFC 8879.
2025-08-03SSL: disabled certificate compression by default with OpenSSL.Sergey Kandaurov1-0/+5
Certificate compression is supported since OpenSSL 3.2, it is enabled automatically as negotiated in a TLSv1.3 handshake. Using certificate compression and decompression in runtime may be suboptimal in terms of CPU and memory consumption in certain typical scenarios, hence it is disabled by default on both server and client sides. It can be enabled with ssl_conf_command and similar directives in upstream as appropriate, for example: ssl_conf_command Options RxCertificateCompression; ssl_conf_command Options TxCertificateCompression; Compressing server certificates requires additional support, this is addressed separately.
2025-08-03Updated ngx_http_process_multi_header_lines() comments.Sergey Kandaurov2-2/+2
Missed in fcf4331a0.
2025-08-03HTTP/3: improved invalid ":authority" error message.Sergey Kandaurov1-1/+1
2025-08-03Made ngx_http_process_request_header() static again.Sergey Kandaurov2-2/+2
The function contains mostly HTTP/1.x specific request processing, which has no use in other protocols. After the previous change in HTTP/2, it can now be hidden. This is an API change.