# CVE-2026-134821 — Gunicorn: unbounded line buffering in the pure-Python ASGI parser
[ |
| **Fixed in** | **27.0.0** — commit `3007d52` (GHSA-m589-rp9j-v484) |
| **CWE** | CWE-400 (Uncontrolled Resource Consumption), CWE-770 (Allocation of Resources Without Limits) |
| **Impact** | The pure-Python ASGI HTTP/1 parser buffered request lines, header fields, chunk-size lines and trailers until CRLF arrived, with no size limit when the corresponding limit was configured as 0 (unlimited), and rescanned the whole growing buffer on every read. An unauthenticated remote client could send a CRLF-less stream to grow worker memory and consume CPU, denying service |
| **Vector** | unauthenticated HTTP connection sending CRLF-less request bytes |
| **Trigger** | 2 MiB of request-line bytes with no `\r\n` and `limit_request_line=0` |
# parser.py — pre-fix (verbatim in the lab)
return False # keep buffering forever, rescan whole buffer time
# fixed (commit 3007d52, verbatim in the lab)
self._limit_request_line or MAX_UNLIMITED_REQUEST_LINE,
LimitRequestLine("Request line is too large"))
`_find_line()` rejects buffers larger than the limit and only scans bytes not
A line without a terminator made the parser retain the bytes indefinitely and
call `buffer.find(b'\r\n')` over the entire buffer again on every socket read.
The cost grew quadratically with the number of bytes sent, and memory grew
without bound. The fix applies the configured request limits even when they
are set to "unlimited" by falling back to the same bounds the WSGI and C
parsers use, and tracks a scan cursor so each byte is examined once.
| `gu-vuln` | `cve-2026-134821:vuln` | verbatim unbounded `find()` request-line path |
| `gu-fixed` | `cve-2026-134821:fixed` | verbatim `_find_line()` and constant from `3007d52` |
| `poc` | `cve-2026-134821-poc:local` | stdlib-only Python driver |
The harness feeds 32 × 64 KiB of CRLF-less line bytes to each side, recording
the buffered size and the cumulative bytes scanned.
./run-lab.sh build # builds both sides (python:3.12-alpine)
./run-lab.sh up # cve134821lab network: gu-vuln / gu-fixed
* **check** — exit 1 when 2 MiB is buffered with no limit error, 0 when the
parser rejects the oversized line; 3 no worker, 2 unreachable.
* **exploit** — narrated chain: CRLF-less stream → unbounded buffer →
quadratic rescan → worker memory/CPU exhaustion.
* **probe** — fed/buffered/scanned bytes and the rejection error.
* **mitigation** — 27.0.0 / commit `3007d52` / bounded incremental scan.
A standalone full-chain exploit ships at `exploit/exploit.py`:
python3 exploit/exploit.py --host=gu-vuln
# exit 1 on confirmed unbounded buffering, 0 on a safe target
| | `gu-vuln` (< 27.0.0) | `gu-fixed` (27.0.0) |
| 2 MiB CRLF-less input | **2 MiB buffered, 34.6 MiB rescanned, no error** | **rejected at ~1.1 MiB with `Request line is too large`; 10 MiB scanned** |
Captured runs: `evidence/check-*-run.txt`, `evidence/exploit-*-run.txt`,
`evidence/probe-*-run.txt`, `evidence/mitigation-*-run.txt`,
`evidence/exploit-standalone-run.txt`, `evidence/exploit-standalone-fixed-run.txt`,
`evidence/versions.txt`, `evidence/0day-sweep.txt`.
* Podman (or Docker); bounded containers on the isolated `cve134821lab`
* Real-world exploitation requires a client able to open HTTP connections to
a Gunicorn ASGI worker on an affected version.
## 7. Additional findings (0-day sweep on the fixed line)
`_find_line()` applies the bound to request lines, headers, chunk-size lines
and trailers, and its scan cursor eliminates repeated whole-buffer scans.
Normal CRLF-terminated requests still parse on the fixed build. No residual
unbounded line path was found on the fixed line in this sweep.
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/harness-*.py verbatim parser path per side + scan accounting
lab/lab.Dockerfile builds both sides from pinned upstream source slices
lab/service.py HTTP wrapper (POST /feed), child-process isolation
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)
* CVE record —
* GitHub advisory —
* Fix commit —
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
