Summary
On macOS, the standalone daemon authenticates every accepted raw CLI connection by verifying the full installed app bundle before it parses the request. This happens for ordinary non-History methods and when Computer History is not admitted.
The verification runs synchronously in the listener accept loop. Concurrent CLI clients therefore queue behind repeated deep signature checks. A client can time out while its mutation remains queued and later executes, making a blind retry unsafe.
Source path
At Cua Driver 0.22.0 commit ac9b1643acb61e20d5af078215e7d1b8c414db89:
serve.rs calls authenticate_history_cli_connection(&stream) synchronously after every listener.accept() and before spawning the request handler:
|
loop { |
|
tokio::select! { |
|
result = listener.accept() => { |
|
let (stream, _) = result?; |
|
if let Err(error) = authenticate_unix_peer(&stream) { |
|
tracing::warn!("service connection rejected before request parsing: {error}"); |
|
continue; |
|
} |
|
let trusted_host_connection = |
|
authenticate_embedded_host_connection(&stream).is_ok(); |
|
let trusted_history_cli_connection = |
|
authenticate_history_cli_connection(&stream).is_ok(); |
|
let reg = sdk.clone(); |
|
let shutdown_tx2 = shutdown_tx.clone(); |
|
let trusted_resume_registry = trusted_resume_registry.clone(); |
|
|
|
tokio::spawn(async move { |
- That authentication calls
verify_history_cli_executable_path, which reaches verify_installed_app_for_history:
|
pub(crate) fn verify_history_cli_executable_path(path: &Path) -> anyhow::Result<()> { |
|
#[cfg(target_os = "macos")] |
|
{ |
|
let expected = PathBuf::from(crate::bundle::app_bundle_path()) |
|
.join("Contents/MacOS") |
|
.join(crate::bundle::cli_name()); |
|
if !is_exact_packaged_helper(path, &expected) { |
|
anyhow::bail!("history control peer is not the exact installed Cua Driver helper"); |
|
} |
|
return verify_installed_app_for_history(); |
|
} |
|
#[cfg(not(target_os = "macos"))] |
|
{ |
|
let current = std::env::current_exe() |
|
.map_err(|error| anyhow::anyhow!("current executable is unavailable: {error}"))?; |
|
if !same_canonical_file(path, ¤t) { |
|
anyhow::bail!("history control peer is not the exact installed Cua Driver helper"); |
|
} |
|
verify_installed_non_macos_binary_for_history() |
|
} |
|
} |
|
|
|
pub fn verify_installed_product_for_history() -> anyhow::Result<()> { |
|
#[cfg(target_os = "macos")] |
|
{ |
|
verify_installed_app_for_history() |
|
} |
|
#[cfg(not(target_os = "macos"))] |
|
{ |
|
verify_installed_non_macos_binary_for_history() |
|
} |
|
} |
|
|
|
#[cfg(target_os = "macos")] |
|
pub fn verify_installed_app_for_history() -> anyhow::Result<()> { |
|
use std::process::{Command, Stdio}; |
|
|
|
let path = crate::bundle::app_bundle_path(); |
|
let metadata = fs::metadata(&path)?; |
|
if !metadata.is_dir() { |
|
anyhow::bail!("installed Cua Driver app path is not a directory"); |
|
} |
|
let verified = Command::new("/usr/bin/codesign") |
|
.args(["--verify", "--deep", "--strict", &path]) |
|
.stdout(Stdio::null()) |
|
.stderr(Stdio::null()) |
|
.status()?; |
- The latter runs
/usr/bin/codesign --verify --deep --strict <app bundle> for each connection.
The same path is present in 0.21.0 commit 70db98d1bcd92890d778f4978e0eb107a4b66c1b.
Reproduction
- Start the standalone daemon on macOS with Computer History not admitted.
- Confirm
cua-driver history status reports admitted: false.
- Run several ordinary calls concurrently, for example
cua-driver call list_apps '{}'.
- While they wait, inspect children of the daemon or sample its stack.
Observed child:
/usr/bin/codesign --verify --deep --strict /Applications/CuaDriver.app
On an arm64 Mac running Cua Driver 0.21.0, ordinary calls took roughly 10–60 seconds under concurrent client load. Sampling placed the daemon in authenticate_history_cli_connection and verify_installed_app_for_history before request handling.
Expected behavior
Ordinary non-History CLI methods should not pay the full History-control trust check. History control must remain authenticated before any History action is accepted.
Actual behavior
Every accepted CLI connection performs full app-bundle verification serially before the daemon reads the requested method.
Impact
- Concurrent clients serialize behind repeated deep signature verification.
- Read-only health calls can appear hung while status endpoints remain responsive.
- A timed-out mutating client does not prove cancellation. The queued action may execute later.
- Operators may retry an indeterminate mutation or restart a healthy daemon.
Possible fixes
- Parse enough of the request to apply
authenticate_history_cli_connection only to History-control methods, while failing closed before any such method executes.
- Alternatively, cache successful installed-product verification for the daemon lifetime and bind it to the canonical helper and app identity. The security properties of cache invalidation would need explicit review.
A regression test should prove that an ordinary method does not invoke full app verification, while unauthenticated History control remains rejected.
Summary
On macOS, the standalone daemon authenticates every accepted raw CLI connection by verifying the full installed app bundle before it parses the request. This happens for ordinary non-History methods and when Computer History is not admitted.
The verification runs synchronously in the listener accept loop. Concurrent CLI clients therefore queue behind repeated deep signature checks. A client can time out while its mutation remains queued and later executes, making a blind retry unsafe.
Source path
At Cua Driver 0.22.0 commit
ac9b1643acb61e20d5af078215e7d1b8c414db89:serve.rscallsauthenticate_history_cli_connection(&stream)synchronously after everylistener.accept()and before spawning the request handler:cua/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
Lines 856 to 872 in ac9b164
verify_history_cli_executable_path, which reachesverify_installed_app_for_history:cua/libs/cua-driver/rust/crates/cua-driver/src/history_runtime.rs
Lines 178 to 224 in ac9b164
/usr/bin/codesign --verify --deep --strict <app bundle>for each connection.The same path is present in 0.21.0 commit
70db98d1bcd92890d778f4978e0eb107a4b66c1b.Reproduction
cua-driver history statusreportsadmitted: false.cua-driver call list_apps '{}'.Observed child:
On an arm64 Mac running Cua Driver 0.21.0, ordinary calls took roughly 10–60 seconds under concurrent client load. Sampling placed the daemon in
authenticate_history_cli_connectionandverify_installed_app_for_historybefore request handling.Expected behavior
Ordinary non-History CLI methods should not pay the full History-control trust check. History control must remain authenticated before any History action is accepted.
Actual behavior
Every accepted CLI connection performs full app-bundle verification serially before the daemon reads the requested method.
Impact
Possible fixes
authenticate_history_cli_connectiononly to History-control methods, while failing closed before any such method executes.A regression test should prove that an ordinary method does not invoke full app verification, while unauthenticated History control remains rejected.