CVE
CVE-2026-85091, CVE-2026-4738
CWE
CWE-787, CWE-125, CWE-415, CWE-22, CWE-843, CWE-908
Affected Surface
- C / C++ library `zlib` (`madler/zlib`) versions `<= 1.3.2` (fixed in `1.4`, released 4-5 November 2026), including `1.3.1` through `1.3.2` for `CVE-2026-85091` (`TOB-ZLIB-003`) and `THM-ZLIB-001`
- Bundled `contrib/minizip` and `miniunz` in `zlib <= 1.3.2` (`block_central_name()` double free, `zipAlreadyThere()` NULL dereference, Zip64 extra-field out-of-bounds read, and `miniunz` directory/Windows path traversal)
- CPython (`python/cpython`) versions `<= 3.14.x` (`Objects/genericaliasobject.c` `_Py_subs_parameters()`, fixed on `main` / `3.15` in commit `3c9c477f508a` / PR `#155761`, not backported by upstream to `3.12`, `3.13`, or `3.14`)
- AI/ML inference servers and Python template sandboxes (including vLLM and Hugging Face `chat_template.jinja` evaluators using Jinja2 `SandboxedEnvironment` or `ImmutableSandboxedEnvironment`) that render untrusted model templates on CPython
TL;DR
On 4 and 5 November 2026, two foundational C runtime disclosures landed on oss-security:
zlib 1.4(CVE-2026-85091,THM-ZLIB-001, and Trail of BitsTOB-ZLIB-003throughTOB-ZLIB-014): Mark Adler releasedzlib 1.4(oss-security 2026/11/05/10), fixing 13 security flaws across corelibzandcontrib/minizip:CVE-2026-85091(TOB-ZLIB-003, CVSS 7.4 High): Whengz_write()wrote to a non-blocking file descriptor that stalled (EAGAIN/EWOULDBLOCK) on the direct caller-buffer path, it returned early without resettingstate->strm.avail_inandstate->strm.next_in, leavingnext_inpointing into the caller’s external buffer. A subsequentgzprintf()orgzvprintf()call invokedgz_vacate(), which computedmemmove()using the stale external pointer and overflowedstate->in.- Theorem
THM-ZLIB-001(8 MB out-of-bounds heap write ininflateGetDictionary()): Inzlib 1.3.1and1.3.2,inflate()overwrotestate->wbitswith the zlib header’s window sizelen(BITS(4) + 8, up to 23) before checkinglen > 15. If the caller then calledinflateReset()orinflateSync(),state->wbitsstayed up to23(1U << 23= 8 MiB), and a laterinflateGetDictionary()copied up to 8 MiB into the caller’s 32 KiB buffer. - Trail of Bits
TOB-ZLIB-004,TOB-ZLIB-008,TOB-ZLIB-009,TOB-ZLIB-013,TOB-ZLIB-014, plus uninitialized memory disclosures andminizipflaws:inflateSync()before a header was seen allocated a 1-byte window that a reused stream could overrun (TOB-ZLIB-004); repeateddeflatePrime()calls overflowedpending_buf(TOB-ZLIB-013);inflatePrime()leftnext_inpointing before the start of the input buffer (TOB-ZLIB-014);inflateBack(),deflateResetKeep(), and forwardgzseek()leaked uninitialized heap or out-of-window memory; andcontrib/minizipfixed a double free inblock_central_name(), a NULL dereference inzipAlreadyThere(), Zip64 extra-field over-reads, and directory/Windows path traversal inminiunz.
- CPython
types.GenericAlias_Py_subs_parameters()out-of-bounds read and Jinja2 / vLLM sandbox escape (gh-155752/python/cpython#155761): Disclosed by Darius Houle of RunSybil on 3 November 2026 and posted tooss-security 2026/11/05/11, CPython’s_Py_subs_parameters()inObjects/genericaliasobject.ccaches a generic alias’s parameters tuple (__parameters__) before invoking__typing_prepare_subst__hooks during type subscription (alias[...]). If a preparation callback attaches__typing_subst__to an argument that did not have it when__parameters__was cached,tuple_index(parameters, nparams, arg)returns-1. Becauseassert(iparam >= 0)is compiled out in release builds, CPython executesPyObject_CallOneArg(subst, argitems[-1]), passing the 8-byte word immediately before the tuple’s element array as a livePyObject *argument to the callback. On CPython>= 3.14, that word is the tuple’s cached hash (ob_hash), letting a crafted Jinja2 template choose two integers whose tuple hash equals a leaked address (from''.maketrans), forge references tostr,type,code, andfunction, and escapeImmutableSandboxedEnvironmentinside a Hugging Facechat_template.jinjaloaded by vLLM or BYOM inference services. Because neither CPython nor Jinja2 considers Python-level sandboxing a supported security boundary, upstream mergedpython/cpython#155761onmain(3.15) without backporting it to3.12,3.13, or3.14.
What to do now: Upgrade native and bundled copies of zlib and minizip to 1.4. If you operate vLLM, TGI, or custom LLM serving pipelines that render model-supplied chat_template.jinja files, do not rely on Jinja2’s SandboxedEnvironment or ImmutableSandboxedEnvironment as a host isolation boundary: apply patch python/cpython#155761 to your Python runtime or isolate untrusted model rendering inside an unprivileged container/microVM without host credentials.
Affected packages and components
| Ecosystem | Package / Component | CVE / Identifier | Severity | Affected versions | Fixed / Safe version | Vulnerable location |
|---|---|---|---|---|---|---|
| C / C++ | zlib (libz) | CVE-2026-85091 (TOB-ZLIB-003) | CVSS 7.4 High | 1.3.1.2 through 1.3.2 | 1.4 (commit df84af25dc19) | gz_write() and gz_vacate() in gzwrite.c |
| C / C++ | zlib (libz) | THM-ZLIB-001, TOB-ZLIB-004, TOB-ZLIB-014 | High | 1.3.1 through 1.3.2 (THM-ZLIB-001); <= 1.3.2 (TOB-ZLIB-004, 014) | 1.4 (commits 2fd31f00740e, 8179479c6274, e7bb9788e0f0) | inflate(), inflateSync(), inflateGetDictionary(), and inflatePrime() in inflate.c |
| C / C++ | zlib (libz) | TOB-ZLIB-013, TOB-ZLIB-008, TOB-ZLIB-009, e9415f70eb6a, 1e4178b27f45 | Medium / High | <= 1.3.2 | 1.4 (commits 12d7b9098091, 2ec717a141cb, e9415f70eb6a, 1e4178b27f45) | deflatePrime() and deflateResetKeep() in deflate.c, gzdopen() in gzlib.c, gz_zero() in gzwrite.c |
| C / C++ | zlib (contrib/minizip) | 2804ba757385, 6201bd6046fc, 4c94e39fc370, fd54d99ea361 | High | <= 1.3.2 | 1.4 | block_central_name() and zipAlreadyThere() in contrib/minizip/zip.c, unzip.c, and miniunz.c |
| Python / C | cpython (python3) | gh-155752 (PR #155761) | High / Critical (in sandboxed AI/template hosts) | <= 3.14.x (exploited via tuple ob_hash on 3.14.x) | Patched on main (3c9c477f508a); not backported to 3.12-3.14 | _Py_subs_parameters() in Objects/genericaliasobject.c |
Technical analysis
1. zlib 1.4: CVE-2026-85091 (gz_write stale pointer) and THM-ZLIB-001 (inflateGetDictionary 8 MB OOB write)
In gzwrite.c, when gz_write() is given a buffer at least as large as state->size, it compresses directly from the caller’s buf (state->strm.next_in = (z_const Bytef *)buf) instead of copying through state->in. If the underlying file descriptor is non-blocking and gz_comp() stalls with EAGAIN / EWOULDBLOCK (ret == -1), gz_write() in zlib 1.3.1.2 through 1.3.2 returned early while leaving state->strm.avail_in non-zero and state->strm.next_in pointing into the caller’s external buffer. If the caller next invoked gzprintf() or gzvprintf(), gz_vacate() assumed state->strm.next_in pointed inside state->in and called memmove(state->in, state->strm.next_in, state->strm.avail_in), overflowing state->in. Commit df84af25dc19 clears both fields before returning on a non-blocking stall, and commit 2fd31f00740e fixes the THM-ZLIB-001 window-size ordering bug in inflate.c:
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -242,8 +242,11 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
n -= state->strm.avail_in;
state->x.pos += n;
len -= n;
- if (ret == -1)
+ if (ret == -1) {
+ state->strm.avail_in = 0;
+ state->strm.next_in = state->in;
return state->again ? put - len : 0;
+ }
} while (len);
}
--- a/inflate.c
+++ b/inflate.c
@@ -545,13 +545,13 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
}
DROPBITS(4);
len = BITS(4) + 8;
- if (state->wbits == 0)
- state->wbits = len;
- if (len > 15 || len > state->wbits) {
+ if (len > 15 || (state->wbits != 0 && len > state->wbits)) {
strm->msg = (z_const char *)"invalid window size";
state->mode = BAD;
break;
}
+ if (state->wbits == 0)
+ state->wbits = len;
In inflate.c, when a stream was initialized with windowBits = 0 (telling inflate() to read the window size from the zlib header), a crafted 2-byte header with a 4-bit window field > 7 set len = BITS(4) + 8 (up to 23) and assigned state->wbits = len before rejecting len > 15. Calling inflateReset() or inflateSync() preserved state->wbits = 23, allowing updatewindow() to allocate an 8 MiB sliding window and inflateGetDictionary() to write up to 8 MiB past a caller’s standard 32 KiB dictionary buffer.
2. CPython types.GenericAlias (gh-155752 / PR #155761): turning argitems[-1] into a PyObject *
When Python evaluates a generic alias subscription such as dict[first, second, late][arg_tuple], _Py_subs_parameters() in Objects/genericaliasobject.c first caches the parameter tuple (parameters = self->parameters) and runs each parameter’s __typing_prepare_subst__ hook. It then loops over the alias’s args and checks whether each arg has a __typing_subst__ attribute.
If a preparation hook dynamically attaches __typing_subst__ to late after parameters was already built, tuple_index(parameters, nparams, late) cannot find late in parameters and returns -1:
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -525,8 +525,18 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
}
if (subst) {
Py_ssize_t iparam = tuple_index(parameters, nparams, arg);
- assert(iparam >= 0);
- arg = PyObject_CallOneArg(subst, argitems[iparam]);
+ if (iparam < 0) {
+ // __parameters__ may be stale if an argument gained
+ // __typing_subst__ after the tuple was computed.
+ PyErr_Format(PyExc_TypeError,
+ "argument %R with __typing_subst__ was not found "
+ "in __parameters__",
+ arg);
+ arg = NULL;
+ }
+ else {
+ arg = PyObject_CallOneArg(subst, argitems[iparam]);
+ }
Py_DECREF(subst);
}
In production CPython builds (NDEBUG), assert(iparam >= 0) is compiled out. _Py_subs_parameters() indexes argitems[-1] (the Py_ssize_t word sitting immediately before PyTupleObject.ob_item[0]) and passes that word as a PyObject * argument to the caller’s __typing_subst__ callback. On CPython >= 3.14, the field immediately preceding ob_item in PyTupleObject is ob_hash. Because tuple hashing over two integers is deterministic and invertible, a Jinja2 chat_template.jinja running inside ImmutableSandboxedEnvironment can:
- Read the memory address of a built-in C method or type from
''.maketrans.__repr__(). - Compute a 2-integer tuple
(a, b)whosehash((a, b))equals the targetPyObject *address, use(a, b)as adictkey to populateob_hash, and pass(a, b)as the substitution tuple to a generic alias (dict[str, ...]) constructed from standard sandbox objects. - Receive the raw
str,type,code, andfunctionobjects inside a Jinja macro callback and construct an arbitrary Pythoncodeobject to execute OS commands inside the vLLM or inference server process.
Indicators of compromise (IOCs) and exploit signatures
- Malicious Hugging Face
tokenizer_config.json/chat_template.jinjapatterns (gh-155752):- Jinja templates referencing
__typing_prepare_subst__,__typing_subst__,__parameters__, or.maketransinside macro definitions or namespace objects.
- Jinja templates referencing
zlib <= 1.3.2vulnerable call patterns:- C/C++ services calling
gzwrite()+gzprintf()on non-blocking sockets/pipes (O_NONBLOCK), or callinginflateInit2(&strm, 0)followed byinflateReset()/inflateSync()andinflateGetDictionary().
- C/C++ services calling
Detection and remediation
# 1. Check installed and bundled zlib versions across Linux hosts and container images
ldconfig -p | rg libz\.so || true
python3 -c 'import zlib; print("python zlib:", zlib.ZLIB_VERSION, zlib.ZLIB_RUNTIME_VERSION)'
# 2. Scan downloaded Hugging Face model directories and tokenizer_config.json files
# for GenericAlias substitution hooks in chat_template.jinja
rg -n '(__typing_subst__|__typing_prepare_subst__|__parameters__|maketrans)' \
~/.cache/huggingface/hub/ /models/ 2>/dev/null || true
- Upgrade
zlibandminizipto1.4: Rebuild or update native packages linkinglibz(>= 1.4) and replace any vendoredcontrib/minizipsources soCVE-2026-85091,THM-ZLIB-001,TOB-ZLIB-004..014, andblock_central_name()are patched. - Isolate Jinja2
chat_templateevaluation and patch CPython if running BYOM inference: Because CPython is not backportingPR #155761to Python3.12through3.14, apply commit3c9c477f508a(Objects/genericaliasobject.c) to custom Python builds used for multi-tenant LLM serving, reject untrustedchat_templatefiles that reference dunder attributes (__*__), and run model-serving workers inside unprivileged sandboxes without cloud IAM or host secrets.
Timeline
- 2026-08-13: RunSybil opens
gh-155752andpython/cpython#155761after CPython and Jinja maintainers decline to treat Python-level sandbox escapes as security vulnerabilities; CPython merges3c9c477f508aontomain(3.15) without backporting to3.12through3.14. - 2026-09-03 to 2026-11-03:
CVE-2026-85091(df84af25dc19),THM-ZLIB-001(2fd31f00740e),TOB-ZLIB-004(8179479c6274),2804ba757385, andfd54d99ea361land inmadler/zlib. - 2026-11-03 to 2026-11-05: RunSybil publishes its 90-day disclosure on CPython
GenericAliaschat-template RCE; Mark Adler tagszlib 1.4(99623ef70973); and both disclosures are posted tooss-security(2026/11/05/10,2026/11/05/11, and2026/11/05/12).
From research to remediation
Check whether this pattern exists in your codebase
Turn this research into a remediation workflow. Use AI-native static analysis to find similar application vulnerabilities and generate review-ready fixes.
References
- oss-security (2026/11/05/10): zlib 1.4 released with security fixes (CVE-2026-85091, THM-ZLIB-001, TOB-ZLIB-003..014)
- madler/zlib v1.4 release notes and commits df84af25dc19, 2fd31f00740e, 8179479c6274, 12d7b9098091, and 2804ba757385
- oss-security (2026/11/05/11 and 2026/11/05/12): CPython types.GenericAlias sandbox escape (gh-155752 / PR #155761)
- RunSybil Research (3 November 2026): CPython 0-Day Vulnerabilities Threaten the AI Supply Chain
- python/cpython PR #155761 (gh-155752: Do not crash when GenericAlias parameters change during substitution)