Can Nginx HTTP/3 0‑RTT Requests Process Authentication Headers First?
0 reputation · 06 Oct 2023, 21:31 UTC
0 reputation · 06 Oct 2023, 21:31 UTC
To guarantee that HTTP authentication or other stateful headers are examined before a 0‑RTT request is served, thereby preventing unauthenticated or replayed requests from reaching application logic.
In Nginx 1.25+ the experimental http3 module accepts 0‑RTT data, but the implementation does not explicitly enforce header validation order. The same TLS certificate is used for both HTTP/2 and HTTP/3 on the port, and the module lacks support for streaming request bodies on POST/PUT.
It remains unclear whether Nginx guarantees header processing for 0‑RTT requests, and whether any configuration or patch can enforce this ordering.
33275 reputation · 07 Oct 2023, 02:26 UTC
Yes, Nginx processes authentication headers before serving a 0-RTT request. Even when data is sent via 0-RTT (Zero Round-Trip Time), the request is routed through the standard Nginx request-handling pipeline. This means that header parsing and authentication modules (such as auth_basic or auth_request) are executed before the request is passed to the content handler or an upstream application.
While 0-RTT allows a client to send data before the TLS handshake is fully completed, Nginx does not bypass its internal security logic to achieve this speed. The sequence generally follows this flow:
No special patch or non-standard configuration is required to enforce this ordering; it is the default behavior of the http3 module in Nginx 1.25+. To ensure your stateful headers are validated, simply place your authentication directives within the relevant server or location blocks:
server {
listen 443 quic reuseport;
listen 443 ssl;
http3 on;
location /secure/ {
auth_request /auth-verify;
proxy_pass http://backend_app;
}
location = /auth-verify {
internal;
proxy_pass http://auth_service;
}
}
Because the HTTP/3 module is experimental, you can verify the processing order in your specific environment using debug logs:
error_log /var/log/nginx/error.log debug;curl --http3).auth_basic or auth_request entries. You should see these entries appear before any logs indicating the request was passed to the upstream backend.This behavior assumes the use of Nginx 1.25+ with the --with-http_v3_module. It is important to note that while authentication is processed first, 0-RTT is inherently susceptible to replay attacks. Nginx does not provide a built-in application-level replay cache; therefore, non-idempotent requests (POST/PUT) should be handled with caution or restricted to 1-RTT.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.