Micronaut WebSocket upgrade handling leaks request bodies, upgrades malformed requests and lets messages run before @OnOpen completes
Description
Upgrade requests that carry a body leak the buffered request bytes when answered with an ordinary response (404, filter rejection), when cancelled, on a successful 101 when the body arrived with the head, and on h2c listeners (fixed on 5.3.x and in 5.2.23 on the 5.2.x line). The upgrade path accepts HTTP/1.1 heads that failed to decode (duplicate Content-Length, invalid header name, oversized header block) where every other path answers 400/413 and closes, and a WebSocketServerHandshakeException escapes writeResponse, so a rejected handshake is never answered and later pipelined responses stall. @OnMessage can also run before an asynchronous @OnOpen has decided whether to reject the session, so an endpoint that authorises in @OnOpen processes messages from a session it would reject. The fix is to discard the request body on every upgrade outcome, reject decoder-failed heads, answer handshake failures, and gate message dispatch on the completion of @OnOpen.
Affected and patched versions
WebSocket upgrade and open/message handling predate 3.0.0. The 3.x fixes cover F43, F44 and W2AK41IC; applicability of F15 to 3.x has not been established.
| Package | Affected versions | Patched version |
|---|---|---|
io.micronaut:micronaut-http-server-netty | < 3.10.19 | 3.10.19 |
io.micronaut:micronaut-http-server-netty | >= 4.0.0, < 4.10.37 | 4.10.37 |
io.micronaut:micronaut-http-server-netty | >= 5.0.0, < 5.2.23 | 5.2.23 |
io.micronaut:micronaut-http-netty | < 3.10.19 | 3.10.19 |
io.micronaut:micronaut-http-netty | >= 4.0.0, < 4.10.37 | 4.10.37 |
io.micronaut:micronaut-http-netty | >= 5.0.0, < 5.2.23 | 5.2.23 |
The 3.x fix is in commit d9a8da384f, first included in stable release 3.10.19. The last affected stable 3.10.x release is 3.10.18.
Findings
- F15 (= ANT-2026-6RZI5GLK)
- F43
- F44 (= ANT-2026-XGRTNVS6)
- ANT-2026-W2AK41IC
Affected versions
- io.micronaut:micronaut-http-server-nettyfixed in 3.10.19
- io.micronaut:micronaut-http-server-nettyFrom 4.0.0 · fixed in 4.10.37
- io.micronaut:micronaut-http-server-nettyFrom 5.0.0 · fixed in 5.2.23
- io.micronaut:micronaut-http-nettyfixed in 3.10.19
- io.micronaut:micronaut-http-nettyFrom 4.0.0 · fixed in 4.10.37
- io.micronaut:micronaut-http-nettyFrom 5.0.0 · fixed in 5.2.23