/

CVE-2026-51883

Severity:

CRITICAL RISK

(9.1)

Path Traversal (CWE-22) in Langchain-Chatchat Upload

CVE-2026-51883

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write

Severity:

CRITICAL RISK

(9.1)

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

A path traversal vulnerability in Langchain-Chatchat allows crafted knowledge base names to escape the configured knowledge base directory. An attacker who can reach the knowledge base creation or document upload interfaces may write content to arbitrary filesystem locations accessible to the application.

A path traversal vulnerability in Langchain-Chatchat allows crafted knowledge base names to escape the configured knowledge base directory. An attacker who can reach the knowledge base creation or document upload interfaces may write content to arbitrary filesystem locations accessible to the application.

Affected context

The vulnerability occurs in the knowledge base creation and document upload interfaces of Langchain-Chatchat versions 0.3.0 and 0.3.1. It becomes risky when the application uses user-controlled knowledge base names in filesystem paths without reliably constraining the resolved path to the configured knowledge base root directory.

The vulnerability occurs in the knowledge base creation and document upload interfaces of Langchain-Chatchat versions 0.3.0 and 0.3.1. It becomes risky when the application uses user-controlled knowledge base names in filesystem paths without reliably constraining the resolved path to the configured knowledge base root directory.

Exploit preconditions

  • Attack surface: Knowledge base creation and document upload interfaces
  • Required access: Ability to submit requests to an exposed interface; authentication requirements depend on deployment configuration
  • Trigger point: Processing of the knowledge_base_name parameter when constructing a storage path
  • Why exploitation is possible: Traversal sequences can cause the resolved destination to fall outside the intended knowledge base root
  • Attack surface: Knowledge base creation and document upload interfaces
  • Required access: Ability to submit requests to an exposed interface; authentication requirements depend on deployment configuration
  • Trigger point: Processing of the knowledge_base_name parameter when constructing a storage path
  • Why exploitation is possible: Traversal sequences can cause the resolved destination to fall outside the intended knowledge base root

Why this happens

The underlying bug is improper neutralization of path traversal elements in a user-controlled path component. When knowledge_base_name is incorporated into filesystem operations without canonicalization and confinement checks, traversal sequences such as ..\ may alter the final resolved path. This behavior maps to CWE-22, Improper Limitation of a Pathname to a Restricted Directory.

The underlying bug is improper neutralization of path traversal elements in a user-controlled path component. When knowledge_base_name is incorporated into filesystem operations without canonicalization and confinement checks, traversal sequences such as ..\ may alter the final resolved path. This behavior maps to CWE-22, Improper Limitation of a Pathname to a Restricted Directory.

Potential impact

  • An attacker may write knowledge base or document content outside the intended storage directory.
  • Sensitive files could be overwritten or corrupted if the process has sufficient permissions.
  • Application integrity could be affected through unauthorized file placement.
  • The vulnerability could contribute to code execution or broader host compromise where written files are later trusted or executed.
  • An attacker may write knowledge base or document content outside the intended storage directory.
  • Sensitive files could be overwritten or corrupted if the process has sufficient permissions.
  • Application integrity could be affected through unauthorized file placement.
  • The vulnerability could contribute to code execution or broader host compromise where written files are later trusted or executed.

General mitigation guidance

Mitigation generally focuses on treating knowledge base names as identifiers

rather than filesystem paths and enforcing directory confinement.

Common defensive patterns include:

  • Allowlisting safe characters and formats for user-controlled names.
  • Canonicalizing paths and verifying that the resolved destination remains within the configured root.
  • Constructing storage paths with trusted identifiers or managed object storage keys.
  • Separating uploaded content from executable and application configuration directories.
  • Applying least-privilege filesystem permissions to the service account.
  • Using filesystem policies and sandboxing to limit the consequences of unauthorized writes.
  • Centralizing path-validation logic so all upload and knowledge base operations use the same controls.

Mitigation generally focuses on treating knowledge base names as identifiers

rather than filesystem paths and enforcing directory confinement.

Common defensive patterns include:

  • Allowlisting safe characters and formats for user-controlled names.
  • Canonicalizing paths and verifying that the resolved destination remains within the configured root.
  • Constructing storage paths with trusted identifiers or managed object storage keys.
  • Separating uploaded content from executable and application configuration directories.
  • Applying least-privilege filesystem permissions to the service account.
  • Using filesystem policies and sandboxing to limit the consequences of unauthorized writes.
  • Centralizing path-validation logic so all upload and knowledge base operations use the same controls.

How teams detect issues like this

Organizations can look for path traversal risks through:

  • Static analysis rules that flag user input passed into filesystem path construction.
  • Code review checks for concatenation or joining of untrusted values without canonicalization and root-boundary validation.
  • Runtime monitoring for requests containing traversal markers, encoded separators, or unusual path normalization patterns.
  • File-integrity monitoring for writes outside approved knowledge base directories.
  • Policy enforcement that restricts service processes from writing to sensitive or executable locations.
  • Automated security review tools that identify unsafe path handling patterns during development.

Organizations can look for path traversal risks through:

  • Static analysis rules that flag user input passed into filesystem path construction.
  • Code review checks for concatenation or joining of untrusted values without canonicalization and root-boundary validation.
  • Runtime monitoring for requests containing traversal markers, encoded separators, or unusual path normalization patterns.
  • File-integrity monitoring for writes outside approved knowledge base directories.
  • Policy enforcement that restricts service processes from writing to sensitive or executable locations.
  • Automated security review tools that identify unsafe path handling patterns during development.

Sources

SourceLink
gist.github.comgist.github.com/Ro1ME/30f5139a2920bf7075299a33eb1690f2
github.comgithub.com/chatchat-space/Langchain-Chatchat/issues/5467

Frequently asked

questions

It may be remotely exploitable when the affected knowledge base or document

upload interfaces are network-accessible and accept attacker-controlled

knowledge_base_name values.

The attacker needs access to the relevant interface. Whether authentication

or authorization is required depends on how the Langchain-Chatchat service

is deployed and protected.

Treat user-provided names as opaque identifiers, apply strict allowlisting,

canonicalize the resulting path, and confirm that it remains inside the

intended storage root before writing.

Use centralized path-confinement utilities, least-privilege filesystem

permissions, isolated upload storage, negative-path testing, and monitoring

for writes outside approved directories.

It may be remotely exploitable when the affected knowledge base or document

upload interfaces are network-accessible and accept attacker-controlled

knowledge_base_name values.

The attacker needs access to the relevant interface. Whether authentication

or authorization is required depends on how the Langchain-Chatchat service

is deployed and protected.

Treat user-provided names as opaque identifiers, apply strict allowlisting,

canonicalize the resulting path, and confirm that it remains inside the

intended storage root before writing.

Use centralized path-confinement utilities, least-privilege filesystem

permissions, isolated upload storage, negative-path testing, and monitoring

for writes outside approved directories.

Find out what's already
exploitable in your codebase.