From 08ee45b4c4146ee0a17466e6cb0f770d362ea6d2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 11 May 2026 10:12:20 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITICAL]?= =?UTF-8?q?=20Fix=20Path=20Traversal=20in=20ApiFilesGet?= 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..bfe964669d --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2024-10-24 - Fix Path Traversal in ApiFilesGet + **Vulnerability:** Path traversal in `api/api_files_get.py` allowed arbitrary file reading outside of the base directory via manipulated input paths (e.g. starting with `/a0/../../`). + **Learning:** When converting internal virtual paths to physical paths on the file system, standard normalization handles `..` but can resolve to directories completely outside the expected application root. + **Prevention:** Always use a base directory check function (like `files.is_in_base_dir()`) immediately before acting on any user-provided or user-manipulated file path to restrict access boundaries. diff --git a/api/api_files_get.py b/api/api_files_get.py index b2533f4f4f..0df7900719 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 path is within base directory to prevent path traversal + if not files.is_in_base_dir(external_path): + PrintStyle.warning(f"Security: Path traversal attempt blocked for path: {path}") + continue + # Check if file exists if not os.path.exists(external_path): PrintStyle.warning(f"File not found: {path}")