You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vulnerability #1: Path Traversal in save_download_file (CBD-B5)
Location: src/backend/bisheng/core/cache/utils.py:290-349 Entry Point: src/backend/bisheng/api/v1/workstation.py:177 (knowledgeUpload endpoint) CWE: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) CVSS 3.1: 9.1 (Critical)
Vulnerable Code
@create_cache_folderdefsave_download_file(file_input: Union[bytes, BinaryIO], folder_name: str, filename: str) ->str:
""" Synchronous I/O intensive tasks: Write data stream to a temporary file Simultaneously calculate SHA256 Rename a file based on the hash """# Convert to stream objectsifisinstance(file_input, bytes):
src_stream=BytesIO(file_input)
else:
src_stream=file_inputifhasattr(src_stream, 'seek'):
src_stream.seek(0)
# Prepare a temporary filecache_path=Path(CACHE_DIR)
folder_path=cache_path/folder_name# Create the folder if it doesn't existifnotfolder_path.exists():
folder_path.mkdir(exist_ok=True)
temp_filename=f"tmp_{uuid4().hex}"temp_file_path=folder_path/temp_filenamesha256_hash=hashlib.sha256()
try:
# Write to temporary file and calculate SHA256 simultaneouslywithopen(temp_file_path, 'wb') asdst_file:
chunk_size=65536# 64KBwhileTrue:
chunk=src_stream.read(chunk_size)
ifnotchunk:
breaksha256_hash.update(chunk)
dst_file.write(chunk)
# calculate final hashfile_hash=sha256_hash.hexdigest()
# Logic for handling filename length limitssafe_filename=filenameiflen(filename) >60:
safe_filename=filename[-60:] # VULNERABILITY: Takes last 60 chars, preserves path traversalfinal_file_name=f'{file_hash}_{safe_filename}'# VULNERABILITY: No path validationfinal_file_path=folder_path/final_file_name# Path traversal possible here# Rename (Move) Temporary File to Final Pathiffinal_file_path.exists():
os.remove(temp_file_path)
returnstr(final_file_path)
shutil.move(str(temp_file_path), str(final_file_path)) # VULNERABILITY: Moves to traversed pathreturnstr(final_file_path)
Root Cause: The filename parameter from user upload is used directly without sanitization. When constructing final_file_path = folder_path / final_file_name, if final_file_name contains path traversal sequences like ../../, the resulting path can escape the intended cache directory.
Vulnerability #2: Path Traversal in _download_file (CBD-B5)
Location: src/backend/bisheng/linsight/domain/task_exec.py:225-246 CWE: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) CVSS 3.1: 9.1 (Critical)
Root Cause: The file_name from file_info dictionary (which can be user-controlled via workflow configuration) is directly joined with target_dir using os.path.join(). If file_name contains path traversal sequences, the file will be written outside the intended directory.
Proof of Concept
PoC #1: Exploiting save_download_file via knowledgeUpload
Severity: Critical
CVSS Score: 9.1 (Vulnerabilities #1, #2)
Affected Versions: Latest version (as of 2026-04-20)
Attack Vector: Network (HTTP API)
Vulnerability Count:2
Vulnerability Details
Vulnerability #1: Path Traversal in save_download_file (CBD-B5)
Location:
src/backend/bisheng/core/cache/utils.py:290-349Entry Point:
src/backend/bisheng/api/v1/workstation.py:177(knowledgeUpload endpoint)CWE: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)
CVSS 3.1: 9.1 (Critical)
Vulnerable Code
Root Cause: The
filenameparameter from user upload is used directly without sanitization. When constructingfinal_file_path = folder_path / final_file_name, iffinal_file_namecontains path traversal sequences like../../, the resulting path can escape the intended cache directory.HTTP API Entry Point
Vulnerability #2: Path Traversal in _download_file (CBD-B5)
Location:
src/backend/bisheng/linsight/domain/task_exec.py:225-246CWE: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)
CVSS 3.1: 9.1 (Critical)
Vulnerable Code
Root Cause: The
file_namefromfile_infodictionary (which can be user-controlled via workflow configuration) is directly joined withtarget_dirusingos.path.join(). Iffile_namecontains path traversal sequences, the file will be written outside the intended directory.Proof of Concept
PoC #1: Exploiting save_download_file via knowledgeUpload
Expected Result: File written to
/tmp/bisheng_pwned.phpinstead of cache directory.Verification:
ls -la /tmp/bisheng_pwned.php # File should exist outside the cache directoryPoC #2: Exploiting _download_file via Linsight Workflow
Expected Result: File downloaded to
/tmp/linsight_pwned.txtinstead of workflow directory.Impact
Security Impact
Arbitrary File Write (Vulnerabilities add langchain_contrib module #2, Add bisheng-unstructured submodule #3):
Configuration Tampering:
Privilege Escalation:
Data Integrity: