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

🛡️ Sentinel: [CRITICAL/HIGH] Fix path traversal in file download#316

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

🛡️ Sentinel: [CRITICAL/HIGH] Fix path traversal in file download#316
bashandbone wants to merge 1 commit into
mainfrom
sentinel/fix-path-traversal-17825619782213999374

Conversation

@bashandbone

@bashandbone bashandbone commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🚨 Severity: HIGH
💡 Vulnerability: Path traversal in TypeScript module resolution fallback when canonicalize fails. Popping components indiscriminately via ParentDir allowed potential traversal beyond root directories.
🎯 Impact: Allows traversing outside of expected directories when resolving missing or virtual module files.
🔧 Fix: Prevented popping of ParentDir when at root, prefix, or already a ParentDir, ensuring consistent bounds checking and safe pushing of relative path references.
✅ Verification: Tested manual component resolution logic and ran test suites. Also validated against clippy and formatting checks.


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

Summary by Sourcery

Fix path traversal handling in the TypeScript dependency extractor and clean up rule engine variable checking signatures.

Bug Fixes:

  • Harden TypeScript module path normalization to prevent path traversal beyond root or prefixed directories during dependency extraction.

Enhancements:

  • Simplify rule engine variable checking function signatures by removing unnecessary lifetimes from constraint and transform references.

Documentation:

  • Add Sentinel security note documenting the TypeScript extractor path traversal vulnerability, its root cause, and prevention guidance.

This commit fixes a path traversal vulnerability in the TypeScript extractor's manual path resolution logic. It ensures that `std::path::Component::ParentDir` resolution safely handles root, prefix, and leading parent directories without inadvertently erasing boundaries or swallowing components.

Additionally, this commit creates the sentinel journal with learnings and includes a minor valid code clippy lint fix.

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 14, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Fixes a HIGH-severity path traversal bug in the TypeScript dependency extractor’s manual path normalization, and performs small lifetime/borrowing cleanups in rule-engine variable checking plus adds a Sentinel incident note.

File-Level Changes

Change Details Files
Harden manual path normalization to prevent path traversal when handling .. components in TypeScript module resolution fallback.
  • Reworked handling of std::path::Component::ParentDir when iterating over path components during manual resolution.
  • Prevented popping components when the previous component is a root or prefix, or when there is no previous component.
  • Ensured ParentDir components are preserved (pushed) when at the start of a path or after another ParentDir, and only pop a prior non-root/prefix component in other cases.
crates/flow/src/incremental/extractors/typescript.rs
Tighten reference lifetimes and reduce unnecessary generic lifetimes in rule variable checking functions.
  • Adjusted function signatures to take &RapidMap<MetaVariableID, Rule> and &Option<Transform> directly instead of lifetime-parameterized references.
  • Removed unused lifetime parameter from check_var_in_constraints and check_var_in_transform.
  • Kept call sites behaviorally consistent while simplifying borrowing and lifetimes.
crates/rule-engine/src/check_var.rs
Document the Sentinel incident and remediation for the TypeScript extractor path traversal vulnerability.
  • Added a Sentinel markdown entry describing the vulnerability, its root cause in manual path normalization, and prevention guidelines going forward.
.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 manual component normalization logic in the TypeScript extractor is now security-sensitive; consider extracting it into a small helper function with a brief comment about the invariants (never popping RootDir/Prefix, preserving leading ParentDir) to make future modifications safer and easier to reason about.
  • In the ParentDir handling match arm, using a use std::path::Component; import and matching on Component::... variants (possibly with a matches! guard) could improve readability and reduce repetition inside the nested match.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The manual component normalization logic in the TypeScript extractor is now security-sensitive; consider extracting it into a small helper function with a brief comment about the invariants (never popping RootDir/Prefix, preserving leading ParentDir) to make future modifications safer and easier to reason about.
- In the `ParentDir` handling match arm, using a `use std::path::Component;` import and matching on `Component::...` variants (possibly with a `matches!` guard) could improve readability and reduce repetition inside the nested match.

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