chatchat-space Langchain-Chatchat Path Traversal Vulnerability in Backend Upload Endpoint
Vulnerability
A critical path traversal vulnerability has been identified in the Langchain-Chatchat application by chatchat-space, affecting versions through 0.3.1. The issue arises in the backend component, specifically within the upload_temp_docs function of the knowledge_base/upload_temp_docs file. The vulnerability allows remote attackers to manipulate the flag argument, leading to unauthorized file writing. This exploitation is made possible by the application's failure to properly validate file paths, enabling attackers to traverse directories and overwrite files arbitrarily.
Impact
Exploitation of this vulnerability allows for arbitrary file writing, which could be leveraged to execute malicious code on the server, potentially leading to remote code execution. Additionally, overwriting critical system or application files could disrupt functionality or cause the system to crash.
Reproduction
To reproduce this vulnerability, initialize a Langchain-Chatchat project and start the server. Once the server is running, send a POST request to the /knowledge_base/upload_temp_docs endpoint with a file that includes a path traversal payload, such as ../../../test.txt. The server will respond with a status code indicating success, and the uploaded file will appear in a directory within the project's data folder, demonstrating the path traversal exploit.
Vulnerability Rating
Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.
