Summary
Exploding Gradients RAGAS v0.2.3 to v0.2.14 contains an arbitrary file read vulnerability in the ImageTextPromptValue class, caused by insufficient validation of URLs passed via the retrieved_contexts parameter for multimodal inputs.
An attacker who can influence these URLs may be able to coerce the application into reading local files on the host system and exposing their contents through the RAG pipeline.
Affected context
This issue arises in applications that integrate RAGAS v0.2.3–v0.2.14 and use the ImageTextPromptValue class with multimodal inputs.
The vulnerable condition is present when retrieved_contexts values are accepted from untrusted or partially trusted sources (such as user input, upstream services, or dynamically constructed URLs) and are used without strict normalization and validation.
In such configurations, URL-like inputs may be interpreted in a way that allows access to local filesystem paths or other unintended resources on the host where the application runs.
Exploit preconditions
- Attack surface: APIs, agents, or workflows that accept or assemble retrieved_contexts for ImageTextPromptValue, particularly where those values are user-controlled or derived from external data.
- Required access: Ability to submit or influence the retrieved_contexts parameter (directly via an API, indirectly via prompt orchestration, or through upstream data sources).
- Trigger point: Construction or evaluation of multimodal ImageTextPromptValue instances that dereference or resolve the supplied URLs/paths.
- Why exploitation is possible: The implementation does not sufficiently validate, canonicalize, or constrain the URL/path inputs, enabling traversal or redirection to local file resources that should not be exposed.
Why this happens
At its core, this is a path traversal / arbitrary file read vulnerability aligned with CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
The ImageTextPromptValue logic processes URLs from retrieved_contexts and appears to accept these values without robust checks on scheme, location, or allowed prefixes.
Without enforcing a strict allowlist (e.g., HTTPS-only remote resources, predefined storage backends) and without normalizing and validating resolved paths, attacker-controlled inputs can be interpreted as local file paths or manipulated to escape intended directories.
This insecure pattern—trusting externally supplied locations or URLs as safe resources without restriction—creates a channel to read arbitrary files on the server.
Potential impact
- Reading sensitive configuration files that may contain credentials, API keys, or connection strings.
- Access to environment files, logs, or model configuration data that could aid further attacks.
- Exposure of proprietary model artifacts or prompt templates stored on disk.
- Disclosure of user-specific or tenant-specific data if stored alongside the application.
- Indirect facilitation of further compromise by leaking secrets usable in lateral movement.
General mitigation guidance
Effective mitigation focuses on constraining what retrieved_contexts can reference and treating location-like inputs as untrusted:
- Enforce strict scheme and domain allowlists for URLs used by ImageTextPromptValue (e.g., only HTTPS, only specific trusted hosts or storage buckets).
- Avoid treating unqualified strings as filesystem paths; when file-based contexts are needed, map them through a controlled abstraction instead of raw paths.
- Normalize and validate all paths before use, ensuring they resolve within a predefined, restricted directory and rejecting any inputs that traverse outside it.
- Separate privileges: run the RAG application with a minimally privileged account and restrict filesystem read access to only those directories required for operation.
- Centralize input validation: ensure that any code constructing retrieved_contexts applies consistent validation, rather than ad‑hoc checks in multiple places.
How teams detect issues like this
Organizations can approach detection by combining code-level analysis and behavioral monitoring:
- Static analysis / SAST:
- Flag code that passes user-controlled or external strings into file-opening or URL-fetch APIs without prior validation or normalization.
- Identify usages of ImageTextPromptValue or similar multimodal components where retrieved_contexts is sourced from request data or unvalidated external inputs.
- Code review signals:
- Any logic that dynamically builds URLs or paths for RAG contexts should trigger review for scheme, host, and path constraints.
- Look for missing allowlists, missing canonicalization, or absence of checks that ensure inputs stay within a safe directory or trusted origin set.
- Runtime and logging:
- Instrument file access or URL fetch layers to record unexpected schemes, localhost access patterns, or attempts to access sensitive paths.
- Correlate anomalous file reads (e.g., /etc/, application secrets, environment files) with specific API calls that provide retrieved_contexts.
Automated review tools or custom linters can be configured to highlight risky patterns such as path-derived from request parameters, especially around the RAG pipeline.

