Skip to content

fix(deps): bump Pillow to 13.0.0 in the backend image - #4562

Merged
AndriiPasternak31 merged 2 commits into
devfrom
fix/ent1124-pillow-pin
Nov 13, 2026
Merged

AndriiPasternak31 merged 2 commits into
devfrom
fix/ent1124-pillow-pin

Conversation

@AndriiPasternak31

Copy link
Copy Markdown
Contributor

Part of Abilityai/trinity-enterprise#1124 (the Pillow part only; the python-jose, pin-manifest and Dependabot parts stay open there)

Summary

The backend image pinned Pillow 11.1.0, which carries 90 published advisories (OSV), including Critical heap overflows in decoders that Image.open() reaches with default settings. The backend now decodes avatar images supplied by template repositories, so those bytes are untrusted input.

Every 11.x and 12.x release is still affected (12.3.0 has 62 open advisories, among them the bundled-OpenJPEG write overflow present since 11.1.0). 13.0.0 is the first release that fixes all of them; OSV and the GitHub advisory database list none against it.

Changes

  • docker/backend/Dockerfile: Pillow==11.1.0 → Pillow==13.0.0.
  • tests/requirements-test.txt: floor raised to >=13.0.0 so CI never runs an older Pillow than the image ships.
  • docs/memory/feature-flows/agent-avatars.md: dependency version updated.
  • New test in tests/unit/test_1173_hub_display_avatar.py: real PNG and WebP bytes go through _install_bundled_avatar_bytes with nothing mocked on the image path. The existing tests stub Image.open and optimize_avatar, so they could not catch a Pillow upgrade that broke decoding.

Compatibility

13.0.0 ships cp313 manylinux_2_28 wheels for x86_64 and aarch64. The backend uses Image.open, .width/.height, thumbnail(..., Image.LANCZOS) and WebP save; none of these is removed or changed in 12.0 or 13.0.

Verification

Validation: the backend image builds (arm64); pip show pillow in it reports 13.0.0. Inside the image a PNG and a WebP each go through _install_bundled_avatar_bytes to a 512x384 WebP, and the three bundled template avatars go through optimize_avatar to 512x512 WebP. Avatar and Dockerfile/requirements parity unit tests on Python 3.13: 1065 passed, 29 skipped.
Mutation: restricting optimize_avatar's Image.open to JPEG turns the new test red (UnidentifiedImageError, 2 failed).

Unverified:

  • The amd64 image was not built locally (only the wheel resolution was checked); CI builds it.
  • No full stack boot; the in-image check covers import and the decode path.
  • 13.0.0 patches its bundled OpenJPEG on top of 2.5.4, so a scanner matching on library versions may still flag jpg_2000 2.5.4.

Journey Impact

Journey Impact: none: dependency bump; avatars decode exactly as before

…ity-enterprise#1124)

The backend image pinned Pillow 11.1.0. OSV lists 90 advisories against
that version, several of them Critical heap overflows in decoders that
Image.open() reaches with default settings. Every 11.x and 12.x release
is affected: 12.3.0 still carries 62 open advisories, including the
bundled-OpenJPEG write overflow that has been present since 11.1.0.
13.0.0 is the first release that fixes all of them, and OSV lists none
against it.

The exposure matters because the backend now decodes avatar images taken
from template repositories (local templates and GitHub templates), so the
bytes handed to Pillow come from whoever wrote the template.

13.0.0 ships cp313 manylinux_2_28 wheels for both x86_64 and aarch64,
which the trixie base image (glibc 2.41) installs. The only Pillow calls
the backend makes are Image.open, .width/.height, thumbnail with
Image.LANCZOS, and a WebP save; none of them is removed or changed in
12.0 or 13.0 (Image.LANCZOS is one of the constants Pillow restored for
good in 9.4).

The test requirements floor moves with it so CI never resolves an older
Pillow than the image ships.
…install

The tests for _install_bundled_avatar_bytes stub both Image.open and
optimize_avatar, so a Pillow upgrade that broke the header read, the
resize or the WebP encoder would leave them green. This test passes real
PNG and WebP bytes (the two formats a template may bundle) through the
function with nothing mocked on the image path, and checks that the file
written is a 512x384 WebP with the source colour.

Checked that it fails when the decoder cannot read the input: restricting
optimize_avatar's Image.open to JPEG turns both cases red with
UnidentifiedImageError.
@AndriiPasternak31
AndriiPasternak31 marked this pull request as ready for review November 13, 2026 20:33

@obasilakis obasilakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/review + /validate-pr — APPROVE

Lane C (docker/backend/Dockerfile). Scope clean: Pillow pin, test-requirements floor, one feature-flow line, one new test.

Verified

  • Pillow 13.0.0 is on PyPI (uploaded 2026-10-16) with cp313 manylinux_2_28 wheels for x86_64 and aarch64.
  • Every backend call site (utils/image_optimize.py: Image.open, thumbnail(..., Image.LANCZOS), WebP save; services/agent_service/crud.py: Image.open header read, .width/.height) runs on 13.0.0 with warnings set to errors: PNG, WebP and JPEG 1024x768 inputs each produce a 512x384 WebP. No deprecations raised.
  • The # comment inside the RUN pip install continuation matches existing lines in the same block; Docker strips it. prod-image-smoke is green.
  • tests/requirements-test.txt floor >=13.0.0 keeps CI from testing an older Pillow than the image ships.

Execution coverage

changed item executed by live consumer verdict
Pillow==13.0.0 pin prod-image-smoke; new test_install_decodes_a_real_bundled_image_into_a_webp_avatar (pytest (head) green) utils/image_optimize.py::optimize_avatar, crud.py::_install_bundled_avatar_bytes ✅ executed
new test itself, real PNG/WebP bytes, nothing mocked on the image path same ✅ executed; the PR's mutation (JPEG-only Image.open) turns it red

Informational

  • Part of abilityai/trinity-enterprise#1124 carries no closing keyword. That is correct here, since the issue also covers python-jose, the pin manifest and Dependabot. The issue status will not auto-promote on merge.
  • Lane C merge gate: journey-smoke is green on the PR, frontend-e2e was skipped (no ui label). The diff does not touch the frontend; add the ui label if the merge needs that context to be strict.
  • Enterprise member_agents/router.py also imports PIL and was not checked here. It runs in the same image, so prod-image-smoke covers import but not its call path.

Process / security

  • Conventional commits (fix(deps), test(avatar)); targets dev; 4 files.
  • No secrets, emails, IPs, mode changes or host paths in the diff.
  • Tier 1 green; no open dev-ci red issue.

@AndriiPasternak31
AndriiPasternak31 merged commit 8f0d078 into dev Nov 13, 2026
25 checks passed
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