š”ļø Sentinel: [HIGH] Fix path traversal in manual path normalization#196
š”ļø Sentinel: [HIGH] Fix path traversal in manual path normalization#196bashandbone wants to merge 1 commit intomainfrom
Conversation
Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
|
š 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes a high-severity path traversal issue in the TypeScript dependency extractorās manual path normalization by making ParentDir handling aware of stack state and filesystem roots, and documents the incident in the Sentinel log. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
ParentDirhandling logic is fairly subtle; consider extracting it into a small helper function (e.g.,push_parent_dir_component(...)) or adding a short inline comment to document the intended behaviors for root/prefix/relative cases to make future maintenance easier. - Right now
ParentDircomponents that would escape a root/prefix are silently dropped; if this is security-critical, consider whether propagating an explicit error or signaling this condition would make misuse less likely than silently clamping the path.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `ParentDir` handling logic is fairly subtle; consider extracting it into a small helper function (e.g., `push_parent_dir_component(...)`) or adding a short inline comment to document the intended behaviors for root/prefix/relative cases to make future maintenance easier.
- Right now `ParentDir` components that would escape a root/prefix are silently dropped; if this is security-critical, consider whether propagating an explicit error or signaling this condition would make misuse less likely than silently clamping the path.Help me be more useful! Please click š or š on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Fixes a HIGH-severity path traversal issue in the TypeScript extractorās fallback (non-canonicalize()) path normalization logic, and records the incident/learning in Jules Sentinel notes.
Changes:
- Update manual
..normalization to avoid silently dropping leadingParentDircomponents. - Add
.jules/sentinel.mdentry documenting the vulnerability, learning, and prevention guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/flow/src/incremental/extractors/typescript.rs | Adjusts manual path component reduction logic for .. handling when canonicalize() fails. |
| .jules/sentinel.md | Adds a Sentinel note describing the traversal vulnerability and prevention guidance. |
š” Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| std::path::Component::ParentDir => match components.last() { | ||
| Some(std::path::Component::ParentDir) | None => { | ||
| components.push(component) | ||
| } | ||
| Some(std::path::Component::RootDir) | ||
| | Some(std::path::Component::Prefix(_)) => {} | ||
| _ => { | ||
| components.pop(); | ||
| } | ||
| }, |
| let mut components = Vec::new(); | ||
| for component in resolved.components() { | ||
| match component { | ||
| std::path::Component::ParentDir => { | ||
| components.pop(); | ||
| } | ||
| std::path::Component::ParentDir => match components.last() { | ||
| Some(std::path::Component::ParentDir) | None => { |
šØ Severity: HIGH
š” Vulnerability: The
typescriptextractor manual path normalization (used whencanonicalize()fails) suffered from a path traversal flaw. When reducing../(ParentDir) segments by popping from a vector of path components, thepop()method returned silently if the vector was empty. Consequently, paths starting with../lost those parent directory components, incorrectly anchoring relative references locally or resulting in unintended, out-of-bounds filesystem access attempts outside the original root directory.šÆ Impact: An attacker could craft a dependency graph with
../imports causing arbitrary reads out-of-bounds.š§ Fix: Adjusted the manual normalization loop to track and push
../components when safe (e.g. at the start of a relative path), ignore them at filesystem roots, and safely pop otherwise.ā Verification: Verified that
../references behave correctly mathematically and pass all tests viacargo test -p thread-flow --test extractor_typescript_tests.PR created automatically by Jules for task 157728989311240504 started by @bashandbone
Summary by Sourcery
Fix unsafe manual path normalization in the TypeScript dependency extractor to correctly handle parent directory components and prevent path traversal.
Bug Fixes:
Documentation: