Skip to content

chore(deps): consolidate Python security dependency upgrades#12558

Merged
mekarpeles merged 9 commits intomasterfrom
deps/python-security-consolidation
May 4, 2026
Merged

chore(deps): consolidate Python security dependency upgrades#12558
mekarpeles merged 9 commits intomasterfrom
deps/python-security-consolidation

Conversation

@mekarpeles
Copy link
Copy Markdown
Member

@mekarpeles mekarpeles commented May 3, 2026

Summary

Consolidates 8 open Renovate PRs into a single tested and verified upgrade. All packages were installed and tested in Docker before opening this PR.

Packages upgraded

Package Before After Severity Closes
psycopg2 2.9.6 2.9.12 #10892
beautifulsoup4 4.12.2 4.14.3 #10807
feedparser 6.0.11 6.0.12 #12564
python-multipart 0.0.21 0.0.26 🔴 High (CVE-2026-24486), 🟡 Medium (CVE-2026-40347) #11741
multipart 0.2.4 1.2.2 🔴 Security #12084
Pillow 10.4.0 12.2.0 🔴 High (CVE-2026-25990, CVSS 8.6) #11848
lxml 4.9.4 6.1.0 🔴 High (CVE-2026-41066, CVSS 7.5) #12424
sentry-sdk 2.49.0 2.58.0 #11839

🔴 Security upgrades

python-multipart 0.0.21 → 0.0.26 — Fixes CVE-2026-24486 (arbitrary file write via path traversal, CVSS 8.6) and CVE-2026-40347 (DoS via large multipart preamble/epilogue, CVSS 5.3). v0.0.23 removed trust_x_headers and X-File-Name fallback, but OL does not set those. Risk: low.

multipart 0.2.4 → 1.2.2 — Major version, but no direct imports in the codebase; consumed indirectly via FastAPI middleware. Risk: medium. What could go wrong: file upload endpoints (batch import /api/import, cover uploads) could be affected if v1 changed how multipart data is exposed to FastAPI route handlers.

Pillow 10.4.0 → 12.2.0 — Fixes CVE-2026-25990 (out-of-bounds write loading PSD images, CVSS 8.6). APIs used by OL — Image.open, Image.LANCZOS, ImageOps.exif_transpose(in_place=True), ImageDraw, ImageFont.truetype — are stable and unchanged in 12.x. Risk: medium.

lxml 4.9.4 → 6.1.0 — Fixes CVE-2026-41066 (XXE via iterparse/ETCompatXMLParser, CVSS 7.5). lxml 6.x changes iterparse() default from resolve_entities=True to resolve_entities='internal'. Impact analysis:

  • marc_xml.py is the only caller using iterparse() without an explicit resolve_entities argument. It parses LoC MARC21 slim XML, which has no external entities — the stricter default is a security improvement with no functional change.
  • All other callers (importapi/code.py, catalog/get_ia.py, scripts/lc_marc_update.py, tests) already pass resolve_entities=False explicitly.

🔧 Maintenance upgrades

psycopg2 2.9.6 → 2.9.12 — Patch-only bump, bugfixes only. Risk: negligible.

beautifulsoup4 4.12.2 → 4.14.3 — Minor version; stable public API, no removals. Risk: low.

feedparser 6.0.11 → 6.0.12 — Patch bump; no API changes. Risk: negligible.

sentry-sdk 2.49.0 → 2.58.0 — Minor version bump. OL uses internal APIs (tracing_utils.add_query_source, record_sql_queries, utils.capture_internal_exceptions) — all verified present and importable at 2.58.0. Risk: low.

Testing

All packages installed cleanly in the running Docker container with no conflicts. Import verification passed for all packages including internal sentry APIs.

HTTP check: static assets return 200; no 500 errors in container logs.

Test results (run inside Docker):

  • openlibrary/catalog/marc/tests/124 passed (lxml iterparse)
  • openlibrary/coverstore/tests/21 passed, 7 skipped (Pillow)
  • openlibrary/plugins/importapi/61 passed (lxml XMLParser)
  • Full remaining suite — 3318 passed, 1 xfailed

Total: 3524 tests, 0 failures.

Checklist

  • All packages install cleanly (no dependency conflicts)
  • All imports verified at new versions
  • App serves HTTP 200 (static assets confirmed)
  • 3524 tests passing, 0 failures
  • API compatibility verified per package
  • CI passing

References

Closes #10807, #10892, #11741, #11848, #12084, #12424, #11839, #12564

mekarpeles added 6 commits May 3, 2026 13:24
Minor version bump; no breaking changes expected.
 #11741)

Fixes CVE-2026-24486 (arbitrary file write via path traversal, CVSS 8.6)
and CVE-2026-40347 (DoS via large multipart preamble/epilogue, CVSS 5.3).
Major version; no direct API usage in codebase — consumed indirectly via
FastAPI/web.py middleware.
Fixes CVE-2026-25990 (out-of-bounds write loading PSD images, CVSS 8.6).
Code uses stable APIs: Image.open, Image.LANCZOS, ImageOps.exif_transpose,
ImageDraw, ImageFont — all unchanged in 12.x.
Fixes CVE-2026-41066 (XXE via iterparse/ETCompatXMLParser, CVSS 7.5).

lxml 6.x changes the default resolve_entities from True to 'internal' for
iterparse() and ETCompatXMLParser(). Impact analysis:
- marc_xml.py uses iterparse() without explicit resolve_entities: behavior
  change is safe since LoC MARC21 slim XML has no external entities, and
  the stricter default is a security improvement.
- All other callers (importapi, get_ia, scripts, tests) already pass
  resolve_entities=False explicitly — no change in behavior.
Copilot AI review requested due to automatic review settings May 3, 2026 19:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Minor version bump. OL uses internal sentry APIs (tracing_utils.add_query_source,
tracing_utils.record_sql_queries, utils.capture_internal_exceptions) — verified
all still present and importable at 2.58.0.
Absorbs renovate PR #12567 into the Python security consolidation rollup.
pip install dry-run verified on Docker (py-spy 0.4.2 resolves cleanly).
@mekarpeles
Copy link
Copy Markdown
Member Author

Added py-spy 0.4.0 → 0.4.2 (from #12567) to this rollup. pip install dry-run verified cleanly on Docker. Closes #12567.

@mekarpeles mekarpeles assigned mekarpeles and unassigned cdrini May 4, 2026
@mekarpeles
Copy link
Copy Markdown
Member Author

Tested locally, uv pip installed and run with docker. (Assigning myself as the reviewer for the renovate PRs)

@mekarpeles mekarpeles merged commit 6a55502 into master May 4, 2026
7 checks passed
@mekarpeles mekarpeles deleted the deps/python-security-consolidation branch May 4, 2026 00:25
mekarpeles added a commit that referenced this pull request May 4, 2026
Patch bump. Previously upgraded to 0.0.26 in #12558.

Closes #12578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 1 Do this week, receiving emails, time sensitive, . [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants