Skip to content

Upgrade vulnerable dependencies, part 2: lift the urllib3 pin (Dependabot backlog, November 2026) - #894

Merged
santicomp2014 merged 1 commit into
mainfrom
deps-vanta-2026-11-part2
Nov 10, 2026
Merged

santicomp2014 merged 1 commit into
mainfrom
deps-vanta-2026-11-part2

Conversation

@santicomp2014

@santicomp2014 santicomp2014 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #893 (base branch deps-vanta-2026-11). Merge #893 first, then retarget this PR to main.

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

Why we think it's fixed now

Both upstream projects fixed this so that urllib3 pools use gevent's cooperative queue by default:

  1. gevent 25.4.1 (changelog, gevent#2097, closes gevent#1957): monkey.patch_all() now also patches queue.Queue, queue.LifoQueue and queue.PriorityQueue. The changelog says this "is known to solve a non-deterministic deadlock with urllib3". 25.8.1, 25.8.2 and 25.9.1 then fixed bugs in the new patched queue classes, so this PR requires gevent>=25.9.1.
  2. urllib3 2.8.0 (changelog, urllib3#5057, closes urllib3#3289): each new connection pool now looks up queue.LifoQueue when 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's frontendapp calls patch_all()):

queue class behind urllib3's connection pools
main / #893 (urllib3 1.26.15, gevent 24.2.1) urllib3.util.queue.LifoQueue → stdlib queue.Queue (threading locks)
this PR (urllib3 2.8.0, gevent 26.9.0) gevent._gevent_cqueue.LifoQueue
this PR, with urllib3 imported before patch_all() gevent._gevent_cqueue.LifoQueue

pywb's own live-web adapter (PywbHttpAdapter) pools also get gevent._gevent_cqueue.LifoQueue.

Changes

  • requirements/requirements.in: replace urllib3==1.26.15 with urllib3>=2.8.0 and gevent>=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 a python:3.11.11 linux/amd64 container):

    Package Upgrade vulnerable dependencies (Dependabot backlog, November 2026) #893 This PR
    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 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.0 floor in requirements.in does the protecting now.

  • tox.ini: ignore one urllib3 FutureWarning. pywb's PywbHttpAdapter passes strict=True to PoolManager. urllib3 2.x ignores it but warns, and with filterwarnings = error that warning fails every proxied request in the functional tests. In production it's just one line on stderr per worker. pywb main still passes strict=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 calls sock.shutdown() when closing connections, and httpretty's fake socket raises on it. This uses the same one-line workaround as hypothesis/via's tests/conftest.py (added when via moved to urllib3 2.7).

Two CI fixes, needed because GitHub's ubuntu-latest runner moved to Ubuntu 26.04 today:

  • .python-version: 3.11.7 → 3.11.18. actions/setup-python has 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 on python: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: the context fixture now gives http_environ a real (empty) dict instead of create_autospec's MagicMock. Since Python 3.11.9, urllib.parse.parse_qsl() calls memoryview() 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 build succeeds. 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, /_status returns 200. Proxying example.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-pool PoolManager holds, 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:

    image requests errors p50 / p99 / max harakiri / stuck workers
    this PR 24,483 0 0.38s / 2.9s / 6.3s 0
    Upgrade vulnerable dependencies (Dependabot backlog, November 2026) #893 16,377 0 0.90s / 4.6s / 13.9s 0

    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:

  1. Concurrent proxied page loads under gevent. Load many different sites in parallel (more than 10 distinct origins per worker, so connection pools get evicted), including heavy pages with many subresources, slow/unresponsive upstreams, and pages with iframes. For example, run several browser tabs plus a scripted loop of curl against /proxy/<url> for 30+ minutes.
  2. Watch for the old symptom: workers that stop serving but don't crash. Look for HARAKIRI lines 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 in queue/threading acquire inside urllib3.connectionpool means the problem is back.
  3. Compare New Relic error rate, response time and the report_metrics uWSGI stats against the previous week.
  4. Keep it on staging for at least a day (ideally a weekday with LMS traffic on lms-viahtml QA) before deploying to prod. To roll back, revert this PR. Upgrade vulnerable dependencies (Dependabot backlog, November 2026) #893 can stay.

Still deferred

  • cryptography 46.0.7 (18 high, 6 medium). The fixes need cryptography 48.0.1, 49.0.0 or 50.0.0. pywb, both 2.10.1 and the new 2.11.0 (and main), requires pyOpenSSL<26.2 because its certauth dependency uses X509.add_extensions(), which pyOpenSSL 26.2 removed (webrecorder/pywb#1000, still open). pyOpenSSL < 26.2 requires cryptography<48. No pywb release allows a fixed cryptography yet.
  • werkzeug 3.1.7 (6 medium, GHSA-g6x2-hccm-hh4m, Windows-only 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: document for frame requests, Refresh header 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.
  • 53 alerts on a top-level requirements.txt that was deleted in the 2021 "Requirements reorg" (90bd841). It doesn't exist on main, so they can't be closed by a code change and need to be dismissed as inaccurate by an admin.

🤖 Generated with Claude Code

@santicomp2014
santicomp2014 force-pushed the deps-vanta-2026-11-part2 branch 2 times, most recently from 8ae5209 to 5529428 Compare November 6, 2026 14:45
Base automatically changed from deps-vanta-2026-11 to main November 10, 2026 08:34
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
santicomp2014 force-pushed the deps-vanta-2026-11-part2 branch from 5529428 to 32f23ae Compare November 10, 2026 08:36
@santicomp2014
santicomp2014 merged commit 04bc51e into main Nov 10, 2026
3 checks passed
@santicomp2014
santicomp2014 deleted the deps-vanta-2026-11-part2 branch November 10, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants