Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(net): the update manifest and the sound list are fetched trusting Concat's own roots alone

Jareer41ca63a423a2
diff --git a/src/crates/concat-host/src/net.rs b/src/crates/concat-host/src/net.rs
index 2228e71b..fbedc770 100644
--- a/src/crates/concat-host/src/net.rs
+++ b/src/crates/concat-host/src/net.rs
@@ -2,7 +2,8 @@
// SPDX-FileCopyrightText: 2026 Jareer Abdullah and Concat contributors
//! The one way the host reaches the network: models, sounds and update
-//! checks all go through [`agent`].
+//! checks all go through [`agent`], and the manifests that vouch for a
+//! download through [`strict_agent`].
//!
//! An HTTPS connection is trusted when its certificate chains to a root
//! Concat ships (Mozilla's list, as webpki-roots carries it) or to a root
@@ -19,7 +20,9 @@ use std::sync::{Arc, OnceLock};
use std::time::Duration;
/// An agent with these timeouts that trusts the shipped roots and the
-/// system's.
+/// system's: for a file whose digest Concat already knows - a model, whose
+/// sums are compiled in, or an installer or sound checked against a
+/// manifest fetched with [`strict_agent`].
pub fn agent(connect: Duration, read: Duration) -> ureq::Agent {
ureq::AgentBuilder::new()
.timeout_connect(connect)
@@ -28,6 +31,38 @@ pub fn agent(connect: Duration, read: Duration) -> ureq::Agent {
.build()
}
+/// An agent that trusts the shipped roots alone, for the manifests that
+/// say what a download must hash to: the update manifest and the sound
+/// list. A root the system was given by a proxy or an antivirus is enough
+/// to re-sign github.com, and a manifest fetched through it could name a
+/// swapped installer's digest beside the swapped installer. Behind such a
+/// network the update check and the sound list fail, as every download did
+/// before #517; the files they vouch for still come over [`agent`].
+pub fn strict_agent(connect: Duration, read: Duration) -> ureq::Agent {
+ ureq::AgentBuilder::new()
+ .timeout_connect(connect)
+ .timeout_read(read)
+ .tls_config(Arc::clone(shipped_tls()))
+ .build()
+}
+
+/// The TLS configuration [`strict_agent`] shares: the shipped roots only.
+fn shipped_tls() -> &'static Arc<rustls::ClientConfig> {
+ static CONFIG: OnceLock<Arc<rustls::ClientConfig>> = OnceLock::new();
+ CONFIG.get_or_init(|| {
+ let config = rustls::ClientConfig::builder_with_provider(
+ rustls::crypto::ring::default_provider().into(),
+ )
+ .with_protocol_versions(&[&rustls::version::TLS12, &rustls::version::TLS13])
+ .expect("ring offers cipher suites for TLS 1.2 and 1.3")
+ .with_root_certificates(rustls::RootCertStore {
+ roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(),
+ })
+ .with_no_client_auth();
+ Arc::new(config)
+ })
+}
+
/// The TLS configuration every agent shares. Built once: reading the
/// system's store takes a keychain query on macOS and a registry walk on
/// Windows, which is not worth paying per request.
@@ -77,6 +112,7 @@ mod tests {
// The configuration is whole: a connection can be started on it.
// The name is never looked up.
let name = rustls::pki_types::ServerName::try_from("github.com").expect("a valid name");
- assert!(rustls::ClientConnection::new(Arc::clone(tls()), name).is_ok());
+ assert!(rustls::ClientConnection::new(Arc::clone(tls()), name.clone()).is_ok());
+ assert!(rustls::ClientConnection::new(Arc::clone(shipped_tls()), name).is_ok());
}
}
diff --git a/src/crates/concat-host/src/sounds.rs b/src/crates/concat-host/src/sounds.rs
index 7e3814be..5c8dce5a 100644
--- a/src/crates/concat-host/src/sounds.rs
+++ b/src/crates/concat-host/src/sounds.rs
@@ -382,7 +382,7 @@ pub fn cached_catalogue(dirs: &AppDirs) -> Option<Catalogue> {
/// error.
pub fn fetch_catalogue(dirs: &AppDirs) -> Result<Option<Catalogue>, String> {
use std::io::Read;
- let agent = crate::net::agent(
+ let agent = crate::net::strict_agent(
std::time::Duration::from_secs(15),
std::time::Duration::from_secs(30),
);
diff --git a/src/crates/concat-host/src/updates.rs b/src/crates/concat-host/src/updates.rs
index 8901bf84..63ea139e 100644
--- a/src/crates/concat-host/src/updates.rs
+++ b/src/crates/concat-host/src/updates.rs
@@ -669,7 +669,7 @@ fn detach(command: &mut Command) -> Result<(), String> {
/// One GET, read whole as text. GitHub wants a user agent and says so with
/// a 403 otherwise.
fn get_text(url: &str) -> Result<String, String> {
- let agent = crate::net::agent(
+ let agent = crate::net::strict_agent(
std::time::Duration::from_secs(20),
std::time::Duration::from_secs(30),
);
diff --git a/src/crates/concat-mcp/src/tools.rs b/src/crates/concat-mcp/src/tools.rs
index dce61c94..972fdad2 100644
--- a/src/crates/concat-mcp/src/tools.rs
+++ b/src/crates/concat-mcp/src/tools.rs
@@ -461,9 +461,12 @@ pub fn catalogue() -> Vec<Tool> {
Tool {
name: "preview_frame",
title: "Preview a frame",
- description: "Renders the true composited frame at `time` seconds on an open project's timeline and returns it as an image to look at - titles, effects and transforms included. Without `width` and `height` it fits within 1280 pixels; give both for another size (8192 at most). With `output` (a .png path) it is written there instead.",
- read_only: true,
- destructive: false,
+ description: "Renders the true composited frame at `time` seconds on an open project's timeline and returns it as an image to look at - titles, effects and transforms included. Without `width` and `height` it fits within 1280 pixels; give both for another size (8192 at most). With `output` (a .png path) it is written there instead, replacing any file already at that path.",
+ // Not read-only: with `output` it writes a file, over one that
+ // is there. A client that trusts the hint to skip asking would
+ // let an agent overwrite anything under home.
+ read_only: false,
+ destructive: true,
idempotent: true,
action: Action::PreviewFrame,
},
diff --git a/src/crates/concat-speech/src/transcribe.rs b/src/crates/concat-speech/src/transcribe.rs
index b7ffee53..05da8990 100644
--- a/src/crates/concat-speech/src/transcribe.rs
+++ b/src/crates/concat-speech/src/transcribe.rs
@@ -289,7 +289,10 @@ fn vad_model(dirs: &AppDirs) -> Result<PathBuf, String> {
let path = models_dir(dirs)?.join("ggml-silero-v6.2.0.bin");
let whole = std::fs::metadata(&path).is_ok_and(|meta| meta.len() == VAD_MODEL.len() as u64);
if !whole {
- let part = path.with_extension("part");
+ // Named for this process, so two windows writing it at once do
+ // not write into one file; whichever renames last wins, and both
+ // wrote the same bytes.
+ let part = path.with_extension(format!("part-{}", std::process::id()));
std::fs::write(&part, VAD_MODEL)
.and_then(|()| std::fs::rename(&part, &path))
.map_err(|error| format!("could not write {}: {error}", path.display()))?;