From 8a611c9be1d22c6066418aef8c1b5ffe90afcb9b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 11 Jun 2026 18:03:34 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]=20Fi?= =?UTF-8?q?x=20path=20traversal=20in=20manual=20path=20normalization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- .jules/sentinel.md | 4 ++++ .../flow/src/incremental/extractors/typescript.rs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .jules/sentinel.md diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 00000000..8cbbab43 --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2024-06-11 - [Path Traversal] Improper Manual Path Normalization in TypeScript Extractor +**Vulnerability:** A path traversal vulnerability existed in `crates/flow/src/incremental/extractors/typescript.rs` during manual module path resolution fallback. When resolving `../` components using `std::path::Component::ParentDir`, the code unconditionally popped the last component from the constructed path. This allowed `../` components to pop root directories (`Component::RootDir`), prefixes (`Component::Prefix`), or ignore leading `../` sequences, potentially leading to unauthorized path traversal and incorrect relative path construction. +**Learning:** Manual path normalization is error-prone. In Rust's `std::path::Component` iteration, `Component::ParentDir` must be handled contextually. It should never pop root or prefix components, and if a path starts with `ParentDir` (or only contains `ParentDir`s so far), the `ParentDir` must be explicitly pushed onto the stack to preserve relative navigation, rather than ignored or attempting to pop an empty list. +**Prevention:** When performing manual path component normalization, always match on the last pushed component type. Explicitly block `Component::ParentDir` from popping `RootDir` or `Prefix`, and ensure it is pushed when the list is empty or the last item is also a `ParentDir`. diff --git a/crates/flow/src/incremental/extractors/typescript.rs b/crates/flow/src/incremental/extractors/typescript.rs index 1bdda4ef..3f140692 100644 --- a/crates/flow/src/incremental/extractors/typescript.rs +++ b/crates/flow/src/incremental/extractors/typescript.rs @@ -808,7 +808,18 @@ impl TypeScriptDependencyExtractor { for component in resolved.components() { match component { std::path::Component::ParentDir => { - components.pop(); + if let Some(last) = components.last() { + match last { + std::path::Component::ParentDir => components.push(component), + std::path::Component::Normal(_) => { + components.pop(); + } + // Do not pop RootDir or Prefix + _ => {} + } + } else { + components.push(component); + } } std::path::Component::CurDir => {} _ => components.push(component),