🛡️ Sentinel: [CRITICAL] Fix path traversal in module resolution#319
🛡️ Sentinel: [CRITICAL] Fix path traversal in module resolution#319bashandbone wants to merge 1 commit into
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 GuideAdjusts TypeScript dependency extractor path normalization to safely handle parent directory components and prevent path traversal, and records the vulnerability and fix 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
ParentDirhandling logic in the normalization loop is now fairly subtle; consider extracting it into a small helper (e.g.,fn push_component(...)) with a brief comment describing the intended semantics so future changes don’t accidentally reintroduce traversal issues. - You explicitly special-case
RootDirandPrefix, but UNC or other platform-specific prefix behaviors can be tricky; it may be worth adding a debug assertion or small invariant check around howComponent::Prefix(_)interacts with subsequent components to make those assumptions explicit.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `ParentDir` handling logic in the normalization loop is now fairly subtle; consider extracting it into a small helper (e.g., `fn push_component(...)`) with a brief comment describing the intended semantics so future changes don’t accidentally reintroduce traversal issues.
- You explicitly special-case `RootDir` and `Prefix`, but UNC or other platform-specific prefix behaviors can be tricky; it may be worth adding a debug assertion or small invariant check around how `Component::Prefix(_)` interacts with subsequent components to make those assumptions explicit.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
🚨 Severity: CRITICAL
💡 Vulnerability: The TypeScript dependency extractor manually normalized paths when canonicalization failed. By blindly using
components.pop()when encounteringstd::path::Component::ParentDir, it failed to account for situations where..segments exceed the base path depth or when the root path is absolute. This allows path traversal attacks (e.g., escaping via../../..).🎯 Impact: Arbitrary out-of-bounds file reads during AST parsing or module extraction. Malicious users or packages could cause the system to read and expose unintended files outside the root workspace directory.
🔧 Fix: Updated the path normalization logic to emulate lexical canonicalization safely. Explicitly blocked
Component::ParentDirfrom poppingComponent::RootDirorComponent::Prefix, and pushed the newComponent::ParentDirinstead of ignoring it when the components list is empty or already ends in aParentDir.✅ Verification: Ran
cargo test -p thread-flow --test extractor_typescript_testswhich passed successfully. Confirmedgit diffcorrectly preserved..segments. All other workspace tests (cargo clippy,cargo test) execute without issues or warnings. Logged findings to.jules/sentinel.md.PR created automatically by Jules for task 1715232826389703906 started by @bashandbone
Summary by Sourcery
Fix unsafe path normalization in the TypeScript dependency extractor to prevent path traversal during module resolution and document the incident in the Sentinel log.
Bug Fixes:
Documentation: