Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL/HIGH] Fix path traversal#280

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

πŸ›‘οΈ Sentinel: [CRITICAL/HIGH] Fix path traversal#280
bashandbone wants to merge 1 commit into
mainfrom
sentinel/fix-path-traversal-10333070984827272800

Conversation

@bashandbone
Copy link
Copy Markdown
Contributor

@bashandbone bashandbone commented May 31, 2026

  • 🚨 Severity: CRITICAL
  • πŸ’‘ Vulnerability: Path traversal during manual path resolution in TypeScript extractor.
  • 🎯 Impact: Allows arbitrary path traversal which could lead to accessing files outside the expected directory.
  • πŸ”§ Fix: Updated the manual path resolution to properly handle Component::ParentDir according to security guidelines.
  • βœ… Verification: Tests and lint checks pass.

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

Summary by Sourcery

Harden manual path resolution in the TypeScript dependency extractor to prevent path traversal escapes and document the vulnerability and remediation steps.

Bug Fixes:

  • Prevent Component::ParentDir from popping root or prefix components during manual path resolution to avoid directory traversal outside the allowed base path.

Documentation:

  • Add a Sentinel security note documenting the TypeScript extractor path traversal vulnerability, its root cause, and secure handling guidelines for ParentDir components.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 31, 2026 17:54
@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
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 31, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts manual path resolution in the TypeScript dependency extractor to prevent directory traversal escapes and documents the vulnerability and fix in a Sentinel note.

File-Level Changes

Change Details Files
Harden manual ParentDir handling in TypeScript dependency path resolution to prevent traversal escapes beyond root/prefix.
  • Replace unconditional pop on encountering ParentDir with logic that inspects the last accumulated component.
  • Disallow ParentDir from popping RootDir or Prefix components to avoid escaping the filesystem root or drive prefix.
  • Preserve or accumulate ParentDir components when the stack is empty or already ends with ParentDir, and only pop for normal path components.
crates/flow/src/incremental/extractors/typescript.rs
Document the path traversal vulnerability, underlying cause, and prevention guidelines in a Sentinel note.
  • Add a Sentinel markdown entry describing the original vulnerability in manual path resolution.
  • Capture learnings around correct handling of ParentDir and use of PathBuf::canonicalize.
  • Document prevention guidelines for future manual path resolution logic in Rust.
.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

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="crates/flow/src/incremental/extractors/typescript.rs" line_range="811-817" />
<code_context>
                     match component {
                         std::path::Component::ParentDir => {
-                            components.pop();
+                            let last = components.last();
+                            match last {
+                                Some(std::path::Component::RootDir)
+                                | Some(std::path::Component::Prefix(_)) => {
+                                    // Do not pop RootDir or Prefix to prevent traversal escapes
+                                }
+                                Some(std::path::Component::ParentDir) | None => {
+                                    components.push(component);
+                                }
</code_context>
<issue_to_address>
**🚨 question (security):** Re-check intended behavior for leading `..` components when normalizing paths.

Because `pop()` on an empty `components` was a no-op, leading `ParentDir` segments were previously discarded. Now, when `last` is `None`, they are preserved (e.g. `../foo` remains `../foo`). If this function is used as part of a security boundary (e.g., to enforce confinement under a root), preserving leading `..` could reintroduce traversal concerns. Please confirm whether callers rely on this to yield a path guaranteed under a root, or whether leading `..` is expected and validated elsewhere.
</issue_to_address>

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.

Comment on lines +811 to +817
let last = components.last();
match last {
Some(std::path::Component::RootDir)
| Some(std::path::Component::Prefix(_)) => {
// Do not pop RootDir or Prefix to prevent traversal escapes
}
Some(std::path::Component::ParentDir) | None => {
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.

🚨 question (security): Re-check intended behavior for leading .. components when normalizing paths.

Because pop() on an empty components was a no-op, leading ParentDir segments were previously discarded. Now, when last is None, they are preserved (e.g. ../foo remains ../foo). If this function is used as part of a security boundary (e.g., to enforce confinement under a root), preserving leading .. could reintroduce traversal concerns. Please confirm whether callers rely on this to yield a path guaranteed under a root, or whether leading .. is expected and validated elsewhere.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens TypeScript module path normalization in the incremental dependency extractor and adds a Sentinel note documenting the path traversal issue and mitigation.

Changes:

  • Updates manual ParentDir handling to avoid popping root/prefix components and to preserve leading .. components.
  • Documents the vulnerability, learning, and prevention guidance in .jules/sentinel.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/flow/src/incremental/extractors/typescript.rs Adjusts unresolved path component normalization for TypeScript/JavaScript imports.
.jules/sentinel.md Adds a security note describing the path traversal remediation.

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 810 to +823
std::path::Component::ParentDir => {
components.pop();
let last = components.last();
match last {
Some(std::path::Component::RootDir)
| Some(std::path::Component::Prefix(_)) => {
// Do not pop RootDir or Prefix to prevent traversal escapes
}
Some(std::path::Component::ParentDir) | None => {
components.push(component);
}
_ => {
components.pop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants