Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

🛡️ Sentinel: [CRITICAL] Fix path traversal in module resolution#319

Open
bashandbone wants to merge 1 commit into
mainfrom
sentinel-fix-path-traversal-1715232826389703906
Open

🛡️ Sentinel: [CRITICAL] Fix path traversal in module resolution#319
bashandbone wants to merge 1 commit into
mainfrom
sentinel-fix-path-traversal-1715232826389703906

Conversation

@bashandbone

@bashandbone bashandbone commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

🚨 Severity: CRITICAL
💡 Vulnerability: The TypeScript dependency extractor manually normalized paths when canonicalization failed. By blindly using components.pop() when encountering std::path::Component::ParentDir, it failed to account for situations where .. segments exceed the base path depth or when the root path is absolute. This allows path traversal attacks (e.g., escaping via ../../..).
🎯 Impact: Arbitrary out-of-bounds file reads during AST parsing or module extraction. Malicious users or packages could cause the system to read and expose unintended files outside the root workspace directory.
🔧 Fix: Updated the path normalization logic to emulate lexical canonicalization safely. Explicitly blocked Component::ParentDir from popping Component::RootDir or Component::Prefix, and pushed the new Component::ParentDir instead of ignoring it when the components list is empty or already ends in a ParentDir.
✅ Verification: Ran cargo test -p thread-flow --test extractor_typescript_tests which passed successfully. Confirmed git diff correctly preserved .. segments. All other workspace tests (cargo clippy, cargo test) execute without issues or warnings. Logged findings to .jules/sentinel.md.


PR created automatically by Jules for task 1715232826389703906 started by @bashandbone

Summary by Sourcery

Fix unsafe path normalization in the TypeScript dependency extractor to prevent path traversal during module resolution and document the incident in the Sentinel log.

Bug Fixes:

  • Harden TypeScript module resolution against path traversal by safely handling parent directory components during manual path normalization.

Documentation:

  • Add Sentinel incident entry documenting the path traversal vulnerability, its root cause, and prevention guidance.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai

sourcery-ai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts TypeScript dependency extractor path normalization to safely handle parent directory components and prevent path traversal, and records the vulnerability and fix in the Sentinel log.

File-Level Changes

Change Details Files
Harden path normalization when canonicalization fails to prevent .. components from escaping the root or being dropped unsafely.
  • Replace unconditional components.pop() on Component::ParentDir with logic that inspects the last component before modifying the stack.
  • Preserve leading and consecutive ParentDir components by pushing a new ParentDir when the stack is empty or already ends with ParentDir.
  • Block ParentDir from popping RootDir or Prefix entries, only allowing a pop for normal path segments.
crates/flow/src/incremental/extractors/typescript.rs
Document the discovered path traversal vulnerability, its root cause, and mitigation guidance.
  • Add a Sentinel log entry describing the TypeScript module resolution path traversal issue and its security impact.
  • Capture learnings about the risks of manual path normalization and the correct handling of ParentDir, RootDir, and Prefix components for future prevention.
.jules/sentinel.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The ParentDir handling logic in the normalization loop is now fairly subtle; consider extracting it into a small helper (e.g., fn push_component(...)) with a brief comment describing the intended semantics so future changes don’t accidentally reintroduce traversal issues.
  • You explicitly special-case RootDir and Prefix, but UNC or other platform-specific prefix behaviors can be tricky; it may be worth adding a debug assertion or small invariant check around how Component::Prefix(_) interacts with subsequent components to make those assumptions explicit.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `ParentDir` handling logic in the normalization loop is now fairly subtle; consider extracting it into a small helper (e.g., `fn push_component(...)`) with a brief comment describing the intended semantics so future changes don’t accidentally reintroduce traversal issues.
- You explicitly special-case `RootDir` and `Prefix`, but UNC or other platform-specific prefix behaviors can be tricky; it may be worth adding a debug assertion or small invariant check around how `Component::Prefix(_)` interacts with subsequent components to make those assumptions explicit.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant