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(vault): sandbox iframe was a full-screen overlay → black screen on Protected tier (#828)

Call White5954a60d0ac6
diff --git a/tests/test_ui_show_pages.py b/tests/test_ui_show_pages.py
index 0de37fb45..11456066d 100644
--- a/tests/test_ui_show_pages.py
+++ b/tests/test_ui_show_pages.py
@@ -841,6 +841,7 @@ def test_private_show_page_sets_show_event_write_cookie(monkeypatch, tmp_path):
# 'self' (not 'none'): the workbench frames a private Show Page in the chat
# view (same origin); cross-origin framing stays blocked.
assert response.headers["content-security-policy"] == "frame-ancestors 'self'"
+ assert "permissions-policy" not in response.headers
def test_public_show_page_clears_show_event_write_cookie(monkeypatch, tmp_path):
@@ -855,7 +856,9 @@ def test_public_show_page_clears_show_event_write_cookie(monkeypatch, tmp_path):
cookies = "\n".join(response.headers.getlist("set-cookie"))
assert "vibe_show_event_token=" in cookies
assert "Max-Age=0" in cookies
+ assert response.headers["content-security-policy"] == "frame-ancestors 'self'"
assert "sandbox.avibe.bot" not in response.headers.get("content-security-policy", "")
+ assert "permissions-policy" not in response.headers
def test_show_events_stream_replays_all_persisted_pages_before_live(monkeypatch, tmp_path):
diff --git a/tests/test_vault_rest.py b/tests/test_vault_rest.py
index 70a9f6a02..013f52ed1 100644
--- a/tests/test_vault_rest.py
+++ b/tests/test_vault_rest.py
@@ -193,6 +193,22 @@ def test_rest_security_headers_delegate_webauthn_to_sandbox_only():
assert "frame-src 'self' https://sandbox.avibe.bot" in response.headers["Content-Security-Policy"]
+def test_spa_document_security_headers_delegate_webauthn_to_sandbox_only():
+ client = app.test_client()
+
+ response = client.request("HEAD", "/vaults", base_url="http://127.0.0.1:5123")
+
+ assert response.status_code == 200
+ assert "text/html" in response.headers["content-type"]
+ permissions = response.headers["Permissions-Policy"]
+ assert 'publickey-credentials-get=("https://sandbox.avibe.bot")' in permissions
+ assert 'publickey-credentials-create=("https://sandbox.avibe.bot")' in permissions
+ assert 'clipboard-write=(self "https://sandbox.avibe.bot")' in permissions
+ assert "publickey-credentials-get=(self" not in permissions
+ assert "publickey-credentials-create=(self" not in permissions
+ assert "frame-src 'self' https://sandbox.avibe.bot" in response.headers["Content-Security-Policy"]
+
+
def test_rest_vault_authz_options_use_sandbox_rp_origin():
client = app.test_client()
diff --git a/ui/src/lib/vaultSandboxClient.ts b/ui/src/lib/vaultSandboxClient.ts
index 169ae7f39..3372128ba 100644
--- a/ui/src/lib/vaultSandboxClient.ts
+++ b/ui/src/lib/vaultSandboxClient.ts
@@ -240,13 +240,18 @@ export class VaultSandboxClient {
iframe.referrerPolicy = 'no-referrer';
iframe.style.position = 'fixed';
iframe.style.inset = '0';
- iframe.style.width = '100vw';
- iframe.style.height = '100vh';
iframe.style.border = '0';
iframe.style.background = 'transparent';
iframe.style.zIndex = '2147483647';
- iframe.style.pointerEvents = 'none';
iframe.style.colorScheme = 'normal';
+ // At rest the sandbox is a headless RPC worker: keep it in the DOM (so
+ // postMessage works) but 0-sized + hidden so it never covers the app. It
+ // only expands to a full-screen overlay while an interactive ceremony is
+ // active — see setInteractive().
+ iframe.style.width = '0';
+ iframe.style.height = '0';
+ iframe.style.visibility = 'hidden';
+ iframe.style.pointerEvents = 'none';
const client = new VaultSandboxClient(iframe);
iframe.src = VAULT_SANDBOX_IFRAME_URL;
@@ -264,7 +269,13 @@ export class VaultSandboxClient {
private setInteractive(active: boolean): void {
this.interactiveDepth += active ? 1 : -1;
this.interactiveDepth = Math.max(0, this.interactiveDepth);
- this.iframe.style.pointerEvents = this.interactiveDepth > 0 ? 'auto' : 'none';
+ const interactive = this.interactiveDepth > 0;
+ // Expand to a full-screen overlay only while a ceremony is active; otherwise
+ // collapse to a hidden 0-size worker so the sandbox never covers the app.
+ this.iframe.style.width = interactive ? '100vw' : '0';
+ this.iframe.style.height = interactive ? '100vh' : '0';
+ this.iframe.style.visibility = interactive ? 'visible' : 'hidden';
+ this.iframe.style.pointerEvents = interactive ? 'auto' : 'none';
}
private waitForReady(): Promise<ReadyMessage> {
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 482b4f59b..24bc29871 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -2159,9 +2159,8 @@ def _is_show_page_response_path(path: str) -> bool:
return path == "/show" or path.startswith("/show/") or path == "/p" or path.startswith("/p/")
-def add_vault_sandbox_security_headers(response: Response) -> Response:
- if _is_show_page_response_path(request.path):
+def _apply_vault_sandbox_security_headers(response: FastAPIResponse, path: str) -> FastAPIResponse:
+ if _is_show_page_response_path(path):
return response
response.headers["Permissions-Policy"] = VAULT_SANDBOX_PERMISSIONS_POLICY
response.headers["Content-Security-Policy"] = _merge_csp_frame_src(
@@ -2170,6 +2169,12 @@ def add_vault_sandbox_security_headers(response: Response) -> Response:
return response
+async def add_vault_sandbox_security_headers(starlette_request: FastAPIRequest, call_next):
+ response = await call_next(starlette_request)
+ return _apply_vault_sandbox_security_headers(response, starlette_request.url.path)
+
+
@app.after_request
def renew_remote_access_cookie(response: Response) -> Response:
# Logout handler explicitly clears the session cookie; never re-issue it.
@@ -8559,12 +8564,12 @@ def _rewrite_show_runtime_location(session_id: str, location: str, *, external_p
def _with_show_event_write_cookie(response: Response, session_id: str, *, enabled: bool) -> Response:
+ # 'self' (not 'none') so the workbench can frame a Show Page in the chat
+ # view — same origin as the page — while cross-origin clickjacking stays
+ # blocked. Direct navigation is unaffected (frame-ancestors only governs
+ # framing).
+ response.headers["Content-Security-Policy"] = "frame-ancestors 'self'"
if enabled:
- # 'self' (not 'none') so the workbench can frame a private Show Page in the
- # chat view — same origin as the page — while cross-origin clickjacking
- # stays blocked. Direct navigation is unaffected (frame-ancestors only
- # governs framing).
- response.headers["Content-Security-Policy"] = "frame-ancestors 'self'"
response.set_cookie(
SHOW_EVENT_WRITE_TOKEN_COOKIE,
show_event_write_token(session_id),
@@ -8769,8 +8774,8 @@ def _ui_static_file_response(resolved_path: Path, *, content_type: str, cache_co
return Response(content=compressed, headers=headers)
[email protected]("/", defaults={"path": ""})
[email protected]("/<path:path>")
[email protected]("/", defaults={"path": ""}, methods=["GET", "HEAD"])
[email protected]("/<path:path>", methods=["GET", "HEAD"])
def serve_static(path):
"""Serve static files from ui/dist, with SPA fallback to index.html."""
ui_dist = get_ui_dist_path()