/

CVE-2026-72742

Severity:

HIGH RISK

(8.6)

Arbitrary File Read (CWE-73) in DSPy Media Adapters

CVE-2026-72742

Awaiting Analysis

Vulnerability type

Category:

External Control of File Name or Path

CWE:

CWE-73

Impact:

Arbitrary Local File Disclosure

Severity:

HIGH RISK

(8.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

DSPy 3.3.0b1 contains a file exfiltration vulnerability in Image and Audio output field adapters. When an attacker can influence language model output and that output is parsed as a typed media value, a filesystem path may cause a local file to be read, encoded, and sent to the model endpoint.

Affected context

The vulnerability occurs in DSPy workflows that parse untrusted language model completions through the JSONAdapter or ChatAdapter and validate Image or Audio output fields. Risk is present when the parsed media value permits a URL-like field to reference a local filesystem path and the runtime process can read that path. The resulting file data may be embedded in outgoing prompt messages sent to a model endpoint.

Exploit preconditions

  • Attack surface: Language model output parsing and media field adaptation
  • Required access: Ability to influence, directly or indirectly, the completion returned to the DSPy application
  • Trigger point: Parsing and type validation of an Image or Audio output value
  • Required runtime condition: The application process must have read access to the referenced local file
  • Why exploitation is possible: Media encoding treats a user-influenced path as a candidate local file, reads matching files, and includes their encoded contents in a subsequent outbound request

Why this happens

The underlying bug is insufficient separation between externally controlled media references and local filesystem paths. During output parsing, validation reaches image or audio encoding logic that checks whether the supplied path exists as a local file and then reads and base64-encodes it. This behavior maps to CWE-73: External Control of File Name or Path, because data influenced by an external source determines which local filesystem object is accessed without an adequate trust boundary or path restriction.

Potential impact

  • Sensitive application files may be disclosed to an attacker-controlled or attacker-influenced model endpoint
  • Credentials, configuration data, source code, or other readable secrets could be exposed
  • Outbound prompts may contain base64-encoded contents from unintended local files
  • Model-provider logs, traces, or downstream integrations may retain the exfiltrated data
  • The application process could experience resource or privacy impacts from repeated file reads

General mitigation guidance

Mitigation generally focuses on preventing untrusted model output from selecting local filesystem resources.

Common defensive patterns include:

  • Treating model-generated paths and media URLs as untrusted data rather than local file references
  • Allowing only explicitly supported remote media schemes or validated application-managed identifiers
  • Applying canonicalization, allowlisting, and containment checks when local media access is an intentional feature
  • Separating media fetching from model-output parsing and requiring an explicit authorization decision
  • Limiting process permissions and restricting access to sensitive directories
  • Redacting or blocking local file contents from outbound prompt construction
  • Enforcing outbound network and model-endpoint policies that reduce unintended data transfer

How teams detect issues like this

Detection approaches can include:

  • Static analysis for model-output fields flowing into filesystem APIs such as file existence checks, open operations, or media encoders
  • Code review searches for path or URL values reaching image and audio conversion routines without scheme, origin, or containment validation
  • Tests using controlled model completions that reference canary files and verifying that no local contents appear in outbound requests
  • Runtime telemetry for unexpected local file reads during response parsing and for unusually large or high-entropy prompt fields
  • Policy enforcement that restricts media inputs to approved schemes, directories, or application-managed object references
  • Automated security review tools configured to flag external data reaching filesystem access functions

Sources

SourceLink
github.comgithub.com/stanfordnlp/dspy
github.comgithub.com/stanfordnlp/dspy/commit/c69136b29aca4c00ca6da7667f7b80783188980e
github.comgithub.com/stanfordnlp/dspy/issues/10067
vulncheck.comvulncheck.com/advisories/dspy-0b1-local-file-read-via-image-audio-output-field-parsing

Frequently asked

questions

It can be exploitable through a remote or semi-remote model interaction when an attacker can influence language model output that the DSPy application parses. The attacker generally does not need direct filesystem access.

The attacker needs a way to affect the completion consumed by the vulnerable adapter. The application process must also have permission to read the targeted file, and the resulting request must reach an endpoint capable of receiving the data.

Do not allow untrusted model-generated values to select local filesystem paths. Prefer approved media schemes or opaque, application-controlled references, with explicit authorization and containment checks for any intentional local access.

Treat model output as untrusted input, review all flows from parsed output to filesystem and network operations, apply least-privilege file permissions, and test outbound requests for accidental inclusion of local file contents.

Find out what's already
exploitable in your codebase.