From d28aab82f2dd45158e6fda775e92b01d802a3d77 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 3 Jul 2026 09:52:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITICAL]?= =?UTF-8?q?=20Fix=20Path=20Traversal=20in=20API=20Files=20Get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: thirdeyenation <133812267+thirdeyenation@users.noreply.github.com> --- .jules/sentinel.md | 4 ++++ api/api_files_get.py | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 .jules/sentinel.md diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 0000000000..ccec0563fc --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2024-05-24 - [Path Traversal in API Files Get] + **Vulnerability:** Unrestricted file path loading in `/api/files/get` allowing users to read any file on the machine like `/etc/passwd`. + **Learning:** Paths weren't validated against the application's base directory before reading them to standard response outputs. + **Prevention:** Use explicit checks like `files.is_in_base_dir(external_path)` to ensure paths cannot traverse outside intended bounds. diff --git a/api/api_files_get.py b/api/api_files_get.py index b2533f4f4f..ec24d570b9 100644 --- a/api/api_files_get.py +++ b/api/api_files_get.py @@ -62,6 +62,11 @@ async def process(self, input: dict, request: Request) -> dict | Response: external_path = path filename = os.path.basename(path) + # Security: Prevent path traversal + if not files.is_in_base_dir(external_path): + PrintStyle.warning(f"Access denied to file outside base dir: {path}") + continue + # Check if file exists if not os.path.exists(external_path): PrintStyle.warning(f"File not found: {path}")