[Bug]: existing-profile attach through the macOS daemon cannot read DevToolsActivePort
Primary area
Cua Driver
Summary
On macOS, browser_prepare with strategy: existing_profile against Chrome's default profile is refused with could not read the browser's DevToolsActivePort file: Operation not permitted (os error 1) when it runs in the LaunchAgent daemon. The same file reads fine from the calling terminal, and the same prepare succeeds in a runtime started with cua-driver mcp --direct.
Reproduction
- In Chrome, turn on "Allow remote debugging for this browser instance" at
chrome://inspect/#remote-debugging.~/Library/Application Support/Google/Chrome/DevToolsActivePortthen names the port Chrome listens on. - Run the daemon from its LaunchAgent:
cua-driver serve --permission-mode unrestricted --dangerously-bypass-approvals. cua-driver call get_browser_state '{"pid": <chrome pid>, "window_id": <window id>, "session": "s"}'returnsbrowser_consent_requiredwithnext_action: browser_prepare, as expected.cua-driver call browser_prepare '{"pid": <chrome pid>, "window_id": <window id>, "session": "s", "strategy": {"kind": "existing_profile"}}'
Seen on my one attempt through the daemon. The same browser attached from a direct runtime a few minutes later.
Expected behavior
The prepare attaches to the existing profile, as it does from a direct runtime.
Actual behavior
$ cua-driver call browser_prepare '{"pid": 1622, "window_id": 333, "session": "s", "strategy": {"kind": "existing_profile"}}'
{
"refusal": {
"code": "browser_route_unavailable",
"message": "could not read the browser's DevToolsActivePort file: Operation not permitted (os error 1)"
},
"status": "refused"
}
From the same terminal, head -1 ~/Library/Application\ Support/Google/Chrome/DevToolsActivePort prints the port. In a runtime started with cua-driver mcp --direct --grant existing-profile, the same call returns attached_existing_profile with endpoint_ownership.method: devtools_active_ports_file and every side_effects entry false. I don't know which macOS protection refuses the daemon's read.
Environment
Cua Driver 0.30.1, daemon started by its LaunchAgent in unrestricted mode; CuaDriver.app holds Accessibility and Screen Recording. macOS 27.0 (26A428), Apple silicon. Google Chrome 154.0.8037.57, default profile, remote debugging turned on through chrome://inspect. main at 1fadc40 reads the file the same way.
Evidence
active_port_endpoint reads the file with tokio::fs::read_to_string and turns any error other than NotFound into this refusal:
https://github.com/trycua/cua/blob/1fadc40b3e40e042590c9f63cf8ef837a6263258/libs/cua-driver/rust/crates/platform-macos/src/browser/platform.rs#L567-L587
Workaround and additional context
cua-driver mcp --direct --grant existing-profile works, since that runtime runs under the calling host. A Chrome started with --remote-debugging-port and its own --user-data-dir attaches through the daemon without trouble, because its endpoint is found from the listening socket rather than this file.
Related but different: #3241 (an attach wedging a long-lived daemon) and #3287 (a consent race on Windows).
Submission checks
- [x] I searched for duplicate issues and active pull requests.
- [x] This issue describes a single problem.
- [x] I removed credentials, private data, sensitive screenshots, and vulnerability details from this public report.
Found the cause. macOS 27 added an app data protection over a fixed list of folders, ~/Library/Application Support/Google/Chrome, Microsoft Edge and BraveSoftware/Brave-Browser among them. A process without Full Disk Access or a per-app grant gets EPERM there, root included, and macOS doesn't prompt. Write-ups: Wojciech Reguła, mdm.tools. Here a one-shot LaunchAgent running ls and head gets Operation not permitted on the Chrome folder and on DevToolsActivePort, while ~/Library/Application Support/Google lists fine. The direct runtime works because it runs under the calling app, which has Full Disk Access on this machine. The hosted macOS E2E runs on macos-26, so CI won't show it.
The same error reaches page enable_javascript_apple_events. It quits the browser, find_preferences_files turns the read_dir failure into an empty list, nothing gets patched, the browser relaunches and the call returns success.
I'd like to fix both in one PR:
active_port_endpoint: keepbrowser_route_unavailableon a permission error, but say what blocked the read and what worksenable_javascript_apple_events: check the profile folder is readable before quitting the browser, and return an error when no Preferences file was patched- a macOS 27 note in the browsers guide
Evidence will be unit tests that pin both behaviors plus the macOS 27.0 runs above. One question first: should the message name Full Disk Access for CuaDriver.app as the fix, or only point at cua-driver mcp --direct?
We are seeing this existing-profile attachment refusal with Cua Driver 0.33.3 on macOS:
browser_route_unavailable
could not read the browser's DevToolsActivePort file: Operation not permitted (os error 1)
The daemon reports com.trycua.driver. Accessibility and Screen Recording are true, and the caller, daemon and Chrome have matching UID/EUID. Those checks do not assess protected Chrome-data access, so the specific permission cause is still unknown.
The installed cua-driver mcp --help returns shared help. It says --direct owns the runtime and attributes TCC to the invoking host. It lists --grant existing-profile and the standard default only under "agent authorization (serve only)". We have not started a direct runtime.
For 0.33.3, what is the supported launch and permission contract for this attachment? Does mcp --direct accept --grant existing-profile, which permission mode governs it, and which calling host must already have protected-data access? Is there a non-prompting, read-only diagnostic for this exact file-read refusal?
The existing browser sessions are preserved. No profile-file inspection, OS permission change, runtime grant/configuration change or attachment retry has followed the refusal.
Fixed by #7745, which shipped in cua-driver-rs v0.50.0.