Skip to content

Commit

Permalink
path traversal bug in api /knowledge_base/download_doc(#4008) (#4009)
Browse files Browse the repository at this point in the history
close #4008
  • Loading branch information
liunux4odoo committed May 14, 2024
1 parent 703d0f6 commit 2c146af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/knowledge_base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def get_vs_path(knowledge_base_name: str, vector_name: str):


def get_file_path(knowledge_base_name: str, doc_name: str):
return os.path.join(get_doc_path(knowledge_base_name), doc_name)
doc_path = Path(get_doc_path(knowledge_base_name))
file_path = doc_path / doc_name
if file_path.is_relative_to(doc_path):
return str(file_path)


def list_kbs_from_folder():
Expand Down

0 comments on commit 2c146af

Please sign in to comment.