mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-22 19:47:15 +00:00
fix: prevent path traversal in save_text_file
This commit is contained in:
parent
3fa8481ba2
commit
813dfaf375
1 changed files with 1 additions and 1 deletions
|
|
@ -169,7 +169,7 @@ class FileBrowser:
|
|||
raise ValueError("File exceeds 1 MB and cannot be edited")
|
||||
|
||||
full_path = (self.base_dir / file_path).resolve()
|
||||
if not str(full_path).startswith(str(self.base_dir)):
|
||||
if not full_path.is_relative_to(self.base_dir.resolve()):
|
||||
raise ValueError("Invalid path")
|
||||
if full_path.exists() and full_path.is_dir():
|
||||
raise ValueError("Target is a directory")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue