Skip to content

fix(docker): install current Pillow and torch dependencies in the image - #239

Merged
jasonmadigan merged 1 commit into
mainfrom
fix/image-python-deps
Oct 24, 2026
Merged

jasonmadigan merged 1 commit into
mainfrom
fix/image-python-deps

Conversation

@jasonmadigan

Copy link
Copy Markdown
Collaborator

Summary

Images built from main ship Pillow 12.3.0, and rebuilding does not change that.

 # Dockerfile
+RUN pip install --no-cache-dir --upgrade pip
-RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
+RUN pip install --no-cache-dir --no-deps torch torchvision --index-url https://download.pytorch.org/whl/cpu
 RUN pip install --no-cache-dir -r backend/requirements.txt

 # backend/requirements.txt
-Pillow>=10.0.0
+Pillow>=13.0.0

The torch step also installed the dependencies of torch and torchvision from the PyTorch CPU index, which carries Pillow 12.3.0, filelock 3.32.3 and setuptools 78.1.0 at most. The requirements install then found Pillow>=10.0.0 already satisfied and left it alone. Pillow 13.0.0 fixes 41 advisories, including heap overflows in JPEG decoding (CVE-2026-112403, CVE-2026-96778), FlashPix decoding (CVE-2026-112398) and the bundled OpenJPEG (GHSA-78g4-xqwv-q3g8). Uploaded images are decoded with Pillow.

With --no-deps, only torch and torchvision come from the CPU index, and the requirements install resolves their dependencies from PyPI. The torch wheels stay CPU-only, and no CUDA packages are installed. Pillow>=13.0.0 makes existing development environments upgrade as well. It needs rembg 2.0.86 or later, because 2.0.85 capped Pillow below 13; pip selects it.

The base image ships pip 25.0.1, which has known install-time vulnerabilities, so pip is upgraded before the installs.

Evidence

  • Before (ghcr.io/tracefinity/tracefinity:0.10.0): Pillow 12.3.0, certifi 2026.7.22, filelock 3.32.3, setuptools 78.1.0 and pip 25.0.1. pip-audit (OSV) reports 54 advisories across those five packages.
    After (local arm64 build of this branch with build(deps): update frontend dependencies for security advisories #238): Pillow 13.0.0, certifi 2026.10.23, filelock 4.2.4, setuptools 84.2.1, pip 26.2.2 and torch 2.14.1+cpu. pip-audit (PyPI and OSV) reports no known vulnerabilities in the 101 installed packages, and pip check reports no broken requirements.
  • The backend suite run inside the built image as the unprivileged tracefinity user: 852 passed.
  • The container starts cleanly: / and /api/version return 200 through nginx, and the backend /health returns {"status":"ok"}.

Merge Danger

Door: two-way

Blast Radius: image

Pillow 13 is a major release. The backend suite passes against it in the image, and CI's backend tests install it as well.

The image installs torch and torchvision from the PyTorch CPU index
first. That step also took their dependencies from the CPU index, which
carries Pillow 12.3.0 at most, and the later requirements install left
the satisfied Pillow in place. Images therefore shipped Pillow 12.3.0
even after Pillow 13.0.0 fixed a large set of decoder vulnerabilities,
and filelock and setuptools lagged in the same way.

Install only torch and torchvision from the CPU index and let the
requirements install resolve their dependencies from PyPI. Require
Pillow 13.0.0 so existing environments upgrade too. Upgrade pip before
installing, since the base image's pip 25.0.1 has known install-time
vulnerabilities.

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
@jasonmadigan
jasonmadigan merged commit 57d10f3 into main Oct 24, 2026
6 checks passed
@jasonmadigan
jasonmadigan deleted the fix/image-python-deps branch October 24, 2026 18:17
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.

1 participant