NGINX 1.29.8 added the max_headers directive to stop a client from sending thousands of request header fields. It closed the main path of the “HTTP/2 Bomb” attack, tracked as CVE-2026-49975. But one header escapes the count: over HTTP/2 and HTTP/3, every cookie field is skipped. A single request can still carry more than 5,000 of them.
This article shows the code that skips them, what that allows, and the fix that ships in NGINX-MOD 1.30.8-85.
What max_headers Protects Against
HPACK (HTTP/2) and QPACK (HTTP/3) compress request headers. A header that the client has already sent once can be repeated with a single byte. The HTTP/2 Bomb abuses that: the client sends thousands of tiny header fields at one byte each, and the server spends far more memory tracking each field than the client spent sending it.
NGINX limits the decoded size of the headers with large_client_header_buffers (32 KB by default). That limit counts bytes of names and values, not fields, so many empty fields fit under it. The max_headers directive, added in NGINX 1.29.8, counts the fields themselves. Upstream defaults it to 1000. NGINX-MOD lowers the default to 100:
max_headers 100;
A request with more fields gets 400 Bad Request and an info-level log entry: client sent too many header lines.
The Gap: Cookie Fields Are Never Counted
HTTP/2 and HTTP/3 allow a client to split the Cookie header into one field per cookie (RFC 9113, section 8.2.3). Browsers do this, because each cookie then compresses on its own. NGINX collects these “crumbs” in a separate array and joins them into one Cookie header later.
Example: The Same Cookies Over HTTP/1.1 and HTTP/2
Say a visitor has three cookies for your site: a session, a theme and a language. Over HTTP/1.1, the browser sends them on one line:
GET / HTTP/1.1
Host: example.com
Cookie: session=abc123; theme=dark; lang=en
That is one header line, and max_headers counts it as one.
Over HTTP/2, the same browser may send each cookie as its own cookie field. Decoded, the request looks like this:
:method: GET
:path: /
:authority: example.com
cookie: session=abc123
cookie: theme=dark
cookie: lang=en
These are three separate fields, the “crumbs”. NGINX glues them back together with ; before your configuration or backend sees them, so $http_cookie is session=abc123; theme=dark; lang=en either way, and a PHP or proxied application receives the same single Cookie header as over HTTP/1.1.
The problem is the counting. Stock NGINX counts every normal field, such as user-agent or accept, against max_headers, but none of the three cookie lines. With three cookies that does not matter. It matters when the client sends this instead:
:method: GET
:path: /
:authority: example.com
cookie:
cookie:
cookie:
... the same empty field, 5,400 times in total
Every one of those lines is an empty cookie field, and NGINX keeps a record for each until it builds the joined header. HPACK makes them nearly free to send: the client sends cookie: once in full, the encoder stores it in its compression table, and every repeat is a single byte that points to that table entry. 5,400 cookie fields cost the client about 5.4 KB. Stock NGINX accepts the request with max_headers 100 in place, because it never counts a single one of them.
With NGINX-MOD 1.30.8-85, the 101st cookie field ends the request with 400 Bad Request, and the error log at info level shows:
client sent too many cookie fields while reading client request headers
The three-cookie browser request above passes unchanged, as does any request with up to 100 cookie fields.
Here is the field handler in src/http/v2/ngx_http_v2.c (NGINX 1.30.8):
if (header->name.len == cookie.len
&& ngx_memcmp(header->name.data, cookie.data, cookie.len) == 0)
{
if (ngx_http_v2_cookie(r, header) != NGX_OK) {
return ngx_http_v2_connection_error(h2c,
NGX_HTTP_V2_INTERNAL_ERROR);
}
} else {
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
if (r->headers_in.count++ >= cscf->max_headers) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"client sent too many header lines");
ngx_http_finalize_request(r, NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
goto error;
}
The max_headers check sits only in the else branch. A cookie field goes to ngx_http_v2_cookie(), which appends it to the array with no limit. HTTP/3 has the same structure in ngx_http_v3_process_header() in src/http/v3/ngx_http_v3_request.c.
So the only bound left for cookie fields is the 32 KB byte limit. An empty cookie field counts as 6 bytes there (the name cookie and no value), which allows about 5,400 of them per request. On the wire, each one after the first is a single byte.
Apache HTTP Server treated exactly this as part of CVE-2026-49975: its fix makes Cookie fields count against LimitRequestFields.
Measuring the Gap
We built stock NGINX 1.30.8 and NGINX-MOD 1.30.8-85, both with the max_headers default of 100, and sent each a single HTTP/2 request with N separate cookie fields. curl cannot do this, because it always joins cookies into one field, so the test uses a small HTTP/2 client that sends one request. The result is a status code per request, not a timing, so it does not depend on the machine or its load: the same test runs in the build of every NGINX-MOD package, on all 18 distribution and architecture targets.
| Cookie fields in one request | Stock NGINX 1.30.8 | NGINX-MOD 1.30.8-85 |
|---|---|---|
| 100 | 200 OK | 200 OK |
| 101 | 200 OK | 400 Bad Request |
| 1,000 | 200 OK | 400 Bad Request |
| 5,400 (5.4 KB on the wire) | 200 OK | 400 Bad Request |
| 5,500 | connection closed (header too large) | 400 Bad Request |
Stock NGINX accepts 54 times the field count that max_headers 100 is meant to allow, as long as the fields are cookies. Over HTTP/3 the results are the same: 101 cookie fields get 200 from stock NGINX and 400 from NGINX-MOD.
The Fix in NGINX-MOD
NGINX-MOD 1.30.8-85 counts cookie fields against max_headers too, over HTTP/2 and HTTP/3. Cookie fields get a budget of their own:
- Up to
max_headerscookie fields per request, separate from the other headers. A browser that sends 100 cookies and 20 other headers still passes with the default of 100. - Over the limit, the request is refused with 400, the same response as for too many header lines. The error log names the reason at info level:
client sent too many cookie fields while reading client request headers
- The limit follows
max_headers. If you raised it, the cookie budget rises with it:
server {
max_headers 200;
# up to 200 other header fields and up to 200 cookie fields
}
HTTP/1.1 is not affected: there the Cookie header is one line and already counts as one header.
Every dynamic module built for NGINX-MOD keeps working with this release without a rebuild.
Get the Fix
The fix ships in NGINX-MOD 1.30.8-85 for RHEL, CentOS, AlmaLinux, Rocky Linux, Fedora and Amazon Linux. You will not find it in stock NGINX.
Requires a Pro subscription or higher.If you already run NGINX-MOD, update it. The package replaces the running binary gracefully, so no restart is needed:
sudo dnf -y update nginx-mod
If you run the standard nginx package, enable the NGINX-MOD repository and swap the packages. Your configuration stays as it is:
sudo dnf -y install https://extras.getpagespeed.com/release-latest.rpm
sudo dnf config-manager --enable getpagespeed-extras-nginx-mod
sudo dnf -y swap nginx nginx-mod
sudo systemctl enable --now nginx
On CentOS 7, use yum and yum-config-manager --enable in place of dnf and dnf config-manager --enable.
Then confirm the release. It must be 85 or later:
rpm -q nginx-mod
rpm -q --changelog nginx-mod | head -n 8
The newest changelog entry starts with “HTTP/2 and HTTP/3: cookie fields now count against max_headers (CVE-2026-49975)”.
The update is also published as advisory GPSA-2026-0012, so you can apply security updates only:
sudo dnf -y update --advisory=GPSA-2026-0012
Performance Considerations
The limit only affects requests that exceed it. Requests under it are handled exactly as before.
Typical sites send a few dozen cookies at most, well under the default budget of 100. A site that sends more than 100 cookies with every request pays for it on every request. If you do need more, raise max_headers.
Troubleshooting
Clients get 400 and the log says client sent too many cookie fields. The client sent more cookie fields than max_headers allows. Check what sets so many cookies on the domain. If the traffic is legitimate, raise max_headers in the server block. Log at info level to see the message: error_log /var/log/nginx/error.log info;.
Requests still pass with hundreds of cookie fields. Check rpm -q nginx-mod: releases before 85 do not count cookie fields. Also check that max_headers is not set to a large value in the server block or in http.
Conclusion
Applying this fix once is the easy part. Keeping every host fixed as configs evolve and NGINX versions roll forward is where regressions creep back in. GetPageSpeed Amplify runs scheduled gixy scans across every host and ties findings to live NGINX runtime metrics. Drop-in compatible with the deprecated nginx-amplify-agent (EOL January 2026).
The max_headers directive is NGINX’s answer to the HTTP/2 Bomb, but in stock NGINX it never sees cookie fields. Over HTTP/2 and HTTP/3, one request can carry more than 5,000 of them in a few kilobytes.
NGINX-MOD 1.30.8-85 counts them, verified against stock NGINX over both protocols. Subscribe to the GetPageSpeed repository to get it, along with every other fix we ship ahead of upstream.
