Back to the blog
NginxSecurityBunHTTP/2

Nginx RCE flaw: what changes if you use Bun

November 19, 2026·6 min read·Diego Horvatti

Your Bun API can be flawless and still go down because of the server sitting in front of it. Wiz published research on an RCE flaw in Nginx: remote code execution, no authentication, exploited through HTTP/2 handling. In other words, someone on the outside runs code on your machine with no login and no password, just by sending requests.

The technical details are in the original Wiz post. Read the CVEs and affected versions there, because that's what you'll compare against your server. Here I want to talk about the practical side: what this means for people who, like me, put Bun behind Nginx and forget it exists.

What happened with Nginx and HTTP/2

HTTP/2 is a binary protocol. It multiplexes many requests over a single connection, compresses headers and keeps state per connection. That makes everything faster. It also makes the parser a lot more complicated than HTTP/1.1's, which is basically text split by line breaks.

And a complicated parser written in C is where the trouble lives. A memory bug in a place like that (a buffer read past its limit, a pointer used after being freed) can turn into code execution if the attacker controls the right bytes. According to the Wiz research, that's what happened: the vulnerable surface is HTTP/2 handling, and the attacker needs no credentials at all.

There's a reason this is serious. Nginx is the front door for a huge slice of the web, close to a third of sites by public measurements. And it almost always runs directly exposed to the internet, because that's its job.

The reverse proxy is the only code of yours that everyone on the internet can touch.

Why this matters if you run Bun

The setup I see most often (and the one I use) is this:

internet → Nginx (443, TLS, HTTP/2) → Bun.serve (127.0.0.1:3000)

Nginx handles TLS, HTTP/2, gzip, static files and rate limiting. Bun only receives clean HTTP/1.1 on the local port. It's a good design and I still stand by it.

But there's a side effect we tend to forget. All the security "hardening" you put into your Bun code (Zod validation, auth middleware, parameterized Postgres queries) happens after Nginx. If the attacker can execute code in the Nginx process, they've already gotten past all of it. They're inside the machine, on the same local network as your API, possibly reading the same .env.

I've heard "but my Nginx is just a proxy, there's nothing in it". Yes, there is:

  • the TLS certificate and private key;
  • access to the internal network, including 127.0.0.1:3000 with no authentication at all;
  • often, the same user or the same container that holds the application's secrets.

The flaw isn't in Bun. But the damage lands on your app all the same.

How to tell if your Nginx is vulnerable

Step one: find out the version. Sounds obvious, but a lot of people don't know which Nginx runs in production because it came from the base image or from apt three years ago.

nginx -v
# or, inside the container
docker exec meu-proxy nginx -v

Compare the number with the affected versions Wiz lists. Then check whether HTTP/2 is on. It shows up in two ways, depending on the version:

# old syntax
listen 443 ssl http2;

# new syntax (Nginx 1.25.1+)
listen 443 ssl;
http2 on;

A grep does the job:

grep -rn "http2" /etc/nginx/

If you found http2 and the version is in the affected range, you're exposed. Not "maybe". Treat it as an incident.

One detail that catches a lot of people: the Nginx may not be just yours. An ingress controller in Kubernetes, a panel image like Coolify or similar, the built-in proxy of some deploy template. Plenty of things use Nginx under the hood without saying so. It's worth checking every layer.

What to do today, in order

The real fix is to update. Everything else is a bandage until the update lands.

1. Update Nginx. If you use the official image, change the tag and redeploy. Avoid the latest tag in production, but also don't stay stuck on a 2023 tag out of fear of change:

# before
FROM nginx:1.24-alpine

# after: the patched version listed in the advisory
FROM nginx:<patched-version>-alpine

If you install through the system package manager, check whether your distro's repository has already shipped the patch. LTS distros sometimes lag, and the official nginx.org repository usually comes out first.

2. If you can't update right now, turn off HTTP/2. Remove http2 from listen or switch to http2 off; and reload:

nginx -t && nginx -s reload

You lose a bit of performance on pages with lots of assets. A JSON API that answers one request at a time barely notices. It's a great trade for a few hours or days.

3. Limit what Nginx can reach. This step holds forever, not just for this flaw:

  • run the worker as an unprivileged user (the default nginx or www-data, never root);
  • don't mount the application's .env in the proxy container;
  • if Bun is in another container, put a simple token between the two or at least restrict the network.

4. Check the logs. Look for worker crashes (worker process exited on signal) in error.log over the last few days. Workers dying for no reason after weird HTTP/2 traffic is exactly the kind of signal you want to see before the attacker lands the exploit.

So should I expose Bun directly and drop Nginx?

That's the reaction I most expect to see on Twitter this week: "Bun.serve can handle it, take Nginx out of the way". I get the temptation. Bun supports native TLS, it's fast and the code gets smaller:

Bun.serve({
  port: 443,
  tls: {
    cert: Bun.file("/certs/fullchain.pem"),
    key: Bun.file("/certs/privkey.pem"),
  },
  fetch(req) {
    return new Response("ok");
  },
});

It works. But switching servers because of a CVE means trading a known, patched risk for an unknown one. Nginx has had decades of people attacking and auditing its parser. It just got a patch. Bun's HTTP server is good, but it's much newer and has faced far fewer hostile eyes. When a flaw shows up in it (and one will, it happens in all software), you'll be in this same situation again, only without the proxy between the world and your application process.

My opinion, and it's a strong one: update Nginx and keep the design. If you want fewer moving parts, switch to another mature proxy (Caddy, for example) calmly, in a planned sprint, not in a panic. Architecture chosen in a panic tends to last exactly until the next panic.

The lesson for developers

What bothers me about this case is how we think about security only in the code we write. We review PRs, run bun audit, pin versions in bun.lock. And the binary that receives 100% of external traffic stays on whatever version came in the image when the project was born.

Put the proxy in the same routine as your dependencies. Pin the version in the Dockerfile, let Renovate or Dependabot open a PR when a new tag comes out, and subscribe to the nginx.org security advisories. It takes ten minutes to set up and saves you a really bad Saturday night.

I already reviewed the stack of my projects early this morning. If you want to see how they're built, they're in my projects. And if your nginx -v showed a version you didn't even remember existed, don't worry: you're not alone. Just don't leave it for tomorrow.

LinkedIn summary

Your Bun code can be flawless and still go down because of the server sitting in front of it.

Wiz published an RCE flaw in Nginx, exploited through HTTP/2 and with no authentication. Anyone on the outside can run code on your machine just by sending requests.

If you run Nginx in front of Bun, remember that Zod, auth and parameterized queries only kick in after the proxy. If Nginx falls, the attacker is already inside the machine, with access to the local port and maybe your .env.

My advice: run nginx -v today, update, and if you can't do it right now, turn off HTTP/2 for the time being.

Also, don't change your architecture in a panic. Update Nginx, keep the design, and treat the proxy as a dependency: pinned version in the Dockerfile and Renovate opening PRs.

I already reviewed my projects early this morning. What about your nginx -v, any surprises?

#Nginx #Bun #CyberSecurity #DevOps #Backend