Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(remote): confine sensitive local reads

Max23889811394a
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.md
index 8faacd2c2..70a186b12 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
@@ -21,12 +21,12 @@ entitlement mirror before remote recurring execution can be enabled.
behavior unchanged.
- Keep IM-triggered Agent behavior unchanged.
- This phase provides no remote authorization for Harness execution or
- definition writes, Vault secret-bearing operations, IM ingress configuration,
- native Agent session forks, or private Show Runtime API writes; these
- capabilities remain trusted-local. Signed private Show human annotations and
- mark-read receipts remain available only when they cannot dispatch an Agent
- turn. Public `/p/<share_id>/...` flows are a separate sharing surface, not
- remote Workbench authorization.
+ definition writes, Vault secret-bearing operations, IM ingress configuration
+ or bind-code inventory, Project archiving, native Agent session forks, or
+ private Show Runtime API writes; these capabilities remain trusted-local.
+ Signed private Show human annotations and mark-read receipts remain available
+ only when they cannot dispatch an Agent turn. Public `/p/<share_id>/...` flows
+ are a separate sharing surface, not remote Workbench authorization.
- Make every remote Workbench capability read-only with respect to local Agent,
terminal, file, and Harness execution.
- Reject remote Task and Watch creation or update at the definition service
@@ -54,16 +54,20 @@ entitlement mirror before remote recurring execution can be enabled.
policy payload-filters routes that persist future execution choices with
explicit safe-field allowlists: Session Agent/model overrides, Project
creation/workdir/default Agent, and Agent/platform/runtime config sections.
- IM channel and thread settings, native Agent session forks, and private Show
- Runtime API writes are explicitly trusted-local because they can alter future
- Agent ingress or invoke local runtime code. The separate server-owned Show
- human-event endpoint may record a signed annotation or mark-read receipt, but
- rejects remote requests that would reserve or dispatch an Agent turn before
- event persistence. Unknown fields fail closed. Complete config round-trips
- may preserve protected values but cannot change them, and protected fields
- are stripped before persistence so a concurrent local update cannot be
- overwritten by a stale remote round-trip. Explicit Session/Project display
- fields and explicit UI/config preferences remain available.
+ IM channel/thread settings, bind-code inventory, Project archiving, native
+ Agent session forks, and private Show Runtime API writes are explicitly
+ trusted-local because they expose credentials, change local availability, or
+ invoke local runtime code. Generic configuration responses use a remote
+ positive projection rather than owner-role based redaction, so local paths,
+ executables, and future local settings are absent by default. The separate
+ server-owned Show human-event endpoint may record a signed annotation or
+ mark-read receipt, but rejects remote requests that would reserve or dispatch
+ an Agent turn before event persistence. Unknown fields fail closed. Complete
+ config round-trips may preserve protected values but cannot change them, and
+ protected fields are stripped before persistence so a concurrent local update
+ cannot be overwritten by a stale remote round-trip. Explicit
+ Session/Project display fields and explicit UI/config preferences remain
+ available.
3. The durable Delivery owner retires remote-origin queue entries before the
FIFO claim that starts an Agent turn.
4. Task and Watch stores reject explicit remote definition writes.
@@ -90,8 +94,9 @@ substitute for either dependency.
- Remote Workbench message and Show dispatch do not reserve or start a turn.
- Remote terminal and file requests fail closed; trusted-local requests retain
existing behavior.
-- Remote Vault secret/grant/sign mutations, IM user and bind-code mutations, and
- Skill source previews fail before reaching local stores or tooling.
+- Remote Vault secret/grant/sign mutations, IM user and bind-code operations,
+ Project archiving, and Skill source previews fail before reaching local stores
+ or tooling. Remote config reads omit local runtime and executable paths.
- Remote service control, installers, Agent-definition mutations, model/backend
mutations and probes, and Show Page icon writes fail before reaching their
local runtime or filesystem services.
diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.py
index afd7cc8e4..e87282549 100644
--- a/tests/test_instance_authorization.py
+++ b/tests/test_instance_authorization.py
@@ -177,7 +177,6 @@ def test_remote_http_policy_defaults_local_machine_and_unknown_routes_to_local_o
("POST", "/api/web-push/subscriptions", REMOTE_HTTP_ALLOWED),
("GET", "/api/harness/runs/run-1", REMOTE_HTTP_ALLOWED),
("GET", "/api/users", REMOTE_HTTP_ALLOWED),
- ("GET", "/api/bind-codes", REMOTE_HTTP_ALLOWED),
("GET", "/show/ses-1/", REMOTE_HTTP_ALLOWED),
("POST", "/show/ses-1/__show/events", REMOTE_HTTP_ALLOWED),
("POST", "/api/config", REMOTE_HTTP_PAYLOAD_FILTERED),
@@ -186,6 +185,8 @@ def test_remote_http_policy_defaults_local_machine_and_unknown_routes_to_local_o
("POST", "/api/settings", REMOTE_HTTP_LOCAL_ONLY),
("POST", "/api/settings/thread", REMOTE_HTTP_LOCAL_ONLY),
("DELETE", "/api/settings/thread", REMOTE_HTTP_LOCAL_ONLY),
+ ("GET", "/api/bind-codes", REMOTE_HTTP_LOCAL_ONLY),
+ ("DELETE", "/api/projects/proj-1", REMOTE_HTTP_LOCAL_ONLY),
("POST", "/api/sessions/ses-1/fork", REMOTE_HTTP_LOCAL_ONLY),
("POST", "/show/ses-1/api/action", REMOTE_HTTP_LOCAL_ONLY),
],
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index b344223d6..a0705ead5 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -777,6 +777,34 @@ def test_remote_generic_config_omits_memory_projection(monkeypatch, tmp_path):
assert "memory" not in response.get_json()
+def test_remote_config_uses_the_safe_projection_for_an_instance_owner(monkeypatch, tmp_path):
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _save_config(tmp_path)
+ config.runtime.default_cwd = "/private/local-agent-workdir"
+ config.agents.codex.cli_path = "/opt/avibe/bin/codex"
+ config.save()
+ client = app.test_client()
+ client.set_cookie(
+ remote_access.SESSION_COOKIE_NAME,
+ remote_session_cookie(config, "[email protected]", "user-owner", role="owner"),
+ domain="alex.avibe.bot",
+ )
+
+ response = client.get(
+ "/api/config",
+ base_url="https://alex.avibe.bot",
+ environ_base=_remote_peer(),
+ )
+
+ assert response.status_code == 200
+ payload = response.get_json()
+ assert payload["mode"] == "self_host"
+ assert payload["ui"]["instance_name"] == config.ui.instance_name
+ assert "runtime" not in payload
+ assert "agents" not in payload
+ assert "memory" not in payload
+
+
def test_remote_session_info_includes_authenticated_subject(monkeypatch, tmp_path):
monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
config = _save_config(tmp_path)
@@ -1656,11 +1684,12 @@ def test_remote_im_user_mutations_are_blocked_before_api_calls(
@pytest.mark.parametrize(
("method", "path", "json_body", "api_method"),
[
+ ("GET", "/api/bind-codes", None, "get_bind_codes"),
("POST", "/api/bind-codes", {"type": "one_time"}, "create_bind_code"),
("DELETE", "/api/bind-codes/CODE1", None, "delete_bind_code"),
],
)
-def test_remote_bind_code_mutations_are_blocked_before_api_calls(
+def test_remote_bind_code_operations_are_blocked_before_api_calls(
monkeypatch,
tmp_path,
method,
@@ -1678,7 +1707,7 @@ def test_remote_bind_code_mutations_are_blocked_before_api_calls(
)
def unexpected_bind_code_call(*args, **kwargs):
- raise AssertionError("remote bind-code mutation reached the local auth store")
+ raise AssertionError("remote bind-code operation reached the local auth store")
monkeypatch.setattr(api, api_method, unexpected_bind_code_call)
response = client.request(
@@ -1694,6 +1723,33 @@ def test_remote_bind_code_mutations_are_blocked_before_api_calls(
assert response.get_json()["code"] == "remote_execution_disabled"
+def test_remote_project_archive_is_blocked_before_project_store(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", role="owner"),
+ domain="alex.avibe.bot",
+ )
+ monkeypatch.setattr(
+ "storage.projects_service.archive_project",
+ lambda *args, **kwargs: (_ for _ in ()).throw(
+ AssertionError("remote project archive reached the local project store")
+ ),
+ )
+
+ response = client.delete(
+ "/api/projects/proj-local",
+ 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"
+
+
@pytest.mark.parametrize(
("path", "json_body", "write_target"),
[
diff --git a/vibe/api.py b/vibe/api.py
index e48887d8f..ea05ec424 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -1129,6 +1129,39 @@ def client_config_payload(config: V2Config) -> dict:
return payload
+_REMOTE_CONFIG_UI_FIELDS = (
+ "instance_name",
+ "default_instance_name",
+ "chat_message_font_size",
+ "show_agent_activity",
+ "show_tool_calls",
+)
+
+
+def remote_config_payload(config: V2Config) -> dict:
+ """Return the explicit remote-safe projection of generic configuration.
+
+ Instance role determines which remote routes a caller may use, but it does
+ not make the caller trusted to inspect local filesystem layout, executable
+ paths, or runtime configuration. Keep this as an allowlist so new local
+ settings remain local by default.
+ """
+
+ payload = client_config_payload(config)
+ ui_payload = payload.get("ui")
+ return {
+ "mode": payload.get("mode"),
+ "version": payload.get("version"),
+ "setup_state": payload.get("setup_state"),
+ "language": payload.get("language"),
+ "ui": {
+ key: ui_payload[key]
+ for key in _REMOTE_CONFIG_UI_FIELDS
+ if isinstance(ui_payload, dict) and key in ui_payload
+ },
+ }
+
+
def _merge_legacy_discord_guild_scope_fields(
merged_payload: dict,
request_payload: dict,
diff --git a/vibe/authorization.py b/vibe/authorization.py
index 7adfe3efe..32923226b 100644
--- a/vibe/authorization.py
+++ b/vibe/authorization.py
@@ -348,6 +348,8 @@ _REMOTE_LOCAL_ONLY_HTTP_RULES = tuple(
("POST", r"^/api/settings$"),
("POST", r"^/api/settings/thread$"),
("DELETE", r"^/api/settings/thread$"),
+ ("GET", r"^/api/bind-codes$"),
+ ("DELETE", r"^/api/projects/[^/]+$"),
)
)
@@ -399,7 +401,6 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(
frozenset({"PUT"}),
r"^/api/resource-policies/[^/]+/[^/]+$",
),
- (frozenset({"DELETE"}), r"^/api/projects/[^/]+$"),
(
frozenset({"GET", "HEAD"}),
r"^/api/(?:projects/[^/]+/agents-md|global-prompts)$",
@@ -430,7 +431,6 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(
r"^/api/harness/(?:counts|tasks|watches|runs|bootstrap|runs/[^/]+)$",
),
(frozenset({"GET", "HEAD"}), r"^/api/users$"),
- (frozenset({"GET", "HEAD"}), r"^/api/bind-codes$"),
)
)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 418ddecc1..3ac65efd5 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -3626,33 +3626,15 @@ def config_get():
# default is never mistaken for a completed setup. The write side
# (``save_config``) already creates the file on the first real save.
config = settings_service.load_config_or_default()
- payload = api.client_config_payload(config)
- payload["capabilities"] = {"model_hub": {"enabled": is_model_hub_enabled()}}
authorization_context = getattr(g, "authorization_context", None)
- if authorization_context is not None and authorization_context.can_manage_instance:
+ if authorization_context is None or not authorization_context.is_remote:
+ payload = api.client_config_payload(config)
+ payload["capabilities"] = {"model_hub": {"enabled": is_model_hub_enabled()}}
return jsonify(payload)
- ui_payload = payload.get("ui")
- return jsonify(
- {
- "mode": payload.get("mode"),
- "version": payload.get("version"),
- "setup_state": payload.get("setup_state"),
- "language": payload.get("language"),
- "capabilities": payload.get("capabilities"),
- "ui": {
- key: ui_payload[key]
- for key in (
- "instance_name",
- "default_instance_name",
- "chat_message_font_size",
- "show_agent_activity",
- "show_tool_calls",
- )
- if isinstance(ui_payload, dict) and key in ui_payload
- },
- }
- )
+ payload = api.remote_config_payload(config)
+ payload["capabilities"] = {"model_hub": {"enabled": is_model_hub_enabled()}}
+ return jsonify(payload)
_MODEL_HUB_SERVICE = None