Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(remote): block persisted execution routing
Maxf4efbef5e51a
diff --git a/docs/plans/2026-08-04-org-master-conservative-harness-gate.md b/docs/plans/2026-08-04-org-master-conservative-harness-gate.mdindex 4617f9ed2..de05150e1 100644--- a/docs/plans/2026-08-04-org-master-conservative-harness-gate.md+++ b/docs/plans/2026-08-04-org-master-conservative-harness-gate.md@@ -39,7 +39,11 @@ entitlement mirror before remote recurring execution can be enabled.Agent-definition and instruction mutations, model/backend mutations andruntime operations, service control, local installers, terminal sockets,file operations including Show Page icon uploads, and Harness definition- mutations before invoking their underlying services.+ mutations before invoking their underlying services. The same boundary also+ rejects payloads that persist future execution choices: Session Agent/model+ overrides, Project creation/workdir/default Agent, channel/thread/+ user cwd or routing, and Agent/platform/runtime config sections. Metadata-only+ Session and Project edits and unrelated UI/config preferences remain available.3. The durable Delivery owner retires remote-origin queue entries before theFIFO claim that starts an Agent turn.4. Task and Watch stores reject explicit remote definition writes.@@ -69,6 +73,10 @@ substitute for either dependency.- Remote service control, installers, Agent-definition mutations, model/backendmutations and probes, and Show Page icon writes fail before reaching theirlocal runtime or filesystem services.+- Remote execution-setting writes through Session, Project, channel, thread,+ user, and config routes fail before any store save, runtime reconciliation, or+ restart scheduling; Session titles, Project display names, and unrelated UI+ preferences remain writable.- Paired Project synchronization never forwards the device secret through anHTTP redirect.- Remote Task and Watch add/update calls produce no definition write.diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex c5a8d738f..5dcd5cb74 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -929,6 +929,215 @@ def test_remote_agent_termination_is_blocked_before_controller_access(assert response.get_json()["code"] == "remote_execution_disabled"+ "json_body",+ [+ {"agent_name": "codex"},+ {"model": "gpt-5"},+ {"reasoning_effort": "high"},+ {"scope_id": "scope-local"},+ ],+)+def test_remote_session_execution_settings_are_blocked_before_store_access(+ monkeypatch,+ tmp_path,+ json_body,+):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )++ def unexpected_session_update(*args, **kwargs):+ raise AssertionError("remote session routing reached the local session store")++ monkeypatch.setattr(+ "core.services.sessions.update_session",+ unexpected_session_update,+ )+ response = client.patch(+ "/api/sessions/ses-local",+ json=json_body,+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"+++ ("method", "path", "json_body"),+ [+ ("POST", "/api/projects", {"folder_path": "/tmp/remote-project"}),+ ("PATCH", "/api/projects/proj-local", {"folder_path": "/tmp/remote-project"}),+ ("PATCH", "/api/projects/proj-local", {"agent_name": "codex"}),+ ("PATCH", "/api/projects/proj-local", {"model": "gpt-5"}),+ ],+)+def test_remote_project_execution_settings_are_blocked_before_store_access(+ monkeypatch,+ tmp_path,+ method,+ path,+ json_body,+):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )++ monkeypatch.setattr(+ "storage.projects_service.create_project",+ lambda *args, **kwargs: (_ for _ in ()).throw(+ AssertionError("remote project creation reached the local project store")+ ),+ )+ monkeypatch.setattr(+ "storage.projects_service.update_project",+ lambda *args, **kwargs: (_ for _ in ()).throw(+ AssertionError("remote project routing reached the local project store")+ ),+ )+ response = client.request(+ method,+ path,+ json=json_body,+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"+++def test_remote_scope_settings_block_execution_fields_but_allow_metadata(monkeypatch, tmp_path):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )++ monkeypatch.setattr(api, "save_settings", lambda payload: {"ok": True, "payload": payload})+ allowed = client.post(+ "/api/settings",+ json={"platform": "slack", "channels": {"C1": {"enabled": False}}},+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )+ assert allowed.status_code == 200++ blocked = client.post(+ "/api/settings",+ json={+ "platform": "slack",+ "channels": {"C1": {"custom_cwd": "/tmp/remote"}},+ },+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )+ assert blocked.status_code == 403+ assert blocked.get_json()["code"] == "remote_execution_disabled"+++def test_remote_thread_scope_settings_are_blocked_before_store_access(monkeypatch, tmp_path):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )+ monkeypatch.setattr(+ api,+ "save_thread_settings",+ lambda payload: (_ for _ in ()).throw(+ AssertionError("remote thread routing reached the local settings store")+ ),+ )++ response = client.post(+ "/api/settings/thread",+ json={+ "platform": "telegram",+ "channel_id": "channel-1",+ "thread_id": "thread-1",+ "settings": {"routing": {"agent_name": "codex"}},+ },+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"+++ "json_body",+ [+ {"agents": {"codex": {"cli_path": "/tmp/remote-codex"}}},+ {"platforms": {"enabled": ["telegram"], "primary": "telegram"}},+ ],+)+def test_remote_execution_config_changes_are_blocked_before_runtime_reconcile(+ monkeypatch,+ tmp_path,+ json_body,+):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )+ monkeypatch.setattr(+ ui_server,+ "_save_config_and_runtime_decisions",+ lambda *args, **kwargs: (_ for _ in ()).throw(+ AssertionError("remote execution config reached persistence/reconcile")+ ),+ )++ response = client.post(+ "/api/config",+ json=json_body,+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"+++def test_remote_session_and_project_metadata_predicates_remain_allowed():+ assert not ui_server._is_remote_local_execution_request(+ "PATCH", "/api/sessions/ses-local", {"title": "renamed"}+ )+ assert not ui_server._is_remote_local_execution_request(+ "PATCH", "/api/projects/proj-local", {"display_name": "renamed"}+ )++def test_remote_session_archive_is_blocked_before_store_access(monkeypatch,tmp_path,diff --git a/vibe/ui_compat.py b/vibe/ui_compat.pyindex 3d26e9c20..1f8221c2d 100644--- a/vibe/ui_compat.py+++ b/vibe/ui_compat.py@@ -71,6 +71,13 @@ class CompatRequest:def json(self) -> Any:return self._json_payload+ async def load_json(self) -> Any:+ """Parse and cache JSON when a shared request hook needs the body."""++ if self._json_payload is None:+ self._json_payload = await _read_json_payload(self._request)+ return self._json_payload+@propertydef host(self) -> str:return self._request.headers.get("host", "")diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex a2de75355..bd6418492 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -2233,7 +2233,142 @@ def enforce_instance_role_capabilities():return None-def _is_remote_local_execution_request(method: str, path: str) -> bool:+_SESSION_EXECUTION_SETTING_FIELDS = frozenset(+ {+ "agent_backend",+ "agent_id",+ "agent_name",+ "agent_variant",+ "model",+ "reasoning_effort",+ "scope_id",+ }+)+_PROJECT_EXECUTION_SETTING_FIELDS = frozenset(+ {+ "agent_backend",+ "agent_id",+ "agent_name",+ "agent_variant",+ "expected_agent_id",+ "folder_path",+ "model",+ "reasoning_effort",+ }+)+_SCOPE_EXECUTION_SETTING_FIELDS = frozenset(+ {"custom_cwd", "expected_agent_name", "routing"}+)+_CONFIG_EXECUTION_SETTING_FIELDS = frozenset(+ {+ "agents",+ "audio_asr",+ "gateway",+ "memory",+ "model_hub",+ "platform",+ "platforms",+ "runtime",+ "show_pages_prompt",+ "update",+ }+)+++def _payload_has_any_field(payload: Any, fields: frozenset[str] | set[str]) -> bool:+ return isinstance(payload, dict) and not fields.isdisjoint(payload)+++def _payload_changes_values(payload: Any, current: Any) -> bool:+ """Return whether supplied values differ from the persisted projection.++ Config saves accept both complete UI round-trips and partial updates. Comparing+ only supplied leaves lets an unchanged complete payload pass while still+ rejecting a remote caller that changes any execution-sensitive value.+ """++ if isinstance(payload, dict):+ if not isinstance(current, dict):+ return True+ return any(+ key not in current or _payload_changes_values(value, current[key])+ for key, value in payload.items()+ )+ return payload != current+++def _config_execution_setting_fields() -> set[str]:+ from config.platform_registry import im_platform_descriptors++ return set(_CONFIG_EXECUTION_SETTING_FIELDS) | {+ descriptor.config_key for descriptor in im_platform_descriptors()+ }+++def _remote_execution_payload_route(method: str, path: str) -> bool:+ normalized_method = method.upper()+ if normalized_method == "POST" and path in {+ "/api/config",+ "/api/projects",+ "/api/sessions",+ "/api/settings",+ "/api/settings/thread",+ "/api/users",+ }:+ return True+ return normalized_method == "PATCH" and bool(+ re.fullmatch(r"/api/(?:projects|sessions)/[^/]+", path)+ )+++def _payload_selects_remote_local_execution(method: str, path: str, payload: Any) -> bool:+ normalized_method = method.upper()+ if normalized_method == "POST" and path == "/api/config":+ if not isinstance(payload, dict):+ return False+ sensitive_fields = _config_execution_setting_fields()+ supplied_sensitive = sensitive_fields.intersection(payload)+ if not supplied_sensitive:+ return False+ from vibe import api++ current = _load_remote_access_config()+ if current is None:+ return True+ current_payload = api.config_to_payload(current)+ return any(+ _payload_changes_values(payload[field], current_payload.get(field))+ for field in supplied_sensitive+ )+ if normalized_method == "POST" and path == "/api/sessions":+ return _payload_has_any_field(payload, _SESSION_EXECUTION_SETTING_FIELDS)+ if normalized_method == "PATCH" and re.fullmatch(r"/api/sessions/[^/]+", path):+ return _payload_has_any_field(payload, _SESSION_EXECUTION_SETTING_FIELDS)+ if normalized_method == "PATCH" and re.fullmatch(r"/api/projects/[^/]+", path):+ return _payload_has_any_field(payload, _PROJECT_EXECUTION_SETTING_FIELDS)+ if normalized_method == "POST" and path == "/api/settings":+ channels = payload.get("channels") if isinstance(payload, dict) else None+ return isinstance(channels, dict) and any(+ _payload_has_any_field(channel, _SCOPE_EXECUTION_SETTING_FIELDS)+ for channel in channels.values()+ if isinstance(channel, dict)+ )+ if normalized_method == "POST" and path == "/api/settings/thread":+ settings = payload.get("settings") if isinstance(payload, dict) else None+ return _payload_has_any_field(settings, _SCOPE_EXECUTION_SETTING_FIELDS)+ if normalized_method == "POST" and path == "/api/users":+ users = payload.get("users") if isinstance(payload, dict) else None+ return isinstance(users, dict) and any(+ _payload_has_any_field(user, _SCOPE_EXECUTION_SETTING_FIELDS)+ for user in users.values()+ if isinstance(user, dict)+ )+ if normalized_method == "POST" and path == "/api/projects":+ return _payload_has_any_field(payload, {"folder_path"})+ return False+++def _is_remote_local_execution_request(method: str, path: str, payload: Any = None) -> bool:normalized_method = method.upper()is_mutation = normalized_method not in {"GET", "HEAD", "OPTIONS"}if path.startswith(("/api/files/", "/api/browse")):@@ -2275,28 +2410,34 @@ def _is_remote_local_execution_request(method: str, path: str) -> bool:if normalized_method == "DELETE" and (re.fullmatch(r"/api/skills/[^/]+", path)or re.fullmatch(r"/api/sessions/[^/]+(?:/queue/[^/]+)?", path)+ or path == "/api/settings/thread"):return True- return normalized_method == "POST" and bool(+ if normalized_method == "POST" and bool(re.fullmatch(r"/api/sessions/[^/]+/(?:messages|attachments|cancel|queue/[^/]+/send-now)",path,)- )+ ):+ return True+ return _payload_selects_remote_local_execution(method, path, payload)@app.before_request-def enforce_remote_local_execution_boundary():+async def enforce_remote_local_execution_boundary():"""Keep shell-capable Workbench surfaces on the trusted-local origin."""context = getattr(g, "authorization_context", None)- if (- context is None- or not context.is_remote- or not _is_remote_local_execution_request(request.method, request.path)- ):+ if context is None or not context.is_remote:+ return None+ if _is_remote_local_execution_request(request.method, request.path):+ return _remote_execution_disabled_response()+ if not _remote_execution_payload_route(request.method, request.path):return None- return _remote_execution_disabled_response()+ payload = await request.load_json()+ if _is_remote_local_execution_request(request.method, request.path, payload):+ return _remote_execution_disabled_response()+ return None_PROJECT_RESOURCE_PATHS = (