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(auth): close remaining remote local-operation gaps

cyha64e8543dbe6
diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.py
index d2d63a62c..778c5ad0f 100644
--- a/tests/test_instance_authorization.py
+++ b/tests/test_instance_authorization.py
@@ -195,7 +195,15 @@ def test_remote_http_policy_defaults_local_machine_and_unknown_routes_to_local_o
("POST", "/api/dock/pins", REMOTE_HTTP_ALLOWED),
("POST", "/api/web-push/subscriptions", REMOTE_HTTP_ALLOWED),
("GET", "/api/harness/runs/run-1", REMOTE_HTTP_LOCAL_ONLY),
- ("GET", "/api/users", REMOTE_HTTP_ALLOWED),
+ ("GET", "/api/users", REMOTE_HTTP_LOCAL_ONLY),
+ ("HEAD", "/api/users", REMOTE_HTTP_LOCAL_ONLY),
+ ("GET", "/api/skills/check", REMOTE_HTTP_LOCAL_ONLY),
+ ("HEAD", "/api/skills/find", REMOTE_HTTP_LOCAL_ONLY),
+ ("POST", "/api/vault/requests/access", REMOTE_HTTP_LOCAL_ONLY),
+ ("POST", "/api/vault/requests/sign", REMOTE_HTTP_LOCAL_ONLY),
+ ("POST", "/api/show-pages/ses-1/rotate-share", REMOTE_HTTP_LOCAL_ONLY),
+ ("POST", "/api/show-pages/ses-1/share-id", REMOTE_HTTP_LOCAL_ONLY),
+ ("POST", "/api/show-pages/ses-1/ensure", 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),
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 1f8aa8246..cfadffa54 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -1680,6 +1680,49 @@ def test_remote_show_page_icon_upload_is_blocked_before_filesystem_access(
assert response.get_json()["code"] == "remote_execution_disabled"
+ ("path", "json_body", "api_method"),
+ [
+ ("/api/show-pages/ses-local/rotate-share", {}, "rotate_show_page_share"),
+ (
+ "/api/show-pages/ses-local/share-id",
+ {"share_id": "remote-link"},
+ "set_show_page_share_id",
+ ),
+ ],
+)
+def test_remote_show_page_public_link_mutations_are_blocked_before_store_access(
+ monkeypatch,
+ tmp_path,
+ path,
+ json_body,
+ api_method,
+):
+ 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_show_page_write(*args, **kwargs):
+ raise AssertionError("remote public-link mutation reached the Show Page store")
+
+ monkeypatch.setattr(api, api_method, unexpected_show_page_write)
+ response = client.post(
+ 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"
+
+
@pytest.mark.parametrize(
("path", "local_only"),
[
@@ -1740,6 +1783,8 @@ def test_remote_agent_definition_mutations_are_blocked_before_api_calls(
@pytest.mark.parametrize(
("method", "path", "json_body", "api_method"),
[
+ ("GET", "/api/skills/check", None, "check_skills"),
+ ("GET", "/api/skills/find?q=memory", None, "find_skills"),
("POST", "/api/skills/preview", {"source": "./local-skill"}, "preview_skill_source"),
("POST", "/api/skills", {"source": "gh:owner/repo"}, "add_skill"),
("POST", "/api/skills/update", {"name": "demo"}, "update_skill"),
@@ -1747,7 +1792,7 @@ def test_remote_agent_definition_mutations_are_blocked_before_api_calls(
("DELETE", "/api/skills/demo", None, "remove_skill"),
],
)
-def test_remote_skill_mutations_are_blocked_before_api_calls(
+def test_remote_skill_operations_are_blocked_before_api_calls(
monkeypatch,
tmp_path,
method,
@@ -1784,6 +1829,8 @@ def test_remote_skill_mutations_are_blocked_before_api_calls(
@pytest.mark.parametrize(
("method", "path", "json_body", "api_method"),
[
+ ("POST", "/api/vault/requests/access", {"secret_name": "REMOTE_SECRET"}, "request_vault_access"),
+ ("POST", "/api/vault/requests/sign", {"secret_name": "REMOTE_SECRET"}, "request_vault_sign"),
("POST", "/api/vault/secrets", {"name": "REMOTE_SECRET"}, "create_vault_secret"),
("PATCH", "/api/vault/secrets/REMOTE_SECRET", {"description": "changed"}, "update_vault_secret"),
("DELETE", "/api/vault/secrets/REMOTE_SECRET", None, "delete_vault_secret"),
@@ -1829,12 +1876,13 @@ def test_remote_vault_mutations_are_blocked_before_api_calls(
@pytest.mark.parametrize(
("method", "path", "json_body", "api_method"),
[
+ ("GET", "/api/users", None, "get_users"),
("POST", "/api/users", {"platform": "slack", "users": {"U1": {"enabled": True}}}, "save_users"),
("POST", "/api/users/U1/admin", {"platform": "slack", "is_admin": True}, "toggle_admin"),
("DELETE", "/api/users/U1", None, "remove_user"),
],
)
-def test_remote_im_user_mutations_are_blocked_before_api_calls(
+def test_remote_im_user_operations_are_blocked_before_api_calls(
monkeypatch,
tmp_path,
method,
diff --git a/vibe/authorization.py b/vibe/authorization.py
index 5d787d745..091e7326c 100644
--- a/vibe/authorization.py
+++ b/vibe/authorization.py
@@ -362,6 +362,12 @@ _REMOTE_LOCAL_ONLY_HTTP_RULES = tuple(
("GET", r"^/api/vault/(?:pubkey|agent/pubkey|sandbox/root-metadata|vmk)$"),
("GET", r"^/api/global-prompts$"),
("POST", r"^/api/show-pages/[^/]+/visibility$"),
+ ("POST", r"^/api/show-pages/[^/]+/(?:rotate-share|share-id)$"),
+ ("GET", r"^/api/skills/(?:check|find)$"),
+ ("HEAD", r"^/api/skills/(?:check|find)$"),
+ ("POST", r"^/api/vault/requests/(?:access|sign)$"),
+ ("GET", r"^/api/users$"),
+ ("HEAD", r"^/api/users$"),
)
)
@@ -393,7 +399,7 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(
),
(
frozenset({"POST"}),
- r"^/api/show-pages/[^/]+/(?:ensure|rotate-share|share-id)$",
+ r"^/api/show-pages/[^/]+/ensure$",
),
(frozenset({"GET", "HEAD"}), r"^/api/dock$"),
(frozenset({"POST"}), r"^/api/dock/pins$"),
@@ -417,7 +423,6 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(
frozenset({"GET", "HEAD"}),
r"^/api/projects/[^/]+/agents-md$",
),
- (frozenset({"GET", "HEAD"}), r"^/api/skills/(?:check|find)$"),
(
frozenset({"GET", "HEAD"}),
r"^/api/models/(?:sources|agents|events|runtime/status)$",
@@ -442,7 +447,6 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(
frozenset({"GET", "HEAD"}),
r"^/api/harness/counts$",
),
- (frozenset({"GET", "HEAD"}), r"^/api/users$"),
)
)