The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(computer-use): accept current notarised CUA Driver
fangliquanflq6662b3618d22
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex c9bf9ad6e2a..5a954ed0a06 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -3688,8 +3688,8 @@ DEFAULT_CONFIG = {# macOS only: allow launching an UNSIGNED (ad-hoc / TeamIdentifier# not set) CuaDriver.app for the private-session daemon. The default# (false) fails closed unless the bundle is signed with the official- # cua-driver identity (com.trycua.driver / team 4YEC26S9KF). Enable- # only when developing the driver locally from source.+ # cua-driver identity (com.trycua.driver / an official signing team).+ # Enable only when developing the driver locally from source."allow_unsigned_driver": False,# Pre-authorize existing-profile browser attachment in standard mode# (cua-driver's trusted-launcher `--grant existing-profile`). Whendiff --git a/tests/tools/test_computer_use_cua_macos_identity.py b/tests/tools/test_computer_use_cua_macos_identity.pynew file mode 100644index 00000000000..1ac47bc7823--- /dev/null+++ b/tests/tools/test_computer_use_cua_macos_identity.py@@ -0,0 +1,85 @@+"""macOS CuaDriver.app path and signing identity contracts."""++from __future__ import annotations++import subprocess++import pytest++from tools.computer_use import cua_backend+++def _codesign_proc(+ *,+ team_id: str,+ identifier: str = "com.trycua.driver",+) -> subprocess.CompletedProcess[str]:+ return subprocess.CompletedProcess(+ ["codesign"],+ 0,+ stdout="",+ stderr=(+ f"Identifier={identifier}\n"+ f"TeamIdentifier={team_id}\n"+ ),+ )+++def test_resolve_app_path_follows_standard_driver_symlink(monkeypatch):+ symlink = "/Users/test/.local/bin/cua-driver"+ executable = "/Applications/CuaDriver.app/Contents/MacOS/cua-driver"++ monkeypatch.setattr(cua_backend.os.path, "realpath", lambda path: executable)+ monkeypatch.setattr(cua_backend.os.path, "isfile", lambda path: True)+ monkeypatch.setattr(cua_backend.os, "access", lambda path, mode: True)++ assert cua_backend._resolve_cua_driver_app_path(symlink) == "/Applications/CuaDriver.app"+++def test_resolve_app_path_does_not_fall_back_to_an_unrelated_bundle(monkeypatch):+ monkeypatch.setattr(+ cua_backend.os.path,+ "realpath",+ lambda path: "/usr/local/bin/cua-driver",+ )++ assert cua_backend._resolve_cua_driver_app_path("cua-driver") is None++[email protected]("team_id", ["4YEC26S9KF", "YCK386LBJ7"])+def test_driver_signature_accepts_official_team_ids(monkeypatch, team_id):+ monkeypatch.setattr(cua_backend.shutil, "which", lambda name: "/usr/bin/codesign")+ monkeypatch.setattr(+ cua_backend.subprocess,+ "run",+ lambda *args, **kwargs: _codesign_proc(team_id=team_id),+ )++ cua_backend._validate_cua_driver_app_signature("/Applications/CuaDriver.app")+++def test_driver_signature_still_rejects_unrecognised_team(monkeypatch):+ monkeypatch.setattr(cua_backend.shutil, "which", lambda name: "/usr/bin/codesign")+ monkeypatch.setattr(+ cua_backend.subprocess,+ "run",+ lambda *args, **kwargs: _codesign_proc(team_id="EVIL000000"),+ )++ with pytest.raises(RuntimeError, match="signed by team"):+ cua_backend._validate_cua_driver_app_signature("/Applications/CuaDriver.app")+++def test_driver_signature_still_requires_exact_bundle_identifier(monkeypatch):+ monkeypatch.setattr(cua_backend.shutil, "which", lambda name: "/usr/bin/codesign")+ monkeypatch.setattr(+ cua_backend.subprocess,+ "run",+ lambda *args, **kwargs: _codesign_proc(+ team_id="YCK386LBJ7",+ identifier="com.trycua.driver.evil",+ ),+ )++ with pytest.raises(RuntimeError, match="has identifier"):+ cua_backend._validate_cua_driver_app_signature("/Applications/CuaDriver.app")diff --git a/tools/computer_use/cua_backend.py b/tools/computer_use/cua_backend.pyindex 3e70607c672..4982426eef9 100644--- a/tools/computer_use/cua_backend.py+++ b/tools/computer_use/cua_backend.py@@ -601,11 +601,12 @@ def _resolve_cua_driver_app_path(driver_cmd: str) -> Optional[str]:chain never validated. If the resolved driver does not live inside anapp bundle, the caller fails closed with install guidance."""+ resolved_driver_cmd = os.path.realpath(driver_cmd)marker = ".app/Contents/MacOS/"- marker_index = driver_cmd.find(marker)+ marker_index = resolved_driver_cmd.find(marker)if marker_index < 0:return None- candidate = driver_cmd[: marker_index + len(".app")]+ candidate = resolved_driver_cmd[: marker_index + len(".app")]executable = os.path.join(candidate, "Contents", "MacOS", "cua-driver")if os.path.isfile(executable) and os.access(executable, os.X_OK):return candidate@@ -613,11 +614,11 @@ def _resolve_cua_driver_app_path(driver_cmd: str) -> Optional[str]:# The only bundle identity the private daemon may launch through, and the-# team that signs official cua-driver releases. Exact matches only: a+# teams that sign official cua-driver releases. Exact matches only: a# suffixed identifier ("com.trycua.driver.evil") or a different non-empty# team is an impostor bundle, not a variant._CUA_DRIVER_BUNDLE_ID = "com.trycua.driver"-_CUA_DRIVER_TEAM_ID = "4YEC26S9KF"+_CUA_DRIVER_TEAM_IDS = ("4YEC26S9KF", "YCK386LBJ7")def _validate_cua_driver_app_signature(app_path: str) -> None:@@ -626,7 +627,7 @@ def _validate_cua_driver_app_signature(app_path: str) -> None:Launching via ``/usr/bin/open`` hands LaunchServices whatever bundle sitsat the path, so the TCC-identity fix must not become a launcher forarbitrary apps: require ``codesign -dv`` to report EXACTLY- ``Identifier=com.trycua.driver`` and the expected TeamIdentifier.+ ``Identifier=com.trycua.driver`` and an expected TeamIdentifier.``TeamIdentifier=not set`` (unsigned/ad-hoc dev builds) is allowed onlywhen ``computer_use.allow_unsigned_driver: true`` is set in config.yaml —the escape hatch for local driver development, never the default. Raises@@ -664,13 +665,13 @@ def _validate_cua_driver_app_signature(app_path: str) -> None:f"CuaDriver.app at {app_path} has identifier {identifier!r}, "f"expected {_CUA_DRIVER_BUNDLE_ID!r}; refusing to launch it.")- if team == _CUA_DRIVER_TEAM_ID:+ if team in _CUA_DRIVER_TEAM_IDS:returnif team in ("", "not set") and _computer_use_cfg().get("allow_unsigned_driver") is True:returnraise RuntimeError(- f"CuaDriver.app at {app_path} is signed by team {team!r}, expected "- f"{_CUA_DRIVER_TEAM_ID!r}; refusing to launch it. (Set "+ f"CuaDriver.app at {app_path} is signed by team {team!r}, expected one of "+ f"{_CUA_DRIVER_TEAM_IDS!r}; refusing to launch it. (Set ""computer_use.allow_unsigned_driver: true in config.yaml only for ""local unsigned driver builds.)")