NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · LlamaIndex

CVE-2025-6209: LlamaIndex vulnerable to Path Traversal attack through its encode_image function

highCVSS 3.0 7.5GHSA-2rhq-96q8-4vjq

llama-index-core 0.11.23 through 0.12.40 has a path traversal in the encode_image function in generic_utils.py. An attacker who controls the image_path value can make the server read arbitrary files, including system files. Upgrade llama-index-core to 0.12.41.

Published Jul 7, 2025 · Updated Jul 8, 2025 · Analysis Nov 1, 2026

What an attacker can do

encode_image reads the file at image_path and returns its content base64-encoded, for use with multimodal models. The advisory says the path is not properly validated or sanitized, so traversal sequences reach files outside the intended directory. The file bytes come back encoded in the data sent to the model, which an attacker can then read.

The attacker needs a way to set image_path in an application built on LlamaIndex, for example an API that accepts an image path or an ImageDocument built from user input. The CVSS vector shows network access, no privileges and no user interaction, and the impact is confidentiality only. Files such as /etc/passwd, application config, .env files, cloud credentials and SSH keys are all readable if the process can open them.

Multimodal chat services and RAG apps that let end users reference images by path are the most exposed. Apps that only use fixed, developer-chosen image paths are not.

Who is affected

The package data lists llama-index-core from 0.11.23 up to but not including 0.12.41. The meta package llama-index pulls in llama-index-core, so check both.

pip show llama-index-core
pip show llama-index

Search your code for encode_image, ImageDocument and image_path values that come from user input.

llama-index-core

Ecosystem
PyPI
Affected
>= 0.11.23, < 0.12.41
Fixed in
0.12.41
Check
pip show llama-index-core

How to fix it

Upgrade to llama-index-core 0.12.41.

pip install --upgrade "llama-index-core>=0.12.41"

The linked fix commit, cdeaab9, does not touch encode_image and adds no directory restriction. It changes schema.py so ImageDocument raises ValueError when a path or URL is not a valid image, checked with PIL's verify. That limits what a path can return, but it does not confine the path to a folder. In your own code, resolve image paths and require them to sit under an allowed directory before you pass them on.

How to tell if you were hit

Review application logs and request records for image_path or image fields that contain ../ sequences, absolute paths such as /etc or /root, or paths to config and key files. On a patched version, a non-image path raises ValueError from ImageDocument. Look for model responses or stored data that contain base64 of non-image content. Check dependency lockfiles in every service for llama-index-core below 0.12.41.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

A path traversal vulnerability exists in run-llama/llama_index versions 0.11.23 through 0.12.40, specifically within the encode_image function in generic_utils.py. This vulnerability allows an attacker to manipulate the image_path input to read arbitrary files on the server, including sensitive system files. The issue arises due to improper validation or sanitization of the file path, enabling path traversal sequences to access files outside the intended directory. The vulnerability is fixed in version 0.12.41.

Questions

Which llama-index-core versions are affected by CVE-2025-6209?

0.11.23 through 0.12.40. The fixed version is 0.12.41.

Does the fix confine paths to a directory?

Not according to the fix commit we read. It adds image validation to ImageDocument and does not change encode_image. Validate and confine user-supplied paths in your own code as well.

What can the attacker read?

Any file the application process can open, including system files, according to the advisory. The CVSS vector shows high confidentiality impact and no effect on integrity or availability.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More LlamaIndex vulnerabilities

All LlamaIndex entries