Repository navigation
Upgrade vulnerable dependencies, part 2: lift the urllib3 pin (Dependabot backlog, November 2026) - #894
Merged
Conversation
santicomp2014
force-pushed
the
deps-vanta-2026-11-part2
branch
2 times, most recently
from
November 6, 2026 14:45
8ae5209 to
5529428
Compare
karenrasmussen
approved these changes
Nov 6, 2026
urllib3 was pinned to 1.26.15 (#716) because 1.26.16+ deadlocked uWSGI workers under gevent. That was caused by urllib3's connection pools using a non-gevent queue. gevent 25.4.1 now monkey-patches queue.LifoQueue (gevent/gevent#1957), and urllib3 2.8.0 resolves queue.LifoQueue when each pool is created (urllib3/urllib3#3289), so pools use gevent's cooperative queue again. - requirements.in: replace `urllib3==1.26.15` with `urllib3>=2.8.0` and `gevent>=25.9.1` so both fixes can't be lost. - urllib3 1.26.15 -> 2.8.0, gevent 24.2.1 -> 26.9.0, greenlet 3.1.0 -> 3.5.6. - Dockerfile: remove the `pip install gevent==24.2.1 greenlet==3.1.0` override, which would now downgrade gevent below the fix. - dependabot.yml: stop ignoring urllib3. - tox.ini: ignore urllib3's FutureWarning about pywb passing strict=True to PoolManager (with filterwarnings=error it failed every proxied request). - Functional tests: give httpretty's fake socket no shutdown(), which urllib3 2.x calls (same workaround as hypothesis/via). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
santicomp2014
force-pushed
the
deps-vanta-2026-11-part2
branch
from
November 10, 2026 08:36
5529428 to
32f23ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #893 (base branch
deps-vanta-2026-11). Merge #893 first, then retarget this PR tomain.This lifts the urllib3 pin that #893 left in place. It closes the 59 urllib3 Dependabot alerts on the live requirements files (41 high, 18 medium), which block the Vanta SOC 2 "packages checked for vulnerabilities" tests.
This changes how the proxy runs under gevent in production, so please soak it on staging before it goes to prod (see "Before merging" below).
Background: why urllib3 was pinned
SIGCONTstack dump to investigate.urllib3==1.26.15. Other projects had reported that urllib3 1.26.16+ deadlocks under gevent (gevent/gevent#1957, urllib3/urllib3#3289). deb4b94 then recorded that the pin had been confirmed to fix the deadlock, and Stop Dependabot from updating urllib3 #727 stopped Dependabot from bumping urllib3.PoolManagercloses evicted connection pools. Closing a pool drains its queue of connections. In urllib3 1.26 that queue isurllib3.util.queue.LifoQueue, a subclass of the standard library'squeue.Queue. gevent didn't patch that class (until 25.4.1 it only patchedSimpleQueue), so the queue relies onthreading.Condition/Lock. Upstream's explanation is that when that close runs from a garbage-collection/finalizer callback (for example on gevent's hub), it can block on a lock that only another greenlet can release, so the worker hangs without crashing. The details are in jamadden's analysis, thegc.disable()/PURE_PYTHONexperiments and the queue-class diagnosis. The common workaround wasConnectionPool.QueueCls = gevent.queue.LifoQueue, which projects reported fixed it in production (geoadmin, locust#2813).Why we think it's fixed now
Both upstream projects fixed this so that urllib3 pools use gevent's cooperative queue by default:
monkey.patch_all()now also patchesqueue.Queue,queue.LifoQueueandqueue.PriorityQueue. The changelog says this "is known to solve a non-deterministic deadlock withurllib3". 25.8.1, 25.8.2 and 25.9.1 then fixed bugs in the new patched queue classes, so this PR requiresgevent>=25.9.1.queue.LifoQueuewhen it's created, instead of using a reference taken at import time. The patched class is used even if urllib3 was imported before gevent patched anything.Checked in the built image, using the same import order as the uWSGI worker (
viahtml.wsgi, where pywb'sfrontendappcallspatch_all()):main/ #893 (urllib3 1.26.15, gevent 24.2.1)urllib3.util.queue.LifoQueue→ stdlibqueue.Queue(threading locks)gevent._gevent_cqueue.LifoQueuepatch_all()gevent._gevent_cqueue.LifoQueuepywb's own live-web adapter (
PywbHttpAdapter) pools also getgevent._gevent_cqueue.LifoQueue.Changes
requirements/requirements.in: replaceurllib3==1.26.15withurllib3>=2.8.0andgevent>=25.9.1. The comment explains why, so neither fix can be downgraded away by accident.Recompiled every file that includes
requirements.txt, upgrading only these three packages (pip-compile --allow-unsafe -P urllib3 -P gevent -P greenlet, in apython:3.11.11linux/amd64 container):Dockerfile: remove thepip install gevent==24.2.1 greenlet==3.1.0override from Add a temporary hack to upgrade gevent and greenlet in Docker #714. It would now downgrade gevent to a version without the fix. The requirements files now pin the gevent that runs in production..github/dependabot.yml: stop ignoring urllib3 (Stop Dependabot from updating urllib3 #727). The>=2.8.0floor inrequirements.indoes the protecting now.tox.ini: ignore one urllib3FutureWarning. pywb'sPywbHttpAdapterpassesstrict=TruetoPoolManager. urllib3 2.x ignores it but warns, and withfilterwarnings = errorthat warning fails every proxied request in the functional tests. In production it's just one line on stderr per worker. pywbmainstill passesstrict=True. urllib3 says it will become an error in v3.0, so that will need a pywb fix before urllib3 3.tests/functional/conftest.py: urllib3 2.x callssock.shutdown()when closing connections, and httpretty's fake socket raises on it. This uses the same one-line workaround ashypothesis/via'stests/conftest.py(added when via moved to urllib3 2.7).Two CI fixes, needed because GitHub's
ubuntu-latestrunner moved to Ubuntu 26.04 today:.python-version: 3.11.7 → 3.11.18.actions/setup-pythonhas no 3.11.7 build for Ubuntu 26.04 (the oldest 3.11 build is 3.11.15), so the Backend job failed at "Setup python". This only affects CI and local dev. The Docker image stays onpython:3.11.11-alpine3.19. Upgrade vulnerable dependencies (Dependabot backlog, November 2026) #893 is green only because its run landed on a 24.04 runner. It will hit the same error if CI re-runs there.tests/unit/viahtml/hooks/hooks_test.py: thecontextfixture now giveshttp_environa real (empty) dict instead ofcreate_autospec's MagicMock. Since Python 3.11.9,urllib.parse.parse_qsl()callsmemoryview()on its input, so 6 redirect tests failed on 3.11.18.No application code changes.
Testing (local)
tox --parallel -e lint,checkformatting,tests,coverage,functests(the CI command) on Python 3.11.18 and 3.11.7: all pass, 100% coverage.tox -e format: no changes. CI (Ubuntu 26.04, 3.11.18) is green.docker buildsucceeds. Image has urllib3 2.8.0, gevent 26.9.0, greenlet 3.5.6, pywb 2.10.1, uWSGI 2.0.31. Under supervisord/nginx/uWSGI,/_statusreturns 200. Proxyingexample.com,web.hypothes.is, a Wikipedia article and a gnu.org page returns 200 with wombat and the client injected.Concurrency sanity soak: 60 concurrent clients for 5 minutes, proxying through nginx → uWSGI (
production.ini, gevent 100) to 40 distinct local upstream origins. That's more origins than requests' 10-poolPoolManagerholds, so pools are evicted and closed all the time, which is the code path changed in urllib3 1.26.16. Run against this PR's image and Upgrade vulnerable dependencies (Dependabot backlog, November 2026) #893's image:This is a sanity check, not proof. The original deadlock was non-deterministic, GC-timing dependent, and needed production traffic to show up. That's what the staging soak below is for.
Before merging: staging soak
One caveat: the deadlock was never reliably reproduced upstream, and one commenter argued that the gevent queue swap may hide the race rather than remove it. That's why staging needs to see real concurrent traffic first.
Please deploy to staging/QA and let it run under real, concurrent proxied traffic before prod:
curlagainst/proxy/<url>for 30+ minutes.HARAKIRIlines in the logs (harakiri = 60), rising latency or 502/504s at nginx, and uWSGI busyness pinned at 100% while CPU sits idle. If a worker looks stuck,kill -s SIGCONT <worker pid>(Support dumping gevent stacks from uWSGI workers #715) dumps its greenlet stacks. A hang inqueue/threadingacquireinsideurllib3.connectionpoolmeans the problem is back.report_metricsuWSGI stats against the previous week.lms-viahtmlQA) before deploying to prod. To roll back, revert this PR. Upgrade vulnerable dependencies (Dependabot backlog, November 2026) #893 can stay.Still deferred
main), requirespyOpenSSL<26.2because itscertauthdependency usesX509.add_extensions(), which pyOpenSSL 26.2 removed (webrecorder/pywb#1000, still open). pyOpenSSL < 26.2 requirescryptography<48. No pywb release allows a fixed cryptography yet.safe_join()device names; viahtml runs on Linux). pywb 2.11.0 (released 2026-11-02) unpins werkzeug, so 3.1.9 would install. But 2.11.0 also brings wombat 3.11.0,Sec-Fetch-Dest: documentfor frame requests,Refreshheader rewriting, a Vue 3 UI and index changes. Shipping that in the same staging soak as the gevent/urllib3 change would make any regression hard to attribute, so it should be its own PR once this one has soaked.requirements.txtthat was deleted in the 2021 "Requirements reorg" (90bd841). It doesn't exist onmain, so they can't be closed by a code change and need to be dismissed as inaccurate by an admin.🤖 Generated with Claude Code