From 2326220b7e6c6afaf1a2079a65731fda40fe54da Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Tue, 12 May 2026 14:13:19 -0500 Subject: [PATCH] fix(vision): reject rooted image paths on windows --- crates/tui/src/vision/tools.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/tui/src/vision/tools.rs b/crates/tui/src/vision/tools.rs index 808b5cbe..ff0e2e08 100644 --- a/crates/tui/src/vision/tools.rs +++ b/crates/tui/src/vision/tools.rs @@ -1,6 +1,6 @@ //! `image_analyze` tool — analyze images using a dedicated vision model. -use std::path::Path; +use std::path::{Component, Path}; use std::time::Duration; use async_trait::async_trait; @@ -109,11 +109,12 @@ impl ToolSpec for ImageAnalyzeTool { .unwrap_or("Describe this image in detail."); let image_path_buf = Path::new(image_path); - if image_path_buf.is_absolute() - || image_path_buf - .components() - .any(|c| matches!(c, std::path::Component::ParentDir)) - { + if image_path_buf.components().any(|c| { + matches!( + c, + Component::Prefix(_) | Component::RootDir | Component::ParentDir + ) + }) { return Err(ToolError::execution_failed( "image_path must be a relative path within the workspace and cannot escape it.", ));