Skip to content

Commit 06c126a

Browse files
committed
fix(claw-analog): reject backslash paths in validate_rel_path (dotdot bypass on Linux)
1 parent 1f572ff commit 06c126a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • rust/crates/claw-analog/src

rust/crates/claw-analog/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,12 @@ fn output_to_input_blocks(blocks: &[OutputContentBlock]) -> Vec<InputContentBloc
15891589
}
15901590

15911591
pub fn validate_rel_path(rel: &str) -> Result<(), String> {
1592+
// Reject Windows-style backslash paths that may contain dotdot traversal
1593+
// (on Unix, Path::components does not split on backslash, so "..\\x" parses
1594+
// as a single Normal component and evades the ParentDir check).
1595+
if rel.contains('\\') {
1596+
return Err("path must not contain backslashes".into());
1597+
}
15921598
let p = Path::new(rel);
15931599
for c in p.components() {
15941600
match c {

0 commit comments

Comments
 (0)