-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The limit check that tested negative one\n\nNetty's HTTP/3 codec shipped with 4.2.0.Final and brought its own QPACK decoder, `io.netty.handler.codec.http3.QpackDecoder`. CVE-2026-48748 names that decoder. It holds a counter, `blockedStreamsCount`, tracking how many request streams are presently parked because their `Required Insert Count` is ahead of the dynamic table. It also holds a ceiling, `maxBlockedStreams`, the value the server promises its peer over the HTTP/3 settings stream.\n\nThe pre-patch gate, on line 483 of `QpackDecoder.java`:\n\n```java\nprivate boolean shouldWaitForDynamicTableUpdates(int requiredInsertCount) throws QpackException {\n if (requiredInsertCount > dynamicTable.insertCount()) {\n if (blockedStreamsCount == maxBlockedStreams - 1) {\n throw MAX_BLOCKED_STREAMS_EXCEEDED;\n }\n return true;\n }\n return false;\n}\n```\n\n`maxBlockedStreams` is plumbed from the operator's settings in `Http3ConnectionHandler.java`:\n\n```java\nint maxBlockedStreams = toIntExact(localSettings\n .settings()\n .getOrDefault(\n Http3SettingIdentifier.HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS.id(),\n 0L)\n);\nqpackDecoder = new QpackDecoder(maxTableCapacity, maxBlockedStreams);\n```\n\nThe default is `0L`. Any operator who sets `HTTP3_SETTINGS_QPACK_MAX_TABLE_CAPACITY` to a non-zero value, to enable dynamic-table compression in the first place, and who does not explicitly set `HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS`, ships a decoder built with `maxBlockedStreams = 0`.\n\nAt `maxBlockedStreams = 0`, the comparand is `0 - 1 == -1`. `blockedStreamsCount` is a non-negative `int` that starts at zero and is only incremented in this function path. It never equals `-1`. Every blocking header block returns `true` from `shouldWaitForDynamicTableUpdates`, walks past the throw, and is recorded in the per-decoder state:\n\n```java\nif (shouldWaitForDynamicTableUpdates(requiredInsertCount)) {\n blockedStreamsCount++;\n blockedStreams.computeIfAbsent(requiredInsertCount, __ -> new ArrayList<>(2)).add(whenDecoded);\n```\n\nThe promise the decoder made on the wire was zero blocked streams. The check that was supposed to enforce that promise tested for a counter value the counter cannot hold.\n\n## The counter that only went up\n\nThe other half of CVE-2026-48748 is the bookkeeping that was supposed to keep the counter honest. When the encoder eventually inserts a dynamic-table entry that unblocks a parked stream, `sendInsertCountIncrementIfRequired` runs the pending resumption callbacks. The pre-patch version reads them from the map:\n\n```java\nprivate void sendInsertCountIncrementIfRequired(QuicStreamChannel qpackDecoderStream) throws QpackException {\n final int insertCount = dynamicTable.insertCount();\n final List runnables = this.blockedStreams.get(insertCount);\n if (runnables != null) {\n boolean failed = false;\n for (Runnable runnable : runnables) {\n try {\n runnable.run();\n } catch (Exception e) {\n failed = true;\n logger.error(\"Failed to resume a blocked stream {}.\", runnable, e);\n }\n }\n ...\n }\n ...\n}\n```\n\n`blockedStreams.get(insertCount)` reads the list. The runnables fire. The map entry stays. `blockedStreamsCount` is not decremented. The counter only goes up.\n\nBoth errors compose with the comparand. For the operator who explicitly set `HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS = 100`, the check fires when the counter equals `99`. The counter never decrements. After 99 lifetime blocked decodes on the connection, the next blocking header block throws `QPACK - exceeded max blocked streams`, which the codec catches in `Http3FrameCodec.decodeHeaders` and translates to `QPACK_DECOMPRESSION_FAILED`, a connection-level error. The operator who configured an explicit limit got a self-DoS by ordinary traffic; the connection dies when the lifetime count of blocking decodes hits 99, not when the concurrent count does.\n\nFor the operator who left the default, the check never fires at all. Each blocked decode appends another entry to `blockedStreams.computeIfAbsent(requiredInsertCount, __ -> new ArrayList<>(2)).add(whenDecoded)`, holding a reference to the per-stream `ReadResumptionListener` passed in as `whenDecoded`. The map only grows. The JVM heap fills. One QUIC connection, opened by an unauthenticated peer, exhausts the server.\n\n## The two-character fix\n\nCommit `75127ca` by Violeta Georgieva, \"Merge commit from fork,\" landed June 1, 2026, in Netty 4.2.15.Final. The first hunk:\n\n```diff\n private boolean shouldWaitForDynamicTableUpdates(int requiredInsertCount) throws QpackException {\n if (requiredInsertCount > dynamicTable.insertCount()) {\n- if (blockedStreamsCount == maxBlockedStreams - 1) {\n+ if (blockedStreamsCount >= maxBlockedStreams) {\n throw MAX_BLOCKED_STREAMS_EXCEEDED;\n }\n return true;\n }\n```\n\nThe arithmetic change is decorative; the operator change is the bug. `==` was a stand-in for `>=`, on a counter that does not always pass through every integer in order. The new check throws when `blockedStreamsCount >= maxBlockedStreams`. At `maxBlockedStreams = 0`, that is the first blocked decode, which is what RFC 9204 § 2.1.2 required all along.\n\nThe second hunk:\n\n```diff\n private void sendInsertCountIncrementIfRequired(QuicStreamChannel qpackDecoderStream) throws QpackException {\n final int insertCount = dynamicTable.insertCount();\n- final List runnables = this.blockedStreams.get(insertCount);\n+ final List runnables = this.blockedStreams.remove(insertCount);\n if (runnables != null) {\n+ blockedStreamsCount -= runnables.size();\n boolean failed = false;\n for (Runnable runnable : runnables) {\n```\n\n`.get()` becomes `.remove()`. The counter is decremented by the size of the resumed list. The map entry is freed. The bookkeeping the original code never did finally happens.\n\n## The encoder made the same off-by-one, in the other direction\n\nThe same file, the same compilation unit, the same hand: `QpackEncoder.mayNotBlockStream`, on line 516:\n\n```java\nprivate boolean mayNotBlockStream() {\n return blockedStreams >= maxBlockedStreams - 1;\n}\n```\n\nThe shape is identical to the decoder's check. `count == max - 1` versus `count >= max - 1`. Both substitute `max - 1` for `max`. The decoder used `==`, which fires at exactly one value of the counter and fails open at every other value, including the unreachable `-1` at the default. The encoder used `>=`, which fires for any counter at or above `max - 1`. At `maxBlockedStreams = 0`, the encoder's check is `blockedStreams >= -1`, which holds for every non-negative counter, that is, always. The encoder's bug fails closed: it conservatively refuses to insert table references that would cause the peer to block, leaking only compression efficiency. The decoder's bug failed open: it accepted blocking forever, and leaked the heap.\n\nTwo implementations of the same arithmetic mistake in two halves of one codec, by the same author, picking opposite default behaviors at the boundary. The encoder's mistake never had a CVE because failing closed is not a vulnerability. This is the [`limit-check-as-equality`](/patterns/limit-check-as-equality) shape: a bounded counter compared by `==` against a single target value, where any deviation in the target's computation, or any path that steps the counter past the target without firing the check, bypasses enforcement.\n\n## The suite tested the decoder with `maxBlockedStreams = 0` and never tried to block a stream\n\nPre-patch `QpackDecoderTest.java`, in the shared `setup` helper used by every parameterized test:\n\n```java\ndecoder = new QpackDecoder(maxTableCapacity, 0, table, ackEachInsert());\n```\n\nEvery test in the suite constructed the decoder with `maxBlockedStreams = 0`, the exact value at which the limit check is dead. No test in the suite called `decoder.decode(...)` with a `Required Insert Count` that exceeded the dynamic table's `insertCount()`, the precondition that drives the gate in `shouldWaitForDynamicTableUpdates`. The path with the bug had zero test coverage. The constant `0` was hardcoded in the suite that should have exercised the value at which the constant `0` made the check unreachable.\n\nThe patch's same commit adds three new tests in `QpackDecoderTest.java`:\n\n- `zeroMaxBlockedStreamsThrowsOnBlockedStream`, which asserts that at `maxBlockedStreams = 0` a blocking decode throws `QpackException`. Pre-patch, this test would have returned `false` because the throw never fired.\n- `maxBlockedStreamsLimitEnforced`, which asserts the limit fires when the counter reaches `maxBlockedStreams`, not at `maxBlockedStreams - 1`.\n- `blockedStreamsCountReleasedAfterUnblocking`, which asserts the counter decrements when streams resume, the property the `.get()` instead of `.remove()` formulation never had.\n\nThe tests are the disclosure. Each is the smallest input that distinguishes the patched code from the unpatched code. A reader of the diff in isolation gets the same information as a reader of the advisory text.\n\n## The spec default was the connection error\n\nRFC 9204, Section 2.1.2: \"If the decoder encounters more blocked streams than it promised to support, it MUST treat this as a connection error of type QPACK_DECOMPRESSION_FAILED.\"\n\nRead carefully. Zero is not a permissive default. Zero is a promise that no streams may block. The first blocking decode is the one that exceeds the promise. The MUST is unambiguous.\n\nThe Netty decoder's reading of the same zero was the inverse. `count == -1` at the default of `maxBlockedStreams = 0` is dead code. A reader of the source could have pulled up RFC 9204 § 2.1.2 and `QpackDecoder.shouldWaitForDynamicTableUpdates` side by side any time after 4.2.0.Final shipped and observed that the implementation enforced the opposite of what the RFC required at the most common configuration. The CVE-2026-48748 record was not assigned until June 5, 2026, when Violeta Georgieva reported it through the security disclosure process and shipped the fix the same week.\n\nThe advisory's mechanism description ends: \"Attackers exploiting this can send headers referencing unavailable table entries, forcing streams into indefinite blocking states while the server accumulates `ReadResumptionListener` objects indefinitely, exhausting heap memory.\" That is correct, and it is not the part nobody else will say. The part nobody else will say is that the broken check was symmetric across the codec. The encoder picked the safe direction by accident. The decoder picked the unsafe one. Both used `max - 1` where the spec used `max`, both shipped in 4.2.0.Final, both went through the same review, and only one was the CVE.\n\nPoC: [GHSA-4grm-h2qv-h6w6](https://github.com/advisories/GHSA-4grm-h2qv-h6w6)","closing_line":"The check that bricked the connection at the explicit `max` was the check that did nothing at the default; the spec's strictest configuration was the one the implementation refused to enforce.","hook_md":"Netty's HTTP/3 decoder enforces the QPACK blocked-streams ceiling with `if (blockedStreamsCount == maxBlockedStreams - 1) throw MAX_BLOCKED_STREAMS_EXCEEDED`, inside `QpackDecoder.shouldWaitForDynamicTableUpdates`. `maxBlockedStreams` is a signed `int` set from the operator's `HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS` value, defaulting to zero when not configured. `blockedStreamsCount` is a non-negative counter that starts at zero and is only incremented in the vulnerable code. At the default, the check tests for `blockedStreamsCount == -1`, which never holds. RFC 9204 § 2.1.2 reads: \"If the decoder encounters more blocked streams than it promised to support, it MUST treat this as a connection error of type QPACK_DECOMPRESSION_FAILED.\" The decoder that promised zero produced no error at all.","post_id":647,"slug":"netty-cve-2026-48748-qpack-blocked-streams-tested-against-minus-one","title":"CVE-2026-48748: Netty's QPACK Blocked-Streams Limit Tests `count == max - 1`. At The Spec Default Of `max = 0`, That's `count == -1`.","type":"initial","unreadable_sentence":"At `max = 0`, the spec required a connection error on the first blocking decode. The implementation's `count == -1` required nothing of anyone."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCauovtwAKCRDeZjl4jgkQ Jh19AQDAcHHEsjwVEXzEbrpm9tpCpPJ2EEZI3rQSORqo3ZIefQEAgOS8GA0Ps3VN Omi4T9UOI+LLS/Qx04QDV1xHg3BHjg0= =0VW4 -----END PGP SIGNATURE-----