The short version
- Same bug as Node2Shell: crafted Brotli data makes the C decoder write past its buffer. Crash, memory leak, or in some builds code execution.
- Fixed in
Brotli1.2.1 (PYSEC-2026-4322) andbrotlicffi1.2.1.0 (PYSEC-2026-4323). Treat every earlier release as vulnerable. requests,urllib3,httpx,aiohttpand Scrapy decode Brotli responses automatically when either package is installed. The usual risk is outbound: a server you call sends the payload.- Brotli usually arrives as a transitive dependency, through extras like
urllib3[brotli]orhttpx[brotli]. Check the installed environment, not just requirements.txt. - If you don't need Brotli, uninstalling both packages removes the exposure.
1. What Py2Shell is
CVE-2026-111497 is an out-of-bounds write in Google's Brotli decoder: a crafted stream asks for a block-type switch that should stop the decoder with an error, and the vulnerable version carries on writing past the end of its buffer. It was first written up for Node.js as Node2Shell. On 23 October 2026 Python was linked to the same bug, and the Python side picked up the names Python2Shell and Py2Shell.
Python is affected because the two Brotli packages on PyPI, Brotli and brotlicffi, wrap the same C decoder. CPython itself doesn't ship one.
2. Am I affected?
You're exposed when all three are true:
Brotlibelow 1.2.1 orbrotlicffibelow 1.2.1.0 is installed in the environment that runs your code.- Something decodes Brotli with it.
requests,urllib3,httpx,aiohttpand Scrapy do so automatically forContent-Encoding: brresponses whenever either package is importable. Your code never has to mention Brotli. - The data comes from somewhere you don't control: a third-party API, a webhook target, a URL a user gave you, a site you scrape, or an uploaded file containing Brotli (WOFF2 fonts, Parquet).
The typical Python exposure is outbound, the reverse of the usual web bug. A scraper, link-preview service, RSS reader or AI agent that fetches arbitrary URLs is the clearest case. So is any integration with an API that could itself be compromised.
Packages that bundle their own Brotli decoder need their own fix regardless of the PyPI packages. Pillow, pyarrow, DuckDB and ClickHouse were reported as still unpatched in late October 2026; check their advisories.
3. How to find it in your dependencies
Brotli is rarely a direct dependency. It usually arrives through an extra such as urllib3[brotli], httpx[brotli] or aiohttp[speedups], or through a framework that asks for one. So grep brotli requirements.txt often finds nothing while the image still has it.
- In the running environment:
pip show Brotli brotlicffi, orpython -c "import brotli; print(brotli.__version__)". - In lockfiles: search
uv.lock,poetry.lockor apip freezeoutput forbrotli. - Who pulls it in:
pipdeptree -r -p brotlioruv tree --invert --package brotli. - In images: check the built image, not the repository. A fixed lockfile doesn't help until the image is rebuilt and redeployed.
4. What to upgrade, and the workarounds
- Upgrade:
pip install -U "Brotli>=1.2.1" "brotlicffi>=1.2.1.0", or add those floors as constraints so a transitive dependency can't pull an older one. Rebuild images and restart long-running workers, because a process keeps the old extension module loaded. - Or remove it: if you don't need Brotli, uninstall both packages and drop the extras (
httpx[brotli]becomeshttpx). The clients fall back to gzip and deflate. - Untrusted fetches: turn off automatic decoding and check
Content-Encodingyourself. In urllib3, usepreload_content=Falseanddecode_content=False. - Don't rely on
Accept-Encoding. A malicious server can send Brotli whether you asked for it or not. - Don't trust the extra's floor. Earlier urllib3 guidance and the
urllib3[brotli]extra set minimum versions that are still vulnerable.
5. How Compass helps
Compass, our open-source (Apache 2.0) operations agent for AWS, works on both sides of a bug like this one.
Before: the dependency, the workload, the pull request
- The patch captain follows OSV (which carries the PYSEC advisories), the CVE list, CISA KEV and EPSS every hour, and matches them against the Python packages it reads from your repositories:
requirements*.txt,pyproject.toml,uv.lockandpoetry.lock, compared in PEP 440 order. - Each finding says which repository and file it came from, which ECS workloads run the image that repository builds, and whether those face the internet.
- Where Brotli is pinned directly, it opens the fix pull request, editing the pin in place, and reads CI and the image build. Where Brotli is transitive, which is the common case here, the finding waits in the inbox marked "transitive dependency", because the right fix (a constraint, an upgraded parent, or removing the extra) is a choice for a person. It never merges.
During: honeytokens
- Code execution in a Python worker usually starts with reading
os.environ. Compass plants decoy AWS keys and database logins as Terraform pull requests, for you to place next to the real variables. - Use of a decoy opens an incident naming the one task definition it was planted in. If your policy allows, Compass restarts that ECS task or deactivates the key, each with a snapshot, verification, audit entry and rollback.
What it doesn't do: inspect the HTTP responses your code receives, or see an attacker who ignores the decoys. A restart removes a foothold; the upgraded package removes the bug. That pairing contained our PHP2Shell incident in under two minutes. More about Compass.
6. FAQ
What is Py2Shell or Python2Shell?
Py2Shell and Python2Shell are names for CVE-2026-111497 as it affects Python. The Brotli and brotlicffi packages ship Google's Brotli C decoder, which has an out-of-bounds write. Python HTTP clients use those packages to decode Brotli-compressed responses automatically, so a malicious server can send data that crashes the process or, in some builds, runs code.
Is Python2Shell a bug in CPython?
No. CPython's standard library doesn't include a Brotli decoder. The vulnerable code comes from the third-party Brotli and brotlicffi packages, so the fix is upgrading those packages, not Python itself.
Which versions fix CVE-2026-111497 in Python?
Brotli 1.2.1 and brotlicffi 1.2.1.0, released on 22 and 23 October 2026. Run pip install -U "Brotli>=1.2.1" "brotlicffi>=1.2.1.0", or raise the pins in your lockfile. Earlier urllib3 guidance and its brotli extra set minimum versions that are still vulnerable, so don't rely on the extra's floor.
Am I affected if my code never imports brotli?
Possibly. requests, urllib3, httpx, aiohttp and Scrapy check whether Brotli or brotlicffi is installed and, if so, advertise and decode Brotli responses on their own. Run pip show Brotli brotlicffi in the environment that actually runs your code, such as the container image, to find out.
Does removing br from Accept-Encoding protect me?
No. A malicious server can send a Brotli-encoded response whatever you asked for, and a client with automatic decoding will decode it. Disable automatic decoding for untrusted fetches, or remove or upgrade the Brotli packages.
Are Pillow, pyarrow or DuckDB affected?
Packages that bundle their own copy of the Brotli decoder need their own fix, independent of the Brotli package on PyPI. Reports listed Pillow, pyarrow, DuckDB and ClickHouse among those still unpatched in late October 2026. Check each project's advisory, especially if you process untrusted fonts, Parquet files or images.
Written by Ilia Dubovskii, founder of Beamreach. Package versions, advisory IDs and dates were checked against the PyPI advisories and Phoenix Security's write-up on 17 November 2026. Exploitation reports for CVE-2026-111497 disagree; see the Node2Shell page for the spread.
Related: Node2Shell / HTTP2Shell (CVE-2026-111497) · The *2Shell vulnerabilities, 2021 to 2026 · PHP2Shell · AWS canary credentials · One Fake Password Is Worth More Than 10,000 Alerts (talk)
Beamreach