FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
security(automation): isolate bridge screenshots (#2919)
Earl Co9a0096a97940
diff --git a/Cargo.lock b/Cargo.lockindex ae7b24f2c..30676cf2b 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1758,6 +1758,7 @@ dependencies = ["schemars","serde","serde_json",+ "tempfile","thiserror 2.0.21","tokio",]diff --git a/crates/automation/Cargo.toml b/crates/automation/Cargo.tomlindex 3a2e4b965..9bd3e8766 100644--- a/crates/automation/Cargo.toml+++ b/crates/automation/Cargo.toml@@ -20,3 +20,4 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "synbase64 = "0.22"schemars = "1"image = { version = "0.25", default-features = false, features = ["png"] }+tempfile = "3"diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rsindex 3a9cb8e1c..b2e313504 100644--- a/crates/automation/src/server.rs+++ b/crates/automation/src/server.rs@@ -564,7 +564,14 @@ impl FilmcraftMcp {impl FilmcraftMcp {async fn screenshot(&self, b: &BridgeClient, panel: Option<String>, max: u32) -> Result<CallToolResult, McpError> {- let path = std::env::temp_dir().join(format!("filmcraft-mcp-{}.png", std::process::id()));+ // The desktop bridge needs a pathname, so use a freshly-created,+ // owner-only directory rather than exposing image bytes at a+ // predictable shared-temp filename.+ let dir = match tempfile::tempdir() {+ Ok(dir) => dir,+ Err(e) => return Ok(fail(format!("screenshot: {e}"))),+ };+ let path = dir.path().join("screenshot.png");if let Err(e) = b.call("ui.screenshot", json!({"path": path.to_string_lossy(), "panel": panel})).await {return Ok(fail(e));}@@ -572,7 +579,6 @@ impl FilmcraftMcp {Ok(b) => b,Err(e) => return Ok(fail(format!("screenshot: {e}"))),};- let _ = tokio::fs::remove_file(&path).await;let bytes = match image::load_from_memory(&bytes) {Ok(img) => {let rgba = img.to_rgba8();