🛡️ Sentinel: [CRITICAL] Fix path traversal#313
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 GuideFixes a critical path traversal vulnerability in the TypeScript incremental extractor by hardening manual path normalization, alongside small API ergonomics and formatting cleanups in the rule engine, AST engine, and tests, plus adding a Sentinel security learning note. Flow diagram for updated ParentDir path normalization in TypeScriptDependencyExtractorflowchart TD
A["Component::ParentDir encountered"] --> B{"components.last() is Some(Component::Normal)"}
B -->|yes| C["components.pop()"]
B -->|no| D["components.push(Component::ParentDir)"]
C --> E["continue components() iteration"]
D --> E["continue components() iteration"]
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
ParentDirhandling change intypescript.rsis an improvement, but you may want to make the behavior for root/prefix components explicit (e.g., match onRootDir/Prefixand document why they are never popped) so the security invariants are obvious and future refactors don’t unintentionally change them. - Consider extracting the manual path normalization logic into a small helper function with a clear contract (e.g., "never escape root or prefix, preserve leading ../ segments") so its behavior is easier to reason about and reuse in other places that might need similar traversal protection.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `ParentDir` handling change in `typescript.rs` is an improvement, but you may want to make the behavior for root/prefix components explicit (e.g., match on `RootDir`/`Prefix` and document why they are never popped) so the security invariants are obvious and future refactors don’t unintentionally change them.
- Consider extracting the manual path normalization logic into a small helper function with a clear contract (e.g., "never escape root or prefix, preserve leading ../ segments") so its behavior is easier to reason about and reuse in other places that might need similar traversal protection.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
🚨 Severity: CRITICAL
💡 Vulnerability: A path traversal vulnerability existed in
crates/flow/src/incremental/extractors/typescript.rsduring manual resolution of unresolved../paths. The code blindly popped components when encounteringstd::path::Component::ParentDir, which could erroneously pop root directories (RootDir) or prefixes (Prefix), or wrongly collapse../..components.🎯 Impact: This could allow malicious or poorly-formed import specifiers to escape the intended project boundary or resolve to incorrect arbitrary paths on the file system, bypassing boundary constraints.
🔧 Fix: Modified the normalization logic to safely handle
Component::ParentDir. It now explicitly checks the preceding component. It only pops if the last component isNormal. Otherwise, it pushes theParentDirto preserve paths correctly.✅ Verification: Ran formatting, linting, and specifically the
extractor_typescript_testswhich passed successfully. Added an entry to.jules/sentinel.mddocumenting this security learning.PR created automatically by Jules for task 907347045678852346 started by @bashandbone
Summary by Sourcery
Fix path traversal vulnerability in TypeScript dependency extraction and make minor ergonomic and documentation updates.
Bug Fixes:
Enhancements:
Documentation: