Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-30 - Path Traversal in Manual Path Normalization
**Vulnerability:** Path traversal vulnerability in TypeScript module resolution where manual `../` (ParentDir) handling in `typescript.rs` popped components indiscriminately, even after exhausting the base path.
**Learning:** When falling back to manual path normalisation via `.components()` because a file doesn't exist yet (canonicalize fails), naively popping components on `Component::ParentDir` allows malicious inputs like `../../` to escape the root directory context or resolve to arbitrary files, completely bypassing intended base path restrictions.
**Prevention:** Always preserve `ParentDir` components when the component list is empty or already ends in `ParentDir`. Never pop `RootDir` or `Prefix` components, effectively treating the root as an absolute boundary that `..` cannot traverse above.
11 changes: 10 additions & 1 deletion crates/flow/src/incremental/extractors/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,16 @@ impl TypeScriptDependencyExtractor {
for component in resolved.components() {
match component {
std::path::Component::ParentDir => {
components.pop();
if components.is_empty() || components.last() == Some(&std::path::Component::ParentDir) {
components.push(std::path::Component::ParentDir);
} else if let Some(last) = components.last() {
match last {
Comment on lines 810 to +814
std::path::Component::RootDir | std::path::Component::Prefix(_) => {
// Cannot go above root/prefix, ignore
}
_ => { components.pop(); }
}
}
}
std::path::Component::CurDir => {}
_ => components.push(component),
Expand Down