From bcd33488b6514fcbf7c5268d33438d05c4013949 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 28 Jun 2026 09:19:07 +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=20Endpoint?= 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..da2e923b23 --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2025-06-28 - [Path Traversal in API Files Get Endpoint] +**Vulnerability:** Path traversal vulnerability in API endpoint `api/api_files_get.py`. The `paths` array allowed retrieving files outside of the intended directories when path traversal elements (e.g. `../../../`) are provided in the path or filename. +**Learning:** `files.get_abs_path()` and `os.path.basename()` alone do not resolve paths safely against path traversal if malicious components bypass `basename()` or traverse out after `get_abs_path` resolves. A strict boundary check must be explicitly made. +**Prevention:** Always validate that the final resolved absolute path is within the intended base directory using `files.is_in_base_dir(external_path)`. diff --git a/api/api_files_get.py b/api/api_files_get.py index b2533f4f4f..fbd6f1d625 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 check: Ensure the path is within the base directory + if not files.is_in_base_dir(external_path): + PrintStyle.warning(f"Access denied. Path is outside of base directory: {path}") + continue + # Check if file exists if not os.path.exists(external_path): PrintStyle.warning(f"File not found: {path}")