Prevent implicit resource loading during validation
fix(adapters): prevent implicit resource loading during validation (#10111)
Prevent implicit resource loading during validationc69136-fix-prevent-implicit-resource-loading-during-validation-cve-2026-72742fixprevent implicit resource loading during validation
Committed by isaacbmiller
commit message
fix(adapters): prevent implicit resource loading during validation (#10111)
* fix(adapters): make resource loading explicit
* test(gepa): update image construction
* refactor(image): name constructor input source
* fix(adapters): fail loudly on ambiguous media constructor inputs
Review follow-ups for the explicit resource loading change:
- Audio positional strings must be data URIs even when audio_format is
passed; the raw-base64 escape hatch silently accepted paths and URLs
that previously loaded implicitly. Raw base64 uses the kwarg form
Audio(data=..., audio_format=...).
- Audio raises TypeError when audio_format accompanies an input that
already carries its format (data URI, dict, Audio), and when
sampling_rate accompanies a non-array input, instead of silently
ignoring the kwarg. The accidental format= alias is gone.
- File raises TypeError when keyword arguments collide with the
positional source, matching Image and Audio, and accepts positional
data URI strings as documented.
- Image.from_file raises ValueError for missing files and encode_image
wraps unidentifiable bytes in ValueError, matching the error contract
of the Audio/File factories. Audio.from_url gains the same verify
parameter as Image.from_url.
- Fix the audio tutorial's Audio(data=..., format=...) call, which used
a kwarg the constructor never accepted.
Co-Authored-By: Claude Fable 5 <[email protected]>
* docs(adapters): document caller-owned SSRF boundary on from_url
from_url performs an explicit, caller-initiated fetch with no SSRF
protection beyond the HTTP(S) scheme check: like requests.get it will
reach private/loopback/metadata hosts and follow redirects. requests
itself documents no such boundary, so state it here — when the URL comes
from untrusted input, validating the host is the caller's responsibility.
Co-Authored-By: Claude Fable 5 <[email protected]>
* feat(image): deprecate download/verify kwargs with a one-release shim
Image(path) stays a hard break: an implicit filesystem read at
construction is the behavior this change removes, so it cannot be
softened without reintroducing it. The error points at Image.from_file.
The download/verify kwargs, however, can be honored without reintroducing
implicit I/O, so accept them for one release with a DeprecationWarning:
download=True eagerly fetches an HTTP(S) source (routing through the same
path as from_url), while download=False/verify are warned and ignored.
This gives users who followed the 3.2.x deprecation guidance a migration
window instead of an immediate ValidationError.
Co-Authored-By: Claude Fable 5 <[email protected]>
* refactor(adapters): make from_path the canonical local-read factory
Local reads were split across two names: File.from_path but
Image.from_file / Audio.from_file. Standardize on from_path across all
three types and keep from_file as a deprecated alias on Image and Audio
for one release. Update the hard-break and data-URI error messages,
docstrings, and API reference to point at from_path.
Co-Authored-By: Claude Fable 5 <[email protected]>
* test(adapters): assert host-I/O boundary on both entry points; polish
- Reframe the resource-loading boundary tests away from the contrived
output-field scenario. Replace the output-field tests with
test_construction_performs_no_host_io (untrusted app input) and
test_validation_performs_no_host_io (the validate_python path adapters
use for LM output and pydantic uses for nested models), each asserting
no open() or requests.get() for any locator-shaped input.
- Pin every deprecation (download/verify, from_file, from_PIL) to removal
in 3.5 so the deprecation plan is concrete.
- Add accepted-input docstrings to Audio and File for parity with Image,
stating the construction/parsing no-I/O boundary and the from_* factories.
Co-Authored-By: Claude Fable 5 <[email protected]>
* chore(adapters): target 3.4 for resource-loading deprecation removals
Co-Authored-By: Claude Fable 5 <[email protected]>
* refactor(image): soften Image(path) to a deprecation instead of a hard break
Right-sizes the change for a low-severity hardening. Constructing Image
from a local file path now warns and still reads the file (removed in
3.4) rather than raising, restoring the common-case ergonomics that 3.2.x
had endorsed. This convenience is reachable only from direct positional
construction; the validation/parse path (untrusted LM output, nested
models) still hard-rejects paths with no filesystem access, which is the
actual security boundary. Audio/File are unchanged (they never accepted
positional paths).
Co-Authored-By: Claude Fable 5 <[email protected]>
* revert(image): hard-break Image(path) instead of the deprecated read
Addresses Greptile's P1 security finding. The softened Image(path)
convenience still read host files in the constructor, leaving a
filesystem-read footgun in a hardening PR. Restore the hard break:
Image(path) raises with a message pointing at Image.from_path(), and the
constructor never stats or opens the filesystem to decide. The
security boundary is now uniform — no constructor or parse path
dereferences a locator.
Co-Authored-By: Claude Fable 5 <[email protected]>
* fix(image): block downloads during validation
* fix(image): make compatibility source positional-only
* docs(adapters): align resource-loading examples
* docs(adapters): add resource-loading migration notes
---------
Co-authored-by: Claude Fable 5 <[email protected]>Editor assessment
This commit patches CVE-2026-72742. The subject is clear, preventing implicit resource loading during validation, and scope adapters fits. The body is unusually thorough, covering error contracts for the Audio, File and Image factories, the caller-owned SSRF boundary on from_url, deprecation shims, and a reversal prompted by a security review that restored a hard break for Image(path). Regression tests assert no open or requests calls during construction and validation. The weakness is packaging: it is a squashed log of internal commit subjects with repeated co-author trailers, so key decisions are buried in an overlong message.