Security Docker 10 min read
NGINX2Root: How I Patched My Lab
On this page
On 18 November, Xint published NGINX2Root: five bugs in nginx that let someone run code on the server without logging in, plus a Linux kernel bug that turns that foothold into root on the host, even from inside a Docker container. nginx released fixed versions the same day.
nginx sits in front of almost everything in my lab, so the first question was simple: am I exposed? This post covers what I found, what I switched off in the first twenty minutes, how I checked that nobody had been in, and four things that surprised me along the way. One of them is a line in a popular Docker template that keeps HTTP/2 on after you’ve switched it off.
TL;DR
- Upgrade to nginx 1.30.7 (stable) or 1.31.9 (mainline), then restart it. A reload keeps the old binary, and old workers keep their open connections.
- Until then, turn HTTP/2 off. That closes the two bugs most setups have. Check your config for the other three: HTTP/3, the resolver with
mirror, and the mail proxy. - On nginx-proxy,
ENABLE_HTTP2=falseisn’t enough: its catch-all server still sayshttp2 on;. Test a connection that sends no server name, not just your own domain. - If nothing uses SCTP, block the
sctpkernel module. It’s the route from nginx to root, and there’s no kernel fix yet.
# What your nginx actually has on
nginx -v
nginx -T 2>/dev/null | grep -nE '\b(http2|http3|quic|resolver|mirror|auth_http)\b'
# From another machine: is HTTP/2 still offered anywhere?
curl -sI --http2 https://example.com/ | head -1
openssl s_client -connect 203.0.113.10:443 -noservername \
-alpn h2,http/1.1 </dev/null 2>/dev/null | grep -i alpn
# Keep the SCTP module from loading (this doesn't unload a loaded one)
lsmod | grep -w sctp
echo 'install sctp /bin/false' | sudo tee /etc/modprobe.d/disable-sctp.confWhat NGINX2Root is
#It’s five separate bugs. According to Xint, each one lets an attacker run code as the nginx worker process, with no login. That isn’t root, but it’s the process that handles every request and response passing through the server.
| CVE | Where | What it needs | Does turning HTTP/2 off help? |
|---|---|---|---|
| CVE-2026-123007 | HTTP/2 flow control | HTTP/2 on, in every release since 1.9.5 (2015) | Yes |
| CVE-2026-123633 | HTTP/2 connection draining | HTTP/2 on, requests proxied to a backend | Yes |
| CVE-2026-121810 | HTTP/3 (QUIC) connection draining | HTTP/3 on, requests proxied to a backend | No: turn HTTP/3 off |
| CVE-2026-123634 | DNS resolver | resolver, a proxy_pass target taken from the request, and subrequests such as mirror | No: use fixed upstreams |
| CVE-2026-113425 | Mail proxy | a mail block with proxy on and auth_http | No: keep it off the internet |
nginx’s advisories rate the HTTP/2 flow-control bug and the mail proxy bug “major” and the other three “medium”. The same release fixes five more bugs, so the switches below only buy time until the upgrade is in.
The second half is what gave it its name. Xint chained the nginx bugs with a use-after-free in the Linux kernel’s SCTP code, there since Linux 4.15 (2018). Many distributions install the sctp module, and the kernel loads it the first time any program opens an SCTP socket, so an nginx worker can reach it without special rights. Xint reports reliable root from a worker, and a root shell on the host with nginx running in a Docker container. Containers share the host’s kernel, so this is a host problem, not an image problem. As I write this, the kernel bug has no CVE and no patch.
Two more details matter. First, don’t count on ASLR: Xint describes how each exploit gets around it, and CIRCL’s TR-105 says not to close a finding just because ASLR or PIE is on. Second, Xint left out the final steps of its exploits and is holding back the kernel details until a patch exists. The Hacker News reports a public proof of concept whose own notes say it only works against a freshly started container on the same machine. No attacks have been reported so far.
What was exposed in my lab
#In my lab, nginx faces the internet in three places: two Docker reverse proxies built the nginx-proxy way (docker-gen writes the nginx config from the containers’ settings), and one web server managed by a hosting control panel. All three ran an affected 1.31 release with HTTP/2 on.
None of them uses HTTP/3, a proxy_pass target taken from the request, or the mail proxy, so three of the five bugs didn’t apply. That left the two HTTP/2 bugs, and one switch closes both. I checked this on each machine with nginx -T, which prints the full configuration nginx actually loaded, includes and all, not the files I remembered writing.
The upgrade is the real fix. Turning HTTP/2 off took minutes and could be undone in seconds, so it went first, together with a check that nobody had been in.
| Time (UTC, 18 Nov) | Step |
|---|---|
| 18:43 | Read the nginx and Xint advisories: the fixed releases were already out |
| 18:48 | Exposure checked: three nginx, all affected, only the HTTP/2 bugs apply |
| 18:51 | Decided: HTTP/2 off now, then look for signs of intrusion |
| 18:57 | Both Docker proxies serve HTTP/1.1 only, checked from outside |
| 19:00 | The panel-managed server too |
| 19:02 | The sctp module blocked on all three |
| 19:04 | Intrusion checks done: nothing found |
| 19:20 | Two old workers left over from an earlier reload ended (Surprise 2) |
Surprise 1: the off switch that left HTTP/2 on
#nginx-proxy has a switch for this, ENABLE_HTTP2=false, and it’s the advice given on the project’s issue about these CVEs. I set it and regenerated the config. My check wanted zero http2 on lines in the result. It found one.
That line is in the template’s catch-all server, the server_name _ block nginx-proxy writes when no site is set as the default. The block hard-codes http2 on; and ignores the switch (line 899 of nginx.tmpl as I write this). The catch-all answers requests for names you don’t host and TLS connections that send no name at all, which is exactly what a scanner sends. A curl test against your own domain passes and never touches this block.
My script rolled the change back automatically, without an outage. The fix that stuck was the same switch plus the image’s own template with that one line removed, mounted read-only over /app/nginx.tmpl. In the usual single-container setup that’s the nginx-proxy container; in the separate-containers layout it’s the docker-gen one.
# Take the template from the image you actually run
docker cp nginx-proxy:/app/nginx.tmpl ./nginx.tmpl.http2-off
# Find the catch-all and delete the unconditional "http2 on;" a few lines below it
grep -n -A5 'server_name _;' ./nginx.tmpl.http2-off
services:
nginx-proxy:
environment:
ENABLE_HTTP2: "false"
volumes:
- ./nginx.tmpl.http2-off:/app/nginx.tmpl:ro
Then test from another machine. Every site should answer over HTTP/1.1, the openssl test from the TL;DR, which sends no server name, must not get h2, and a name you don’t host should get nothing useful. Copy the template again after each image update, because the rest of it changes.
I’ve decided HTTP/2 and HTTP/3 stay off on my edge proxies for good. One of them runs an image with switches of its own for this, and it gets its own section below.
Surprise 2: a reload left old workers on HTTP/2
#A reload starts new workers with the new config. The old ones stop taking new connections, but they keep serving the ones they already hold until those close. On one proxy, two old workers were still there, marked “worker process is shutting down” and about 11 hours old, holding long-lived connections on the config from before the change. That config had HTTP/2 on.
I ended those two workers, and their clients reconnected to the new HTTP/1.1-only ones. Xint and CIRCL both say to restart rather than reload after the upgrade, and the same applies to the switch:
# Old workers still alive after a reload
ps -eo pid,etime,cmd | grep '[s]hutting down'
Surprise 3: the panel rewrites what you edit
#On the panel-managed server, http2 on; sits in the panel’s vhost templates. I changed it to http2 off; in its custom templates and its server-wide vhost file, then had the panel rewrite the configs. That restarted nginx once, for a few seconds: the only interruption all evening.
The catch is that the panel, and my own configuration management, regenerate those files. A hand edit gets silently undone on the next run. So the same change went into my infrastructure code a few minutes later, byte for byte. If you mitigate by hand on a managed machine, put the change where it survives the next run.
Surprise 4: my own check failed when it succeeded
#Every change ran in a script that checked the result and rolled back if the check failed. On the panel server, it rolled back a working change twice. The check counted the remaining http2 on lines with grep -c, in a script running with set -e -o pipefail. When there’s nothing to count, grep -c prints 0 and exits 1, so the success case looked like a failure.
set -euo pipefail
conf=$(nginx -T 2>/dev/null)
# Wrong: grep -c exits 1 when it counts 0, so set -e stops the script on success
n=$(grep -c 'http2 on' <<<"$conf")
# Right: a count that is allowed to be zero
n=$(grep -c 'http2 on' <<<"$conf" || true)
[ "$n" -eq 0 ] || { echo "HTTP/2 still on in $n places"; exit 1; }
The rollbacks did their job: each one restored the previous config cleanly, without an outage. If a check has to be wrong, that’s the direction to be wrong in. Still, run every check once against a case you know is fine.
Checking that nobody had been in
#Switching HTTP/2 off doesn’t tell you whether someone used the hole before you closed it. So on all three machines I looked back 14 days:
- no nginx worker crashes (
exited on signalin the error log) and no core dumps, because a failed exploit attempt usually crashes a worker; - no kernel warnings (segfaults, general protection faults,
BUG,KASAN), and thesctpmodule not loaded; - only nginx processes in the proxy containers, and
docker diffshowing no files beyond what the image writes when it starts; - no outbound connections from nginx to the internet, checked with
ssinside the container’s network namespace; - no executables in
/tmp,/var/tmpor/dev/shm; - only the expected SSH keys, no extra uid-0 accounts and nothing odd in crontabs;
- two weeks of file-integrity, web-shell and high-severity alerts from my security monitoring, each matched to a known change.
grep -E 'exited on signal|segfault' /var/log/nginx/error.log*
coredumpctl list nginx
journalctl -k --since "14 days ago" | grep -Ei 'segfault|general protection|BUG:|KASAN'
docker diff nginx-proxy
sudo nsenter -t "$(docker inspect -f '{{.State.Pid}}' nginx-proxy)" -n ss -tnp
find /tmp /var/tmp /dev/shm -type f -perm -u+x
I found nothing. One alert made me look twice: an unexpected wp-content/upgrade/index.php on a WordPress site. It came from WordPress’s own automatic core update an hour earlier, and the file was its “Silence is golden” placeholder. On a night like this, check it anyway. For the future, Xint suggests an auditd rule on execve for the nginx worker’s user, because a worker starting any program is the clearest sign of a successful attack.
Blocking the kernel half
#Nothing in my lab uses SCTP, and the module wasn’t loaded anywhere, so blocking it cost nothing:
lsmod | grep -w sctp # should print nothing
grep -w sctp "/lib/modules/$(uname -r)/modules.builtin" # built in? then this won't help
printf 'install sctp /bin/false\nblacklist sctp\n' | sudo tee /etc/modprobe.d/disable-sctp.conf
This only stops modprobe from loading it. It doesn’t unload a module that’s already loaded, and it doesn’t help if SCTP is built into your kernel. For containers, what counts is the host’s kernel, not the image.
edge-proxy: fixed, with real off switches
#One of my two proxies already runs edge-proxy, an open-source image the company I work for maintains. It’s nginx mainline with ModSecurity and the OWASP Core Rule Set in front of every site, built for nginx-proxy’s separate-containers layout.
It’s fixed since 0.1.2, which ships nginx 1.31.9 and its own switches that turn HTTP/2 and HTTP/3 off everywhere, the catch-all included. If you run nginx-proxy and would rather not patch its template by hand, it’s worth a look.
Its WAF doesn’t help with these bugs, though: flow control and connection draining happen in nginx’s HTTP/2 layer, before there’s a request for ModSecurity to inspect.
More is planned for 0.2.0. It’s still being designed, so the details may change:
- Its own configuration, written for current nginx, instead of nginx-proxy’s template and conventions. It’s a clean break: settings and labels get new names, so existing setups need a one-time change.
- Two ways to add a site, with the same generated configuration and the same protection either way: a small file per site, with no access to the Docker socket anywhere, or Docker labels on the site’s container for quick setups.
- TLS certificates from nginx’s own ACME support, with no separate companion container.
- Everything it has now stays: ModSecurity with the OWASP Core Rule Set in front of every site, hardened defaults where each protection is one documented switch, signed images with build provenance, and the switches that turn HTTP/2 and HTTP/3 off.
To follow it, watch the repository on GitHub.
What comes next
#The real fix is still the upgrade: fixed builds on every nginx, then a restart, so no worker keeps running the old code. Then the kernel update, once my distribution ships the SCTP fix, and a reboot. Distributions often backport fixes without changing what nginx -v prints, so compare the full package version with your vendor’s advisory, not the version string.
If you run nginx, here’s what I’d do tonight: find every place nginx answers the internet, read nginx -T instead of trusting memory or a switch, test from outside without a server name, look for old workers after the reload, and look back for crashes before you call it done.
Got it working, or hit a snag?
Share your setup, a fix or a question. Markdown and code blocks work.
Replying to
How comments and emails are handled: Privacy.