Skip to content

Validate Arrow structures in fromarrow() - #10350

Open
aclark4life wants to merge 9 commits into
mainfrom
arrow-null-checks
Open

aclark4life wants to merge 9 commits into
mainfrom
arrow-null-checks

Conversation

@aclark4life

@aclark4life aclark4life commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Image.fromarrow() currently trusts the Arrow C Data Interface structures it is given. If a producer passes NULL pointers, the process crashes with a segfault. This PR adds defensive checks to those cases so they raise ValueError instead of crashing:

  • schema->format is NULL
  • the array has one child, but children or children[0] is NULL
  • buffers or buffers[1] is NULL
  • the array has a negative offset
  • the schema is +w:4, but children[0] or its format is NULL

Raise ValueError instead of crashing for malformed Arrow C Data Interface
structures with a NULL format, buffers or children, or a negative offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@radarhere radarhere added the 🤖-assisted AI-assisted label Oct 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aclark4life
aclark4life marked this pull request as ready for review October 29, 2026 02:21
@radarhere
radarhere requested a review from wiredfool October 29, 2026 02:21
@aclark4life aclark4life added the Arrow Apache Arrow support (fromarrow, __arrow_c_array__) label Oct 29, 2026
Comment thread docs/releasenotes/13.1.0.rst Outdated

:py:func:`~PIL.Image.fromarrow` now raises a :py:exc:`ValueError` for some
malformed Arrow structures, such as missing formats, buffers or children, or a
negative offset, rather than crashing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While this is a helpful change, my feeling would be that it's not a vulnerability, and users with correct code don't need to change their behaviour, so we don't need to tell everyone about it in the release notes?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted Arrow Apache Arrow support (fromarrow, __arrow_c_array__)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants