Nginx 1.31.9 Closes Five CVEs, Including One That Chains to Host Root
Background
Today Nginx has new vulnerabilities again. The blog post from the Xint team reveals 5 new Nginx vulnerabilities, and one of them can be combined with a Linux kernel vulnerability to gain root access on the host machine. The original title is: nginx2root is a collection of 5 critical CVEs, the most impactful of which allows an unauthenticated attacker to execute commands on an affected nginx server with HTTP/2 enabled. (Link: https://xint.io/blog/nginx2root-remote-code-execution). Nginx also published its latest changelog: https://nginx.org/
This affects quite a lot of versions. The most thorough solution is to upgrade to the latest Nginx 1.31.9 (mainline) or 1.30.7 (stable). If you can't upgrade immediately, at least disable HTTP/2. But note: disabling HTTP/2 only blocks CVE-2026-123007 and CVE-2026-123633; the other three vulnerabilities (resolver UAF, HTTP/3 UAF, mail proxy UAF) may still be triggered. If your environment enables resolver, HTTP/3, or mail proxy, disabling HTTP/2 alone is not enough; upgrade as soon as possible.
Alright, that's the background. Following the advice, let's just upgrade Nginx.
Upgrade Steps
Note: The upgrade steps here replace the Nginx binary directly, which may not apply to all environments. It's for reference only.
Prepare the installation package
First, download the latest Nginx package from the official website: https://nginx.org/en/download.html
After downloading, transfer it to the server using any method your environment allows.
scp .\nginx-1.31.9.tar.gz [email protected]:/home/tony/tools
Backup
Before starting the upgrade, back up the current software environment.
# Record current version, compile parameters, and binary fingerprint
nginx -v
nginx -V 2>&1 | tee /tmp/nginx-V.before.txt
md5sum "$(command -v nginx)"
# Backup the binary, naming the file with the current version
OLD_VER=$(nginx -v 2>&1 | awk -F/ '{print $2}')
sudo cp -a "$(command -v nginx)" "/usr/local/nginx/sbin/nginx-${OLD_VER}.bak"
Note: This depends on your Nginx installation. This is a simple test environment with few modules. If you use advanced features or many third-party modules, the backup process may need to be more complex. The output of
nginx -Vmust be saved; it's used later to matchconfigurearguments.
Compile the new package
Extract
After the backup, extract the uploaded tarball to an appropriate location.
tar -zxvf nginx-1.31.9.tar.gz
Compile
Then compile the new software. The parameters after configure must match the configure arguments from the nginx -V output checked earlier (adjustments are possible if this isn't a pure upgrade).
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module \
--with-openssl=/usr/local/src/openssl-1.1.1w
About the OpenSSL parameter: the sample includes
--with-openssl=/usr/local/src/openssl-1.1.1w. This parameter is only needed if the original nginx-Voutput actually included--with-openssl. If the original environment didn't statically compile OpenSSL, adding it will change the binary's behavior and dependencies. Rely on/tmp/nginx-V.before.txt; don't blindly copy it.
A Configuration summary appears when this step succeeds.
Then compile:
make -j"$(nproc)"
This step may briefly spike CPU usage. Compile time depends on the environment, but usually finishes within 3 minutes. The appearance of objs/nginx at the end without error output means it's OK.
Replace the output
This step only replaces the binary; don't run make install (to avoid touching conf/, html/, logs/, etc.).
sudo install -m 755 objs/nginx /usr/local/nginx/sbin/nginx
After that, check the configuration is OK, then restart. Note that you can't use reload; a true restart is required.
nginx -t
sudo nginx -s stop
# If managed by systemd, you can run: sudo systemctl restart nginx
# Wait a moment, then start manually
sudo /usr/local/nginx/sbin/nginx
Verification
After the steps, run some checks to confirm the upgrade is complete.
/usr/local/nginx/sbin/nginx -v # 1.31.9
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1/
Rollback
If the new version malfunctions, restore the backed-up old binary and restart:
sudo install -m 755 "/usr/local/nginx/sbin/nginx-${OLD_VER}.bak" /usr/local/nginx/sbin/nginx
sudo nginx -t
sudo nginx -s stop && nginx # or sudo systemctl restart nginx
{OLD_VER}in the rollback command comes from the backup step; make sure you run it in the same shell session. If you switch sessions, re-runOLD_VER=$(nginx -v 2>&1 | awk -F/ '{print $2}')or hardcode the backup filename.
Conclusion
And one last reminder:
- The version numbers, CVE IDs, and mitigation suggestions in this post should be cross-checked against the official nginx or F5 advisories to confirm that 1.31.9 really covers all 5 vulnerabilities.
- If nginx is invoked through a symlink,
command -v nginxreturns the link path, andmd5sumactually checks the target file. Make sure you back up the real binary. The example is for reference only. - Before upgrading in production, run the full process in a test environment and confirm that third-party modules (if any) are compatible with the new version.
As the most widely deployed web server in the world, Nginx will keep exposing new vulnerabilities from time to time in this AI-heavy era, and the frequency may be high in the short term. Things should stabilize later, but for now we have to adapt to the times. That's about it.