🛡️ Sentinel: [HIGH] Fix path traversal in manual path normalization#271
🛡️ Sentinel: [HIGH] Fix path traversal in manual path normalization#271bashandbone wants to merge 1 commit into
Conversation
- Updated `resolve_module_path` manual path normalization to safely handle `Component::ParentDir`. - Prevents popping `RootDir` or `Prefix` components during manual canonicalization of non-existent paths. 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 manual path normalization in the TypeScript dependency extractor to safely handle File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull request overview
Fixes a path-traversal-style bug in TypeScriptDependencyExtractor::resolve_module_path's manual fallback normalization (used when canonicalize() fails for relative imports). Previously, .. components were blindly popped, which could remove RootDir/Prefix components and produce incorrect paths or escape intended directories. The match arm now checks the previous component before popping. A .jules/sentinel.md note documents the lesson.
Changes:
- Replace unconditional
components.pop()forParentDirwith a guarded handler that preservesRootDir/Prefix, accumulatesParentDirwhen at start or after anotherParentDir, and otherwise pops the last component. - Add
.jules/sentinel.mddocumenting the vulnerability, learning, and prevention guidance.
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 | Safer ParentDir normalization in manual fallback for unresolved relative imports. |
| .jules/sentinel.md | New lesson-log entry describing the bug and prevention. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,4 @@ | |||
| ## 2024-05-18 - [Path Traversal in Manual Path Resolution] | |||
🚨 Severity: HIGH
💡 Vulnerability: The manual path normalization for unresolved paths in
crates/flow/src/incremental/extractors/typescript.rsincorrectly poppedstd::path::Component::ParentDirfrom the components list regardless of the previous component. This could popRootDirorPrefixcomponents, leading to path traversal vulnerabilities and incorrect path resolution for multiple..segments.🎯 Impact: An attacker could potentially use maliciously crafted import paths with multiple
..segments to traverse out of the intended directory and access sensitive files, especially when manual canonicalization is triggered for non-existent or unresolvable paths.🔧 Fix: Updated the
Component::ParentDirmatch arm to safely handle popping components. It now ignoresParentDirif the last component isRootDirorPrefix, pushesParentDirif the components list is empty or the last component is also aParentDir, and otherwise safely pops the last directory.✅ Verification: Ran
cargo test -p thread-flow --test extractor_typescript_teststo verify no functionality is broken and path resolutions succeed correctly.PR created automatically by Jules for task 10888592995321208738 started by @bashandbone
Summary by Sourcery
Harden manual path normalization in the TypeScript dependency extractor to prevent unsafe handling of parent directory components in module path resolution.
Bug Fixes:
ParentDircomponents when normalizing unresolved module paths.Documentation: