r/Ubuntu • • Nov 04 '26

Possible HAProxy regression after Ubuntu 22.04 security update? 502s with Next.js chunked responses

Hey everyone,

I ran into an interesting HAProxy issue today and wanted to check if anyone else has seen the same thing.

Everything was working fine yesterday. Today, requests to a Next.js backend through HAProxy suddenly started returning:

502 Bad Gateway
The server returned an invalid or incomplete response.

HAProxy logs showed:

502 ... PH--

At first I suspected the backend, but hitting the Next.js service directly worked perfectly. The backend returned HTTP/1.1 200 OK with Content-Encoding: gzip and Transfer-Encoding: chunked.

TCP connectivity was fine, the Host header was fine, and curl could consume the response without any issue when connecting directly to the backend.

The interesting part came when I checked HAProxy's runtime errors with:

echo "show errors" | socat stdio /var/run/haproxy.stat

HAProxy reported:

invalid response
H1 msg state MSG_CHUNK_SIZE(26)
H1 chunk len 0 bytes
H1 body len 0 bytes

So HAProxy appeared to be failing while processing the HTTP/1.1 chunked response.

I tested several things, including Connection: close, different Accept-Encoding values, and HAProxy server-side keep-alive behavior. Direct requests continued to work, while requests through HAProxy returned 502.

Then I checked what had changed since yesterday.

HAProxy had been upgraded from:

2.4.30-0ubuntu0.22.04.2

to:

2.4.30-0ubuntu0.22.04.3

This got my attention because Ubuntu published USN-8972-1: HAProxy vulnerabilities on November 3, 2026. The fixed HAProxy version listed for Ubuntu 22.04 is exactly 2.4.30-0ubuntu0.22.04.3, and one of the included fixes, CVE-2026-110354, concerns handling of certain HTTP/1.1 chunked requests. [ubuntu.com]

There was another interesting observation.

Later, the Next.js application returned a cached response using:

Content-Length: 5784

instead of:

Transfer-Encoding: chunked

and HAProxy immediately returned HTTP/1.1 200 OK again.

So the sequence looks like this:

Working yesterday
→ HAProxy .2 upgraded to .3
→ Next.js sends chunked response
→ HAProxy returns 502 PH--
→ show errors reports MSG_CHUNK_SIZE
→ Next.js later sends Content-Length response
→ HAProxy returns 200 OK

I'm not claiming this proves there's a regression in the Ubuntu security update. The new version may simply be stricter and exposing an unusual or invalid edge case in the response generated by Next.js/Node.js.

But considering the timing of the update, the HTTP/1.1 chunk-related security fix, and the MSG_CHUNK_SIZE error, I thought it was worth sharing.

Has anyone else running Ubuntu 22.04 with HAProxy 2.4.30-0ubuntu0.22.04.3 seen similar behavior with Node.js or Next.js backends?

I'd be particularly interested if anyone has compared .2 vs .3 with HTTP/1.1 chunked responses.

15 Upvotes

8 comments sorted by

4

u/cybes539 Nov 04 '26

I’m experiencing the same issue, with multiple backends suddenly returning 502 errors after the security update (also on 22.04).

Edit: I’m still in the middle of debugging, so I’m not much help at the moment.

2

u/South_Echidna_970 Nov 04 '26 edited Nov 04 '26

What worked for me is to downgrade to 22.04.2. # apt install haproxy=2.4.30-0ubuntu0.22.04.2 and then hold the version, so it wont update again( until this is resolved with a new version). # apt-mark hold haproxy. This has nothing to do with Next.js, also some php backends failed too, so it's generic, not related with a certain technology/software.

1

u/KindElk9303 Nov 04 '26

good to know its not just an isolated thing with OPs setup then.

2

u/otigraoken Nov 05 '26

This hit us hard this morning.  It took us a couple of hours to figure out the unattended update pulled in the new haproxy package.  It was not a fun morning.

2

u/aykuth Nov 05 '26

Huge thanks for sharing. Fixed production environment based on your info.

2

u/HorrorCompote7573 Nov 05 '26

you saved my life, thanks for sharing

1

u/Goldman7911 Nov 04 '26

I don't know if it is related. When I was working in a Java integration with FortiManager I got a issue with Transfer-Encoding: chunked because it can't handle that so I had to pass the whole body. So not sending chunked fixed to me (wasn't necessary) . Could you test it? Prob that is not a fix but can point to the correct path.

\``JsonNode response =`

restClient

.post()

.uri("/jsonrpc")

.contentType(MediaType.APPLICATION_JSON)

// Avoid Transfer-Encoding: chunked

.body(mapper.writeValueAsString(rpcBody))

.retrieve()
\``