From 924deebeaae756b688090d25642dfe1b3df52b5e Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:51:15 -0500 Subject: [PATCH 01/16] fix: pass a plugin's git source to git clone only as a repository --- backend/app/engine/marketplaces.py | 4 +++- backend/tests/test_marketplace_sources.py | 25 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 backend/tests/test_marketplace_sources.py diff --git a/backend/app/engine/marketplaces.py b/backend/app/engine/marketplaces.py index 1591311..fc6b9e5 100644 --- a/backend/app/engine/marketplaces.py +++ b/backend/app/engine/marketplaces.py @@ -68,7 +68,9 @@ def _url(source: str) -> str: def _clone(url: str, dest: Path, ref: str = "", sha: str = "", token: str = "") -> None: - _git("clone", *([] if sha else ["--depth", "1"]), *(["--branch", ref] if ref and not sha else []), _url(url), str(dest), token=token) + if not url.strip() or any(v.startswith("-") for v in (url.strip(), ref, sha)): + raise CommandError("A git source needs a repository URL or owner/name, and its ref and sha cannot start with -") + _git("clone", *([] if sha else ["--depth", "1"]), *(["--branch", ref] if ref and not sha else []), "--", _url(url), str(dest), token=token) if sha: _git("checkout", "--quiet", sha, cwd=dest) diff --git a/backend/tests/test_marketplace_sources.py b/backend/tests/test_marketplace_sources.py new file mode 100644 index 0000000..e6ea511 --- /dev/null +++ b/backend/tests/test_marketplace_sources.py @@ -0,0 +1,25 @@ +import pytest + +from app.engine import marketplaces +from app.engine.commands import CommandError + + +@pytest.fixture +def git_calls(monkeypatch): + calls = [] + monkeypatch.setattr(marketplaces, "_git", lambda *args, **kw: calls.append(args) or "") + return calls + + +@pytest.mark.parametrize("url, ref, sha", [("--upload-pack=true", "", ""), ("owner/name", "-b", ""), ("owner/name", "", "--orphan"), ("", "", "")]) +def test_a_git_source_that_reads_as_an_option_is_refused(tmp_path, git_calls, url, ref, sha): + with pytest.raises(CommandError): + marketplaces._clone(url, tmp_path / "dest", ref, sha) + assert git_calls == [] + + +def test_a_git_source_is_passed_after_the_end_of_options(tmp_path, git_calls): + marketplaces._clone("owner/name", tmp_path / "dest", "main") + args = git_calls[0] + assert args[args.index("--") + 1] == "https://github.com/owner/name.git" + assert args[-1] == str(tmp_path / "dest") From ed3ea161e0daac9fc7290d5066351f428ebc595f Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:51:40 -0500 Subject: [PATCH 02/16] fix: check the tool deny list first on the Claude Code engine --- backend/app/engine/claude_code.py | 17 +++++++++++++---- backend/tests/test_claude_code_permissions.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 backend/tests/test_claude_code_permissions.py diff --git a/backend/app/engine/claude_code.py b/backend/app/engine/claude_code.py index 78a4eae..7820731 100644 --- a/backend/app/engine/claude_code.py +++ b/backend/app/engine/claude_code.py @@ -91,6 +91,14 @@ def route(settings: dict) -> str: return "api" +def decision_for(short: str, settings: dict, conversation_id: str | None = None) -> str: + if short in (settings.get("toolDeny") or []): + return "deny" + if settings.get("permissionMode", "ask") == "auto" or short in (settings.get("toolAllow") or []) or tools.chat_allowed(conversation_id): + return "allow" + return "ask" + + @command("claudecode.status", "Claude Code", mutates=False, description="Whether the Claude Code CLI is installed (its path and version) and which engine answers chats now: api (the Anthropic API key) or claude-code (the person's own Claude Code sign-in). programs says the same for each agent program FormAT looks for: claude, codex, cursor and antigravity (finding is runs, broken or missing; said is the sentence to show).") def status() -> dict: @@ -245,12 +253,13 @@ def can_use(request_id: str, req: dict) -> None: status_of(tid, "denied") return respond(request_id, {"behavior": "deny", "message": "Plan mode is on in Format: describe the plan and the person will switch modes to carry it out."}) short = ALLOW_NAMES.get(name, name) - if mode == "auto" or short in (current().get("toolAllow") or []) or tools.chat_allowed(conversation_id): - status_of(tid, "running") - return respond(request_id, {"behavior": "allow", "updatedInput": inp}) - if short in (current().get("toolDeny") or []): + decided = decision_for(short, current(), conversation_id) + if decided == "deny": status_of(tid, "denied") return respond(request_id, {"behavior": "deny", "message": f"The person does not allow {name} in Format."}) + if decided == "allow": + status_of(tid, "running") + return respond(request_id, {"behavior": "allow", "updatedInput": inp}) status_of(tid, "waiting") update(mid, blocks, meta) shown, shown_input = view_of(name, inp) diff --git a/backend/tests/test_claude_code_permissions.py b/backend/tests/test_claude_code_permissions.py new file mode 100644 index 0000000..3af4ba8 --- /dev/null +++ b/backend/tests/test_claude_code_permissions.py @@ -0,0 +1,14 @@ +import pytest + +from app.engine import claude_code + + +@pytest.mark.parametrize("settings", [{"permissionMode": "auto"}, {"toolAllow": ["bash"]}, {}]) +def test_the_deny_list_wins_on_the_claude_code_engine(settings): + assert claude_code.decision_for("bash", settings | {"toolDeny": ["bash"]}) == "deny" + + +def test_the_claude_code_engine_still_allows_and_asks(): + assert claude_code.decision_for("bash", {"permissionMode": "auto"}) == "allow" + assert claude_code.decision_for("bash", {"toolAllow": ["bash"]}) == "allow" + assert claude_code.decision_for("edit", {"toolAllow": ["bash"], "toolDeny": ["bash"]}) == "ask" From 5b0520dada4c5387c5b7131df73063ba803f9829 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:55:35 -0500 Subject: [PATCH 03/16] fix: show the other-devices pairing link only in the FormAT window --- backend/app/engine/agents.py | 6 ++++ backend/app/routers/commands.py | 5 ++- backend/app/routers/mcp_http.py | 2 +- backend/tests/test_device_pairing_link.py | 37 +++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 backend/tests/test_device_pairing_link.py diff --git a/backend/app/engine/agents.py b/backend/app/engine/agents.py index 8b01838..fbdd271 100644 --- a/backend/app/engine/agents.py +++ b/backend/app/engine/agents.py @@ -51,6 +51,12 @@ def require_outside(client: str, channel: str, cid: str, params: dict | None) -> raise CommandError("Only the person, in FormAT's window, can change whether outside agents may use FormAT.", 403) +def outside_result(cid: str, result): + if cid.startswith("devices.") and isinstance(result, dict) and result.get("pairUrl"): + return result | {"pairUrl": None, "qr": None, "pairing": "Only FormAT's window shows the pairing link"} + return result + + @command("agents.status", "Outside agents", mutates=False, description="Whether outside agents (coding agents over MCP) may use Format (outsideAgents: ask, allowed or blocked) and which ones have called since the engine started.") def status() -> dict: diff --git a/backend/app/routers/commands.py b/backend/app/routers/commands.py index ea5e34f..bf0e70c 100644 --- a/backend/app/routers/commands.py +++ b/backend/app/routers/commands.py @@ -41,10 +41,13 @@ def describe(cid: str) -> Any: @router.post("/commands/{cid}") def run(request: Request, cid: str, params: dict | None = Body(default=None), x_format_agent: str | None = Header(default=None)) -> Any: - if x_format_agent or not window_key.is_window(request.scope): + outside = bool(x_format_agent) or not window_key.is_window(request.scope) + if outside: try: agents.require_outside(x_format_agent or "", "stdio" if x_format_agent else "rest", cid, params) except CommandError as exc: return JSONResponse({"ok": False, "command": cid, "error": str(exc)}, status_code=exc.status) status, body = _run(cid, params) + if outside and status == 200: + body = body | {"result": agents.outside_result(cid, body["result"])} return body if status == 200 else JSONResponse(body, status_code=status) diff --git a/backend/app/routers/mcp_http.py b/backend/app/routers/mcp_http.py index fd84a03..b0305e7 100644 --- a/backend/app/routers/mcp_http.py +++ b/backend/app/routers/mcp_http.py @@ -13,7 +13,7 @@ async def _call(cid: str, params: dict, client: str): def run(): agents.require_outside(client, "http", cid, params) - return dispatch(cid, params) + return agents.outside_result(cid, dispatch(cid, params)) return await anyio.to_thread.run_sync(run) diff --git a/backend/tests/test_device_pairing_link.py b/backend/tests/test_device_pairing_link.py new file mode 100644 index 0000000..c9b8e57 --- /dev/null +++ b/backend/tests/test_device_pairing_link.py @@ -0,0 +1,37 @@ +import json + +import pytest +from conftest import set_policy + +from app.engine import devices + + +@pytest.fixture +def listening(monkeypatch): + monkeypatch.setattr(devices, "running", lambda: True) + monkeypatch.setattr(devices, "lan_addresses", lambda: ["192.0.2.10"]) + set_policy("allowed") + yield devices._secret() + + +def test_the_window_gets_the_pairing_link(client, listening): + result = client.post("/api/commands/devices.status", json={}).json()["result"] + assert listening in result["pairUrl"] and result["qr"] + + +@pytest.mark.parametrize("headers", [{"x-format-agent": "some agent"}, None]) +def test_an_outside_agent_never_gets_the_pairing_link(client, bare, listening, headers): + via = client if headers else bare + r = via.post("/api/commands/devices.status", json={}, headers=headers or {}) + assert r.status_code == 200 + assert r.json()["result"]["on"] is True + assert listening not in r.text and r.json()["result"]["pairUrl"] is None + + +def test_an_mcp_agent_never_gets_the_pairing_link(client, listening): + from test_f3_mcp import call, session + + got = call(client, "run_command", {"id": "devices.status", "params": {}}, session(client)) + assert not got.get("isError") + assert listening not in json.dumps(got) + assert json.loads(got["content"][0]["text"])["pairUrl"] is None From 2a1dd307ca7e29688a4edf291e355b7372707c53 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:56:40 -0500 Subject: [PATCH 04/16] fix: keep sandboxed commands on macOS from starting apps outside the sandbox --- backend/app/engine/sandbox.py | 3 ++- backend/tests/test_sandbox_profile.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 backend/tests/test_sandbox_profile.py diff --git a/backend/app/engine/sandbox.py b/backend/app/engine/sandbox.py index d394338..9eee0b5 100644 --- a/backend/app/engine/sandbox.py +++ b/backend/app/engine/sandbox.py @@ -55,7 +55,8 @@ def wrap(argv: list[str], root: Path, network: bool) -> list[str]: return cmd + argv if k == "sandbox-exec": hidden = "".join(f'(deny file-read* (subpath "{h}"))' for h in _hidden()) - profile = ("(version 1)(allow default)(deny file-write*)" + profile = ("(version 1)(allow default)(deny file-write*)(deny lsopen)(deny appleevent-send)" + '(deny mach-lookup (global-name "com.apple.coreservices.launchservicesd") (global-name "com.apple.coreservices.quarantine-resolver"))' f'(allow file-write* (subpath "{folder}") (subpath "/private/tmp") (subpath "/private/var/folders") (literal "/dev/null") (literal "/dev/tty"))' f'{hidden}(allow file-read* (subpath "{folder}"))' + ("" if network else "(deny network*)")) return ["sandbox-exec", "-p", profile] + argv diff --git a/backend/tests/test_sandbox_profile.py b/backend/tests/test_sandbox_profile.py new file mode 100644 index 0000000..5a5a82c --- /dev/null +++ b/backend/tests/test_sandbox_profile.py @@ -0,0 +1,21 @@ +import shutil +import subprocess +import sys + +import pytest + +from app.engine import sandbox + + +def test_the_macos_profile_keeps_commands_from_starting_apps(tmp_path, monkeypatch): + monkeypatch.setattr(sandbox, "kind", lambda: "sandbox-exec") + profile = sandbox.wrap(["true"], tmp_path, False)[2] + assert "(deny lsopen)" in profile and "(deny appleevent-send)" in profile + assert "com.apple.coreservices.launchservicesd" in profile + + +@pytest.mark.skipif(sys.platform != "darwin" or shutil.which("sandbox-exec") is None, reason="sandbox-exec runs only on macOS") +def test_a_sandboxed_command_cannot_hand_work_to_an_app(tmp_path): + assert subprocess.run(sandbox.wrap(["/usr/bin/true"], tmp_path, False)).returncode == 0 + opened = subprocess.run(sandbox.wrap(["/usr/bin/open", "-g", "-a", "Finder"], tmp_path, False), capture_output=True) + assert opened.returncode != 0 From eec4bde85e9dd59c8547e70ec7cb0b0513defc07 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:57:15 -0500 Subject: [PATCH 05/16] fix: keep the built-in browser off FormAT's own engine and window addresses --- backend/app/engine/browser.py | 20 ++++++++++++++++++++ backend/tests/test_browser_addresses.py | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 backend/tests/test_browser_addresses.py diff --git a/backend/app/engine/browser.py b/backend/app/engine/browser.py index 2da2bf5..bf3aa22 100644 --- a/backend/app/engine/browser.py +++ b/backend/app/engine/browser.py @@ -129,6 +129,7 @@ def _worker() -> None: return if fut is not None: fut.set_exception(CommandError(_state["error"], 503)) + ctx.route(own_origin, lambda route: route.abort("blockedbyclient")) page = ctx.pages[0] if ctx.pages else ctx.new_page() _state.update(open=True, error="") try: @@ -178,6 +179,23 @@ def _do(fn, wait: float = 60): raise CommandError("The browser did not answer in time", 504) from None +def own_origin(url: str) -> bool: + import ipaddress + from urllib.parse import urlsplit + try: + parts = urlsplit(url) + host = (parts.hostname or "").lower().rstrip(".") + port = parts.port or {"http": 80, "https": 443, "ws": 80, "wss": 443}.get(parts.scheme) + except ValueError: + return False + try: + loopback = ipaddress.ip_address(host).is_loopback or ipaddress.ip_address(host).is_unspecified + except ValueError: + loopback = host == "localhost" or host.endswith(".localhost") + from app.engine.devices import LAN_PORT + return loopback and port in (config.PORT, config.FRONTEND_PORT, config.FRONTEND_PORT + 1, LAN_PORT) + + def _url(u: str) -> str: u = (u or "").strip() if not u: @@ -186,6 +204,8 @@ def _url(u: str) -> str: u = ("http://" if u.startswith(("localhost", "127.0.0.1")) else "https://") + u if not u.startswith(("http://", "https://", "about:")): raise CommandError("The browser opens http and https pages") + if own_origin(u): + raise CommandError("The browser does not open FormAT's own engine or window; open it in FormAT itself") return u diff --git a/backend/tests/test_browser_addresses.py b/backend/tests/test_browser_addresses.py new file mode 100644 index 0000000..8da8cc0 --- /dev/null +++ b/backend/tests/test_browser_addresses.py @@ -0,0 +1,18 @@ +import pytest + +from app.core import config +from app.engine import browser +from app.engine.commands import CommandError + + +@pytest.mark.parametrize("url", [f"http://127.0.0.1:{config.PORT}/api/health", f"localhost:{config.PORT}/", f"http://[::1]:{config.PORT}/", + f"http://0.0.0.0:{config.PORT}/", f"http://app.localhost:{config.FRONTEND_PORT}/", "http://127.0.0.1:8492/"]) +def test_the_browser_does_not_open_formats_own_addresses(url): + with pytest.raises(CommandError): + browser._url(url) + + +@pytest.mark.parametrize("url", ["localhost:3000", "http://127.0.0.1:8000/", "example.com", "https://example.com:8490/"]) +def test_the_browser_still_opens_other_local_and_public_pages(url): + assert browser._url(url).startswith(("http://", "https://")) + assert not browser.own_origin(browser._url(url)) From c4b54104b9c1761fdd5f0c193383edb55e64f5bb Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:58:03 -0500 Subject: [PATCH 06/16] fix: end a bash tool command's whole process tree on stop, timeout and engine shutdown --- backend/app/engine/tools.py | 25 ++++++++++++++++++++++++- backend/app/routers/__init__.py | 3 ++- backend/tests/test_tool_processes.py | 23 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 backend/tests/test_tool_processes.py diff --git a/backend/app/engine/tools.py b/backend/app/engine/tools.py index 652eede..fd28eca 100644 --- a/backend/app/engine/tools.py +++ b/backend/app/engine/tools.py @@ -88,6 +88,8 @@ _waits: dict[str, dict] = {} _waits_lock = threading.Lock() +_procs: set[subprocess.Popen] = set() +_procs_lock = threading.Lock() def workspace(conversation_id: str) -> Path: @@ -470,6 +472,16 @@ def _bash(root: Path, args: dict, on_output, cancel: threading.Event) -> tuple[s env = bash_env(root) proc = subprocess.Popen(argv, cwd=root, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, env=env, start_new_session=os.name != "nt") + with _procs_lock: + _procs.add(proc) + try: + return _watch(proc, on_output, cancel, timeout) + finally: + with _procs_lock: + _procs.discard(proc) + + +def _watch(proc: subprocess.Popen, on_output, cancel: threading.Event, timeout: int) -> tuple[str, bool]: chunks: list[str] = [] done = threading.Event() @@ -505,10 +517,21 @@ def _kill(proc: subprocess.Popen) -> None: if os.name != "nt": os.killpg(proc.pid, 15) else: - proc.terminate() + subprocess.run(["taskkill", "/PID", str(proc.pid), "/T", "/F"], capture_output=True, timeout=10, + creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0)) proc.wait(3) except Exception: try: + if os.name != "nt": + os.killpg(proc.pid, 9) proc.kill() except Exception: pass + + +def stop_all() -> None: + with _procs_lock: + running = list(_procs) + for proc in running: + if proc.poll() is None: + _kill(proc) diff --git a/backend/app/routers/__init__.py b/backend/app/routers/__init__.py index 6eeeff9..ab04ee8 100644 --- a/backend/app/routers/__init__.py +++ b/backend/app/routers/__init__.py @@ -4,7 +4,7 @@ from app.core import config, instance from app.engine import (agents, browser, claude_code, cmd_account, cmd_app, cmd_artifact, cmd_chat, cmd_connector, cmd_conversation, cmd_demo, cmd_files, cmd_memory, cmd_message, cmd_project, - cmd_settings, cmd_skill, cmd_terminal, demos, devices, documents, events, marketplaces, native, plugins, sandbox, schedules, store, terminal) + cmd_settings, cmd_skill, cmd_terminal, demos, devices, documents, events, marketplaces, native, plugins, sandbox, schedules, store, terminal, tools) from app.routers import commands, files, stream, system, terminal_socket ROUTERS = [system.router, commands.router, stream.router, terminal_socket.router, files.router, devices.router, browser.router] @@ -33,3 +33,4 @@ async def shutdown() -> None: browser.stop() schedules.stop() terminal.close_all() + tools.stop_all() diff --git a/backend/tests/test_tool_processes.py b/backend/tests/test_tool_processes.py new file mode 100644 index 0000000..74904ac --- /dev/null +++ b/backend/tests/test_tool_processes.py @@ -0,0 +1,23 @@ +import os +import threading +import time + +import pytest + +from app.engine import tools + + +@pytest.mark.skipif(os.name == "nt", reason="uses a POSIX shell command") +def test_stopping_the_engine_ends_running_bash_tool_commands(tmp_path): + got = {} + worker = threading.Thread(target=lambda: got.update(out=tools._bash(tmp_path, {"command": "sleep 30 & sleep 30"}, lambda _: None, threading.Event()))) + worker.start() + deadline = time.monotonic() + 10 + while not tools._procs and time.monotonic() < deadline: + time.sleep(0.05) + assert tools._procs + started = time.monotonic() + tools.stop_all() + worker.join(10) + assert not worker.is_alive() and time.monotonic() - started < 10 + assert not tools._procs From 01804bc68497fa2db403f057ef304be84a2b4208 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:58:40 -0500 Subject: [PATCH 07/16] fix: keep a connector signed in when a token refresh cannot reach the server --- backend/app/engine/oauth.py | 18 ++++++++--- backend/tests/test_oauth_refresh.py | 49 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 backend/tests/test_oauth_refresh.py diff --git a/backend/app/engine/oauth.py b/backend/app/engine/oauth.py index 002131c..3c10f7b 100644 --- a/backend/app/engine/oauth.py +++ b/backend/app/engine/oauth.py @@ -19,7 +19,9 @@ class OAuthError(Exception): - pass + def __init__(self, message: str, transient: bool = False): + super().__init__(message) + self.transient = transient def redirect_uri() -> str: @@ -121,9 +123,16 @@ def _token(saved: dict, data: dict) -> dict: try: with httpx.Client(timeout=TIMEOUT) as http: r = http.post(saved["token_endpoint"], data={k: v for k, v in data.items() if v}, auth=auth, headers={"Accept": "application/json"}) + except httpx.HTTPError as exc: + raise OAuthError(f"the token request failed: {exc}", transient=True) from None + if r.status_code == 429 or r.status_code >= 500: + raise OAuthError(f"the sign-in server did not answer: HTTP {r.status_code}", transient=True) + try: body = r.json() - except (httpx.HTTPError, ValueError) as exc: + except ValueError as exc: raise OAuthError(f"the token request failed: {exc}") from None + if not isinstance(body, dict): + raise OAuthError(f"the server refused the sign-in: HTTP {r.status_code}") if r.status_code != 200 or not body.get("access_token"): raise OAuthError(f"the server refused the sign-in: {body.get('error_description') or body.get('error') or f'HTTP {r.status_code}'}") return {"access_token": body["access_token"], "refresh_token": body.get("refresh_token") or saved.get("refresh_token", ""), @@ -159,8 +168,9 @@ def access_token(row: dict) -> str: if not saved.get("refresh_token"): raise OAuthError("no refresh token") fresh = _token(saved, {"grant_type": "refresh_token", "refresh_token": saved["refresh_token"], "resource": saved.get("resource", "")}) - except OAuthError: - sign_out(current) + except OAuthError as exc: + if not exc.transient: + sign_out(current) return "" _save(row["id"], saved | fresh) return fresh["access_token"] diff --git a/backend/tests/test_oauth_refresh.py b/backend/tests/test_oauth_refresh.py new file mode 100644 index 0000000..598fc10 --- /dev/null +++ b/backend/tests/test_oauth_refresh.py @@ -0,0 +1,49 @@ +import json +import time +import types + +import httpx +import pytest + +from app.engine import oauth + +REAL_CLIENT = httpx.Client + + +@pytest.fixture +def connector(monkeypatch): + saved = {"client_id": "c", "token_endpoint": "https://auth.example.com/token", "access_token": "old", "refresh_token": "keep", + "expires_at": time.time() - 10, "lifetime": 3600} + row = {"id": "conn1", "oauth": json.dumps(saved)} + + def save(sql, args): + row["oauth"] = args[0] + monkeypatch.setattr(oauth, "store", types.SimpleNamespace(row=lambda *a: dict(row), run=save)) + return row + + +def answer(monkeypatch, handler): + monkeypatch.setattr(oauth.httpx, "Client", lambda **kw: REAL_CLIENT(transport=httpx.MockTransport(handler), **kw)) + + +def fail_to_connect(request): + raise httpx.ConnectError("network is down", request=request) + + +@pytest.mark.parametrize("handler", [fail_to_connect, lambda r: httpx.Response(503, text="busy"), lambda r: httpx.Response(429, json={})]) +def test_a_refresh_that_could_not_reach_the_server_keeps_the_sign_in(connector, monkeypatch, handler): + answer(monkeypatch, handler) + assert oauth.access_token(connector) == "" + assert json.loads(connector["oauth"])["refresh_token"] == "keep" + + +def test_a_refused_refresh_still_signs_out(connector, monkeypatch): + answer(monkeypatch, lambda r: httpx.Response(400, json={"error": "invalid_grant"})) + assert oauth.access_token(connector) == "" + assert "refresh_token" not in json.loads(connector["oauth"]) + + +def test_a_refresh_that_works_saves_the_new_token(connector, monkeypatch): + answer(monkeypatch, lambda r: httpx.Response(200, json={"access_token": "new", "expires_in": 3600})) + assert oauth.access_token(connector) == "new" + assert json.loads(connector["oauth"])["refresh_token"] == "keep" From f25e3328dd259d33c1ee473be1d056d0cf7f6100 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:59:13 -0500 Subject: [PATCH 08/16] fix: replace a skill of the same name only after its new copy is complete --- backend/app/engine/skills.py | 19 ++++++++++++-- backend/tests/test_skill_replace.py | 40 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 backend/tests/test_skill_replace.py diff --git a/backend/app/engine/skills.py b/backend/app/engine/skills.py index 83b86e1..7ea6975 100644 --- a/backend/app/engine/skills.py +++ b/backend/app/engine/skills.py @@ -1,6 +1,7 @@ import json import re import shutil +import time from pathlib import Path from app.core import config @@ -113,9 +114,23 @@ def _install(src: Path, fallback: str) -> dict: if len(files) > MAX_FILES: raise SkillError(f"a skill holds at most {MAX_FILES} files") dest = root() / name + stamp = time.time_ns() + incoming, previous = root() / f".{name}.incoming-{stamp}", root() / f".{name}.previous-{stamp}" + try: + shutil.copytree(src, incoming, ignore=shutil.ignore_patterns("__MACOSX", ".DS_Store", ".git")) + except OSError as exc: + shutil.rmtree(incoming, ignore_errors=True) + raise SkillError(f"the skill could not be copied, and any skill named {name} is unchanged: {exc}") from None if dest.exists(): - shutil.rmtree(dest) - shutil.copytree(src, dest, ignore=shutil.ignore_patterns("__MACOSX", ".DS_Store", ".git")) + dest.rename(previous) + try: + incoming.rename(dest) + except OSError: + if previous.exists(): + previous.rename(dest) + shutil.rmtree(incoming, ignore_errors=True) + raise + shutil.rmtree(previous, ignore_errors=True) _publish() return get(name) diff --git a/backend/tests/test_skill_replace.py b/backend/tests/test_skill_replace.py new file mode 100644 index 0000000..4e0ad1b --- /dev/null +++ b/backend/tests/test_skill_replace.py @@ -0,0 +1,40 @@ +import shutil + +import pytest + +from app.engine import skills + + +def make(folder, body): + folder.mkdir(parents=True) + (folder / "SKILL.md").write_text(f"---\nname: replace-check\ndescription: test skill\n---\n{body}\n", encoding="utf-8") + return folder + + +@pytest.fixture +def installed(tmp_path): + skills._install(make(tmp_path / "first", "first body"), "replace-check") + yield skills.root() / "replace-check" + shutil.rmtree(skills.root() / "replace-check", ignore_errors=True) + + +def test_a_failed_copy_leaves_the_existing_skill_in_place(tmp_path, installed, monkeypatch): + def broken(src, dst, **kw): + dst.mkdir() + raise OSError("disk full") + monkeypatch.setattr(skills.shutil, "copytree", broken) + with pytest.raises(skills.SkillError): + skills._install(make(tmp_path / "second", "second body"), "replace-check") + assert "first body" in (installed / "SKILL.md").read_text(encoding="utf-8") + assert not [p for p in skills.root().iterdir() if p.name.startswith(".replace-check")] + + +def test_installing_again_replaces_the_skill_and_leaves_nothing_behind(tmp_path, installed): + skills._install(make(tmp_path / "second", "second body"), "replace-check") + assert "second body" in (installed / "SKILL.md").read_text(encoding="utf-8") + assert not [p for p in skills.root().iterdir() if p.name.startswith(".replace-check")] + + +def test_saving_a_skill_from_its_own_folder_keeps_it(installed): + skills._install(installed, "replace-check") + assert "first body" in (installed / "SKILL.md").read_text(encoding="utf-8") From 6ff7557cb24e6b0c0afe39a177a6abe63af1a886 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sat, 28 Nov 2026 20:59:34 -0500 Subject: [PATCH 09/16] docs: log the engine hardening in the backend HASHOUT log --- backend/HASHOUT_LOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index d312636..03d0d25 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -1326,3 +1326,24 @@ Every read, classified. Public: `/api/health`, `/api/commands`, `/api/commands/{ The walk. `test_every_read_route_is_public_addressed_by_a_random_id_or_refused_without_the_window_key` takes every GET of the OpenAPI document; a new read that is in none of the three lists fails the test, and every private read must answer 403 with the refusal and must not echo the key. Seen failing with `PRIVATE_READS` emptied and with an added unlisted GET route; a new write route is refused by default (seen: 403), and the existing write walk fails if one answers without the key. Seen with the real engine (format_engine.py, the built window in Chromium, stand-in agent programs on PATH), from source and with FORMAT_WINDOW_KEY_STDOUT=1 and the global given by an initialization script as the shell does: the window with its key wrote (POST /api/uploads 200), ran a command (200) and read the frame (204 with no page open; 200 image/jpeg from the pane itself with the browser open); a local program without the key got 403 on the write, the frame and the socket ticket, 403 with a wrong key, and its command waited for the person's consent; a second claim got 409 (404 in the packaged mode); after a reload the page made no new claim and its writes still answered 200. Before this change the frame answered the local program (204). + +### Hardening after 0.32.0 (unreleased) · git sources, the deny list, pairing links, the macOS sandbox, the built-in browser, tool processes, connector refresh, skill replace +- refers-to: app/engine/marketplaces.py :: _clone; app/engine/claude_code.py :: decision_for; app/engine/agents.py :: outside_result; app/routers/commands.py :: run; app/routers/mcp_http.py :: _call; app/engine/sandbox.py :: wrap; app/engine/browser.py :: own_origin, _url, _worker; app/engine/tools.py :: _bash, _watch, _kill, stop_all; app/routers/__init__.py :: shutdown; app/engine/oauth.py :: OAuthError, _token, access_token; app/engine/skills.py :: _install +- kind: decision +- logged: unreleased + +Git sources. A plugin or marketplace git source, ref and sha that start with `-` are refused, and the URL goes after `--`, so git reads it only as a repository (tests/test_marketplace_sources.py). + +The deny list on the Claude Code route. `decision_for` checks toolDeny first, then auto mode, toolAllow and Allow for this chat, the same order as tools.decision_for on the API route (tests/test_claude_code_permissions.py). The Claude Code route still gets no sandbox of its own; that is left open. + +Pairing links. devices.status, devices.start and devices.forget return the pairing link and its QR code only to the window (a window key or a paired device). Every other caller, the REST route with or without `x-format-agent` and `/mcp`, gets pairUrl and qr as null and a `pairing` sentence; the listener itself still starts for them (tests/test_device_pairing_link.py). + +The macOS sandbox. The sandbox-exec profile also denies lsopen, appleevent-send and the LaunchServices lookups, so a sandboxed command cannot hand work to an app that would run outside the sandbox. Seen: `open -g -a Finder` exits 1 inside the profile and 0 without these lines; true, sh, python3 and osascript `return 1` still run (tests/test_sandbox_profile.py). + +The built-in browser. `own_origin` matches loopback hosts (localhost, *.localhost, 127/8, ::1, 0.0.0.0) on the engine port, the window ports and the devices port. `_url` refuses them, and a route on the browser context aborts any request to them, redirects and subresources included. Other local ports and public hosts open as before (tests/test_browser_addresses.py). The route was not run here: Playwright is not in the test list. + +Tool processes. Every running bash tool command is kept in `_procs`; `stop_all` ends them at engine shutdown. On Windows `_kill` runs `taskkill /T /F`, so the programs cmd.exe started end with it; elsewhere the process group gets SIGTERM, then SIGKILL after 3 seconds (tests/test_tool_processes.py; the Windows branch was not run). + +Connector refresh. A refresh that cannot reach the token endpoint (a network error, 429 or 5xx) returns no token and keeps the sign-in; only a refusal signs the connector out (tests/test_oauth_refresh.py). + +Skill replace. `_install` copies into `..incoming-` first and swaps it in only when the copy is complete; a failed copy leaves the old skill as it was. Saving a skill from its own folder now works, because the copy is made before the old folder moves (tests/test_skill_replace.py). Installing a skill with an existing name still replaces it without asking, as before. From d9accb46ca7cc762aa1d049a7074966271227791 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 09:35:37 -0500 Subject: [PATCH 10/16] fix: read the built-in browser's addresses as the browser does and refuse its requests at the engine --- backend/app/core/local_guard.py | 3 + backend/app/engine/browser.py | 95 ++++++++++++++++++++++--- backend/tests/test_browser_addresses.py | 49 +++++++++++++ 3 files changed, 136 insertions(+), 11 deletions(-) diff --git a/backend/app/core/local_guard.py b/backend/app/core/local_guard.py index ec63812..5ad228e 100644 --- a/backend/app/core/local_guard.py +++ b/backend/app/core/local_guard.py @@ -1,6 +1,7 @@ from urllib.parse import urlsplit LOOPBACK = {"127.0.0.1", "localhost", "::1"} +BROWSER_MARK = "x-format-browser" def _host_of(value: str) -> str: @@ -30,6 +31,8 @@ def __init__(self, app, origins: list[str]) -> None: def _permitted(self, headers: dict[str, str], paired: bool = False) -> bool: host = headers.get("host", "") + if BROWSER_MARK in headers: + return False if not paired and _host_of(host) not in LOOPBACK: return False origin = headers.get("origin") diff --git a/backend/app/engine/browser.py b/backend/app/engine/browser.py index bf3aa22..e850567 100644 --- a/backend/app/engine/browser.py +++ b/backend/app/engine/browser.py @@ -1,6 +1,7 @@ import concurrent.futures import os import queue +import re import subprocess import sys import threading @@ -129,7 +130,7 @@ def _worker() -> None: return if fut is not None: fut.set_exception(CommandError(_state["error"], 503)) - ctx.route(own_origin, lambda route: route.abort("blockedbyclient")) + ctx.route(loopback, _guard) page = ctx.pages[0] if ctx.pages else ctx.new_page() _state.update(open=True, error="") try: @@ -179,21 +180,93 @@ def _do(fn, wait: float = 60): raise CommandError("The browser did not answer in time", 504) from None -def own_origin(url: str) -> bool: +def _ipv4(host: str): + import ipaddress + parts = host.split(".") + if not 1 <= len(parts) <= 4: + return None + nums = [] + for p in parts: + if re.fullmatch(r"0[xX][0-9a-fA-F]*", p): + nums.append(int(p[2:] or "0", 16)) + elif re.fullmatch(r"0[0-7]+", p): + nums.append(int(p, 8)) + elif re.fullmatch(r"[0-9]+", p): + nums.append(int(p)) + else: + return None + if any(n > 255 for n in nums[:-1]) or nums[-1] >= 256 ** (5 - len(nums)): + return None + value = nums[-1] + for i, n in enumerate(nums[:-1]): + value += n << (8 * (3 - i)) + return ipaddress.IPv4Address(value) + + +def _address(host: str): import ipaddress - from urllib.parse import urlsplit try: - parts = urlsplit(url) - host = (parts.hostname or "").lower().rstrip(".") - port = parts.port or {"http": 80, "https": 443, "ws": 80, "wss": 443}.get(parts.scheme) + ip = ipaddress.ip_address(host) except ValueError: - return False + return _ipv4(host) + if ip.version == 6 and ip.ipv4_mapped is not None: + return ip.ipv4_mapped + if ip.version == 6 and int(ip) >> 32 == 0 and int(ip) > 1: + return ipaddress.IPv4Address(int(ip) & 0xFFFFFFFF) + return ip + + +def _host(url: str) -> tuple[str, int | None] | None: + from urllib.parse import unquote, urlsplit + text = re.sub(r"[\t\n\r]", "", url or "").strip().replace("\\", "/") try: - loopback = ipaddress.ip_address(host).is_loopback or ipaddress.ip_address(host).is_unspecified + parts = urlsplit(text) + port = parts.port or {"http": 80, "https": 443, "ws": 80, "wss": 443}.get(parts.scheme.lower()) + host = unquote(parts.hostname or "") except ValueError: - loopback = host == "localhost" or host.endswith(".localhost") + return None + try: + host = host.encode("idna").decode("ascii") + except UnicodeError: + pass + return host.lower().rstrip("."), port + + +def _local(host: str, resolve: bool = False) -> bool: + if host == "localhost" or host.endswith(".localhost"): + return True + ip = _address(host.split("%", 1)[0]) + if ip is not None: + return ip.is_loopback or ip.is_unspecified + if not resolve or not host: + return False + import socket + try: + found = socket.getaddrinfo(host, None) + except (OSError, UnicodeError): + return False + return any(_local(str(row[4][0]).split("%", 1)[0]) for row in found) + + +def loopback(url: str, resolve: bool = False) -> bool: + got = _host(url) + return got is not None and _local(got[0], resolve) + + +def own_origin(url: str, resolve: bool = False) -> bool: + got = _host(url) + if got is None or not _local(got[0], resolve): + return False from app.engine.devices import LAN_PORT - return loopback and port in (config.PORT, config.FRONTEND_PORT, config.FRONTEND_PORT + 1, LAN_PORT) + return got[1] in (config.PORT, config.FRONTEND_PORT, config.FRONTEND_PORT + 1, LAN_PORT) + + +def _guard(route) -> None: + from app.core.local_guard import BROWSER_MARK + if own_origin(route.request.url): + route.abort("blockedbyclient") + return + route.continue_(headers=route.request.all_headers() | {BROWSER_MARK: "1"}) def _url(u: str) -> str: @@ -204,7 +277,7 @@ def _url(u: str) -> str: u = ("http://" if u.startswith(("localhost", "127.0.0.1")) else "https://") + u if not u.startswith(("http://", "https://", "about:")): raise CommandError("The browser opens http and https pages") - if own_origin(u): + if own_origin(u, resolve=True): raise CommandError("The browser does not open FormAT's own engine or window; open it in FormAT itself") return u diff --git a/backend/tests/test_browser_addresses.py b/backend/tests/test_browser_addresses.py index 8da8cc0..40c6d4d 100644 --- a/backend/tests/test_browser_addresses.py +++ b/backend/tests/test_browser_addresses.py @@ -16,3 +16,52 @@ def test_the_browser_does_not_open_formats_own_addresses(url): def test_the_browser_still_opens_other_local_and_public_pages(url): assert browser._url(url).startswith(("http://", "https://")) assert not browser.own_origin(browser._url(url)) + + +@pytest.mark.parametrize("url", [f"http://2130706433:{config.PORT}/", f"http://0x7f000001:{config.PORT}/", f"http://0177.0.0.1:{config.PORT}/", + f"http://127.1:{config.PORT}/", f"http://127.0x0.1:{config.PORT}/", f"http://[::ffff:127.0.0.1]:{config.PORT}/", + f"http://[::ffff:7f00:1]:{config.PORT}/", f"http://127%2E0%2E0%2E1:{config.PORT}/", f"http://LOCALHOST.:{config.PORT}/", + f"http://user@127.0.0.1:{config.PORT}/", f"2130706433:{config.PORT}", + f"http://127.0.0.1:{config.PORT}/", f"http://[::]:{config.PORT}/"]) +def test_other_spellings_of_formats_own_addresses_are_refused(url): + with pytest.raises(CommandError): + browser._url(url) + + +def test_a_name_that_resolves_to_this_computer_is_refused(monkeypatch): + import socket + monkeypatch.setattr(socket, "getaddrinfo", lambda host, port: [(2, 1, 6, "", ("127.0.0.1", 0))]) + with pytest.raises(CommandError): + browser._url(f"http://format.test:{config.PORT}/") + monkeypatch.setattr(socket, "getaddrinfo", lambda host, port: [(2, 1, 6, "", ("192.0.2.7", 0))]) + assert browser._url(f"http://format.test:{config.PORT}/") + + +class _Route: + def __init__(self, url): + self.request = type("R", (), {"url": url, "all_headers": lambda self: {"accept": "*/*"}})() + self.done = None + + def abort(self, why): + self.done = ("abort", why) + + def continue_(self, headers=None): + self.done = ("continue", headers) + + +def test_the_browser_route_stops_formats_own_addresses_and_marks_other_local_requests(): + from app.core.local_guard import BROWSER_MARK + own = _Route(f"http://127.0.0.1:{config.PORT}/api/health") + browser._guard(own) + assert own.done[0] == "abort" + other = _Route("http://127.0.0.1:3000/") + browser._guard(other) + assert other.done == ("continue", {"accept": "*/*", BROWSER_MARK: "1"}) + assert browser.own_origin(f"http:\\\\127.0.0.1:{config.PORT}/") + assert browser.loopback("http://[::1]:3000/") and not browser.loopback("https://example.com/") + + +def test_the_engine_refuses_requests_from_its_own_browser(client): + from app.core.local_guard import BROWSER_MARK + assert client.get("/api/health").status_code == 200 + assert client.get("/api/health", headers={BROWSER_MARK: "1"}).status_code == 403 From 3a113338fc0c048e5cc47dd30b3739770fecdb1b Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 09:35:37 -0500 Subject: [PATCH 11/16] fix: start Windows agent shims without the command interpreter where possible The shared finder moves to version 1.0.2. A .cmd or .bat shim is replaced by the program it starts; any other shim goes through cmd.exe only when every argument is plain. --- backend/app/engine/agent_lookup.py | 52 +++++++++++++++++++++++++-- backend/app/engine/claude_code.py | 3 +- backend/tests/test_windows_start.py | 54 +++++++++++++++++++++++++++++ setup/agents.py | 3 +- 4 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 backend/tests/test_windows_start.py diff --git a/backend/app/engine/agent_lookup.py b/backend/app/engine/agent_lookup.py index ea34eba..1052ade 100644 --- a/backend/app/engine/agent_lookup.py +++ b/backend/app/engine/agent_lookup.py @@ -26,7 +26,7 @@ from dataclasses import dataclass, field from pathlib import Path -VERSION = "1.0.1" +VERSION = "1.0.2" PROGRAMS: dict = { "claude": {"title": "Claude Code", "names": ("claude",), "setting": "claudeBin", "install": "curl -fsSL https://claude.ai/install.sh | bash", "install_windows": "irm https://claude.ai/install.ps1 | iex", @@ -359,13 +359,59 @@ def _quote(word: str, fish: bool) -> str: return "'" + word.replace("'", "'\"'\"'") + "'" +def _node(folder: Path, env: dict) -> str | None: + for place in [str(folder), *(env.get("PATH") or env.get("Path") or "").split(";")]: + if place.strip() and Path(place.strip(), "node.exe").is_file(): + return str(Path(place.strip(), "node.exe")) + return None + + +def shim_target(path: str | os.PathLike, env: dict | None = None) -> list[str] | None: + """The program a Windows .cmd or .bat shim of the npm, pnpm or bun kind starts, as the words to run it with: the .exe + it names, or node and the script it names. None when the shim is of another kind or its target is missing.""" + env = os.environ if env is None else env + shim = Path(path) + try: + text = shim.read_text(encoding="utf-8", errors="replace") + except OSError: + return None + hit = re.search(r'"%~?dp0%?[\\/]*([^"%\r\n]+)"\s*%\*', text) + if not hit: + return None + target = shim.parent.joinpath(*[p for p in re.split(r"[\\/]+", hit.group(1)) if p]) + if not target.is_file(): + return None + if target.suffix.lower() == ".exe": + return [str(target)] + if target.suffix.lower() in (".js", ".cjs", ".mjs"): + node = _node(shim.parent, env) + return [node, str(target)] if node else None + return None + + +def cmd_safe(word: str) -> bool: + """Whether the command interpreter reads word as one plain argument: no control character, %, " or !, and the + characters & | < > ^ ( ) only in a word that is quoted (one with a space or a tab).""" + if re.search(r'[\x00-\x1f\x7f%"!]', word): + return False + return not word or bool(re.search(r"[ \t]", word)) or not re.search(r"[&|<>^()]", word) + + def start_argv(cmd: list, env: dict | None = None, platform: str | None = None) -> list[str]: """How a program is started, the same for a tab, Chat and a check: through the person's login shell on macOS and Linux - (exec, so the process is the program), directly on Windows with the command interpreter in front of a .cmd or .bat.""" + (exec, so the process is the program), directly on Windows. A .cmd or .bat shim is replaced by the program it starts; + only a shim of another kind goes through the command interpreter, and then every word must pass cmd_safe.""" words = [str(c) for c in cmd] env = os.environ if env is None else env if windows(platform): - return [env.get("COMSPEC") or "cmd.exe", "/c", *words] if words[0].lower().endswith((".cmd", ".bat")) else words + if not words[0].lower().endswith((".cmd", ".bat")): + return words + direct = shim_target(words[0], env) + if direct: + return [*direct, *words[1:]] + if not all(cmd_safe(w) for w in words): + raise OSError(22, "an argument holds a character the Windows command interpreter would read as a command") + return [env.get("COMSPEC") or "cmd.exe", "/d", "/c", *words] shell = login_shell(env, platform) fish = Path(shell).name == "fish" return [shell, "-l", "-c", "exec " + " ".join(_quote(w, fish) for w in words)] diff --git a/backend/app/engine/claude_code.py b/backend/app/engine/claude_code.py index 7820731..3c7811a 100644 --- a/backend/app/engine/claude_code.py +++ b/backend/app/engine/claude_code.py @@ -391,7 +391,8 @@ def drain() -> None: try: if not found["installed"]: raise providers.ProviderError(found.get("said") or "Claude Code is not installed: install it from https://claude.com/claude-code and sign in once with `claude`") - proc = subprocess.Popen(agent_lookup.start_argv(args), cwd=folder, env=child_env(found["path"]), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1) + run_env = child_env(found["path"]) + proc = subprocess.Popen(agent_lookup.start_argv(args, run_env), cwd=folder, env=run_env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1) threading.Thread(target=drain, daemon=True).start() threading.Thread(target=watch, daemon=True).start() send({"type": "control_request", "request_id": "format-init", "request": {"subtype": "initialize", "hooks": None}}) diff --git a/backend/tests/test_windows_start.py b/backend/tests/test_windows_start.py new file mode 100644 index 0000000..6fb99dc --- /dev/null +++ b/backend/tests/test_windows_start.py @@ -0,0 +1,54 @@ +import pytest + +from app.engine import agent_lookup + +NPM_SHIM = '@ECHO off\r\nSETLOCAL\r\nCALL :find_dp0\r\nendLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\\node_modules\\@pkg\\agent\\cli.js" %*\r\n' +EXE_SHIM = '@ECHO off\r\n"%~dp0\\node_modules\\@pkg\\agent\\bin\\agent.exe" %*\r\n' + + +def _shim(tmp_path, text, target): + shim = tmp_path / "agent.cmd" + shim.write_text(text, encoding="utf-8") + script = tmp_path.joinpath("node_modules", "@pkg", "agent", *target) + script.parent.mkdir(parents=True) + script.write_text("", encoding="utf-8") + return shim, script + + +def test_a_node_shim_runs_its_script_with_node_and_no_command_interpreter(tmp_path): + shim, script = _shim(tmp_path, NPM_SHIM, ["cli.js"]) + (tmp_path / "node.exe").write_text("", encoding="utf-8") + argv = agent_lookup.start_argv([str(shim), "-p", "line one\nline two & more"], {"PATH": ""}, "win32") + assert argv == [str(tmp_path / "node.exe"), str(script), "-p", "line one\nline two & more"] + + +def test_a_node_shim_finds_node_on_path(tmp_path): + shim, script = _shim(tmp_path, NPM_SHIM, ["cli.js"]) + elsewhere = tmp_path / "nodejs" + elsewhere.mkdir() + (elsewhere / "node.exe").write_text("", encoding="utf-8") + assert agent_lookup.start_argv([str(shim), "--version"], {"PATH": f"C:\\none;{elsewhere}"}, "win32")[:2] == [str(elsewhere / "node.exe"), str(script)] + + +def test_a_shim_that_names_an_exe_runs_the_exe(tmp_path): + shim, exe = _shim(tmp_path, EXE_SHIM, ["bin", "agent.exe"]) + assert agent_lookup.start_argv([str(shim), "--version"], {"PATH": ""}, "win32") == [str(exe), "--version"] + + +@pytest.mark.parametrize("word", ["a\nb", "tab\x7f", "100%", "%PATH%", 'say "hi"', "x&calc", "a|b", "a>b", "a^b", "(a)", "hey!"]) +def test_an_unknown_shim_refuses_words_the_command_interpreter_would_read(tmp_path, word): + shim = tmp_path / "other.cmd" + shim.write_text("@echo off\r\nrun-something %*\r\n", encoding="utf-8") + with pytest.raises(OSError): + agent_lookup.start_argv([str(shim), word], {"PATH": ""}, "win32") + + +def test_an_unknown_shim_still_starts_plain_and_quoted_words(tmp_path): + shim = tmp_path / "other.cmd" + shim.write_text("@echo off\r\nrun-something %*\r\n", encoding="utf-8") + argv = agent_lookup.start_argv([str(shim), "--model", "a-b.c", "two words & more", ""], {"COMSPEC": "cmd.exe", "PATH": ""}, "win32") + assert argv == ["cmd.exe", "/d", "/c", str(shim), "--model", "a-b.c", "two words & more", ""] + + +def test_an_exe_starts_directly_on_windows(tmp_path): + assert agent_lookup.start_argv(["C:\\agent.exe", "a&b"], {}, "win32") == ["C:\\agent.exe", "a&b"] diff --git a/setup/agents.py b/setup/agents.py index 5a14d23..3e726e4 100644 --- a/setup/agents.py +++ b/setup/agents.py @@ -22,7 +22,8 @@ DOCK = {"present": False, "positions": [], "tabs": []} MCP_URL = "http://127.0.0.1:8490/mcp" LOOKUP = ROOT / "backend" / "app" / "engine" / "agent_lookup.py" -LOOKUP_HASHES = {"1.0.0": "252ea9bb9419d4990f174f91914f09800497bc69e98f849f5643bbf4217cc3f3", "1.0.1": "62667f9b68b7d101e1896ce617240424e33b7e498c560bc79d45f0ab26c77d51"} +LOOKUP_HASHES = {"1.0.0": "252ea9bb9419d4990f174f91914f09800497bc69e98f849f5643bbf4217cc3f3", "1.0.1": "62667f9b68b7d101e1896ce617240424e33b7e498c560bc79d45f0ab26c77d51", + "1.0.2": "4c48259ef6db5f3fec3b1254bb840b36c5ed8db432e4b8a3b1d0a5a711b7a17a"} GROUPS = { "chat": "Chat with Claude", "conversation": "Chats", "message": "Chats", "artifact": "Artifacts", "files": "Chat files and outputs", "outputs": "Chat files and outputs", "tasks": "Chat files and outputs", "project": "Projects", "memory": "Memory", "skill": "Skills", "connector": "Connectors", "schedule": "Scheduled tasks", From 5ad00e1ed07fea27b7d6e5d80f3ee84b38a877b8 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 09:35:37 -0500 Subject: [PATCH 12/16] fix: end every process in a stopped bash tool command's group, also one that ignores SIGTERM --- backend/app/engine/tools.py | 41 ++++++++++++++++++++++++---- backend/tests/test_tool_processes.py | 28 +++++++++++++++++++ 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/backend/app/engine/tools.py b/backend/app/engine/tools.py index fd28eca..6436ed4 100644 --- a/backend/app/engine/tools.py +++ b/backend/app/engine/tools.py @@ -512,18 +512,47 @@ def pump() -> None: return (output if output.strip() else "(no output)") + (f"\n[exit code {code}]" if code else ""), code != 0 -def _kill(proc: subprocess.Popen) -> None: +def _group_alive(pgid: int) -> bool: try: - if os.name != "nt": - os.killpg(proc.pid, 15) - else: + os.killpg(pgid, 0) + except ProcessLookupError: + return False + except OSError: + return True + return True + + +def _kill(proc: subprocess.Popen) -> None: + if os.name == "nt": + try: subprocess.run(["taskkill", "/PID", str(proc.pid), "/T", "/F"], capture_output=True, timeout=10, creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0)) + proc.wait(3) + except Exception: + try: + proc.kill() + except Exception: + pass + return + try: + os.killpg(proc.pid, 15) + except OSError: + pass + deadline = time.monotonic() + 3 + while time.monotonic() < deadline: + proc.poll() + if not _group_alive(proc.pid): + break + time.sleep(0.05) + try: + if _group_alive(proc.pid): + os.killpg(proc.pid, 9) + except OSError: + pass + try: proc.wait(3) except Exception: try: - if os.name != "nt": - os.killpg(proc.pid, 9) proc.kill() except Exception: pass diff --git a/backend/tests/test_tool_processes.py b/backend/tests/test_tool_processes.py index 74904ac..9aa0649 100644 --- a/backend/tests/test_tool_processes.py +++ b/backend/tests/test_tool_processes.py @@ -21,3 +21,31 @@ def test_stopping_the_engine_ends_running_bash_tool_commands(tmp_path): worker.join(10) assert not worker.is_alive() and time.monotonic() - started < 10 assert not tools._procs + + +@pytest.mark.skipif(os.name == "nt", reason="uses a POSIX shell command") +def test_stopping_a_bash_tool_command_also_ends_a_child_that_ignores_the_first_signal(tmp_path): + import signal + + pidfile = tmp_path / "child.pid" + cancel = threading.Event() + command = f"/bin/sh -c 'trap \"\" TERM; sleep 30' & echo $! > {pidfile}; wait" + worker = threading.Thread(target=lambda: tools._bash(tmp_path, {"command": command}, lambda _: None, cancel)) + worker.start() + deadline = time.monotonic() + 10 + while not (pidfile.exists() and pidfile.read_text().strip()) and time.monotonic() < deadline: + time.sleep(0.05) + child = int(pidfile.read_text()) + time.sleep(0.3) + cancel.set() + worker.join(15) + assert not worker.is_alive() + deadline = time.monotonic() + 3 + while time.monotonic() < deadline: + try: + os.kill(child, 0) + except ProcessLookupError: + return + time.sleep(0.05) + os.kill(child, signal.SIGKILL) + pytest.fail("the child that ignored SIGTERM was still running") From fb963ab414473ac5ea33afc9005158e382310ed9 Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 09:35:37 -0500 Subject: [PATCH 13/16] fix: never let a git source use a command transport --- backend/app/engine/marketplaces.py | 2 +- backend/tests/test_marketplace_sources.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/app/engine/marketplaces.py b/backend/app/engine/marketplaces.py index fc6b9e5..639d869 100644 --- a/backend/app/engine/marketplaces.py +++ b/backend/app/engine/marketplaces.py @@ -55,7 +55,7 @@ def _git(*args: str, cwd: Path | None = None, token: str = "") -> str: import base64 auth = ["-c", "http.extraHeader=Authorization: Basic " + base64.b64encode(f"x-access-token:{token}".encode()).decode()] if token else [] try: - done = subprocess.run(["git", *auth, *args], cwd=cwd, capture_output=True, text=True, timeout=GIT_TIMEOUT, env=os.environ | {"GIT_TERMINAL_PROMPT": "0"}) + done = subprocess.run(["git", "-c", "protocol.ext.allow=never", *auth, *args], cwd=cwd, capture_output=True, text=True, timeout=GIT_TIMEOUT, env=os.environ | {"GIT_TERMINAL_PROMPT": "0"}) except subprocess.TimeoutExpired: raise CommandError(f"git {args[0]} took longer than {GIT_TIMEOUT} s") from None if done.returncode != 0: diff --git a/backend/tests/test_marketplace_sources.py b/backend/tests/test_marketplace_sources.py index e6ea511..ec34cb9 100644 --- a/backend/tests/test_marketplace_sources.py +++ b/backend/tests/test_marketplace_sources.py @@ -23,3 +23,13 @@ def test_a_git_source_is_passed_after_the_end_of_options(tmp_path, git_calls): args = git_calls[0] assert args[args.index("--") + 1] == "https://github.com/owner/name.git" assert args[-1] == str(tmp_path / "dest") + + +def test_git_never_runs_a_command_transport(tmp_path, monkeypatch): + import subprocess + + seen = [] + monkeypatch.setattr(marketplaces.shutil, "which", lambda name: "/usr/bin/git") + monkeypatch.setattr(subprocess, "run", lambda argv, **kw: seen.append(argv) or subprocess.CompletedProcess(argv, 0, "", "")) + marketplaces._clone("ext::sh -c true", tmp_path / "dest") + assert seen[0][:3] == ["git", "-c", "protocol.ext.allow=never"] From f1eb6b6d96a3e7a11ab51f84fe0e0015e15a091b Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 09:35:37 -0500 Subject: [PATCH 14/16] docs: log the second hardening pass in the backend HASHOUT log --- backend/HASHOUT_LOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index 03d0d25..7e88154 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -1328,7 +1328,7 @@ The walk. `test_every_read_route_is_public_addressed_by_a_random_id_or_refused_w Seen with the real engine (format_engine.py, the built window in Chromium, stand-in agent programs on PATH), from source and with FORMAT_WINDOW_KEY_STDOUT=1 and the global given by an initialization script as the shell does: the window with its key wrote (POST /api/uploads 200), ran a command (200) and read the frame (204 with no page open; 200 image/jpeg from the pane itself with the browser open); a local program without the key got 403 on the write, the frame and the socket ticket, 403 with a wrong key, and its command waited for the person's consent; a second claim got 409 (404 in the packaged mode); after a reload the page made no new claim and its writes still answered 200. Before this change the frame answered the local program (204). ### Hardening after 0.32.0 (unreleased) · git sources, the deny list, pairing links, the macOS sandbox, the built-in browser, tool processes, connector refresh, skill replace -- refers-to: app/engine/marketplaces.py :: _clone; app/engine/claude_code.py :: decision_for; app/engine/agents.py :: outside_result; app/routers/commands.py :: run; app/routers/mcp_http.py :: _call; app/engine/sandbox.py :: wrap; app/engine/browser.py :: own_origin, _url, _worker; app/engine/tools.py :: _bash, _watch, _kill, stop_all; app/routers/__init__.py :: shutdown; app/engine/oauth.py :: OAuthError, _token, access_token; app/engine/skills.py :: _install +- refers-to: app/engine/marketplaces.py :: _git, _clone; app/engine/claude_code.py :: decision_for, run; app/engine/agent_lookup.py :: shim_target, cmd_safe, start_argv; app/core/local_guard.py :: BROWSER_MARK, LocalGuard._permitted; setup/agents.py :: LOOKUP_HASHES; app/engine/agents.py :: outside_result; app/routers/commands.py :: run; app/routers/mcp_http.py :: _call; app/engine/sandbox.py :: wrap; app/engine/browser.py :: own_origin, _url, _worker; app/engine/tools.py :: _bash, _watch, _kill, stop_all; app/routers/__init__.py :: shutdown; app/engine/oauth.py :: OAuthError, _token, access_token; app/engine/skills.py :: _install - kind: decision - logged: unreleased @@ -1347,3 +1347,11 @@ Tool processes. Every running bash tool command is kept in `_procs`; `stop_all` Connector refresh. A refresh that cannot reach the token endpoint (a network error, 429 or 5xx) returns no token and keeps the sign-in; only a refusal signs the connector out (tests/test_oauth_refresh.py). Skill replace. `_install` copies into `..incoming-` first and swaps it in only when the copy is complete; a failed copy leaves the old skill as it was. Saving a skill from its own folder now works, because the copy is made before the old folder moves (tests/test_skill_replace.py). Installing a skill with an existing name still replaces it without asking, as before. + +The built-in browser, second pass. `own_origin` reads the host the way the browser does before it compares: tabs and newlines dropped, backslashes as slashes, percent escapes and full-width characters folded, and the IPv4 forms the URL standard accepts (one to four parts, hex, octal, 127.1, 2130706433), IPv4-mapped and IPv4-compatible IPv6, :: and 0.0.0.0. `_url` also resolves a name and refuses it when any address is this computer. The context route now takes every loopback request: it aborts FormAT's own ports and sends the rest with the header `x-format-browser`, and LocalGuard (app/core/local_guard.py :: BROWSER_MARK) refuses any request that carries it, so a request from the built-in browser that reaches the engine by another path is still refused. A name that resolves to this computer only later arrives with its own Host, which LocalGuard already refuses (tests/test_browser_addresses.py). + +Git transports. Every git call runs with `protocol.ext.allow=never`, so a source can never name a command transport, whatever the person's own git config says (tests/test_marketplace_sources.py). + +Tool processes, second pass. `_kill` waits up to 3 seconds for the whole process group, not only its leader, and then sends SIGKILL to the group if anything in it still runs, so a child that ignores SIGTERM ends too (tests/test_tool_processes.py). + +The shared finder, version 1.0.2 (app/engine/agent_lookup.py, hash in setup/agents.py `LOOKUP_HASHES`). On Windows `start_argv` no longer puts cmd.exe in front of an npm, pnpm or bun shim: `shim_target` reads the .cmd and runs the .exe it names, or node.exe (beside the shim, then on PATH) and the script it names. A shim of another kind still goes through cmd.exe, now with /d, and only when every word passes `cmd_safe`: no control character, %, " or !, and & | < > ^ ( ) only in a word that list2cmdline quotes; otherwise the start is refused with an OSError. The Claude Code chat run passes its child environment to `start_argv`, so node is looked for on the same PATH the program gets (tests/test_windows_start.py; not run on Windows). The other Form engines still carry 1.0.1. From 5251d311be0822b60dfbae994d33eab1dec52ccc Mon Sep 17 00:00:00 2001 From: gbarnai Date: Sun, 29 Nov 2026 11:00:12 -0500 Subject: [PATCH 15/16] fix: refuse every command interpreter special character in a Windows shim start Quoting does not protect an argument that a .cmd shim reads again through %*, so any word holding & | < > ^ ( ) ! % " or a control character is refused whether or not it has spaces. A name ending in .cmd or .bat with trailing dots or spaces is treated as a shim. The hash recorded for finder version 1.0.2 is updated. --- backend/HASHOUT_LOG.md | 2 +- backend/app/engine/agent_lookup.py | 26 +++++++++----- backend/tests/test_windows_start.py | 53 ++++++++++++++++++++++++----- setup/agents.py | 2 +- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index 7e88154..f8120cd 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -1354,4 +1354,4 @@ Git transports. Every git call runs with `protocol.ext.allow=never`, so a source Tool processes, second pass. `_kill` waits up to 3 seconds for the whole process group, not only its leader, and then sends SIGKILL to the group if anything in it still runs, so a child that ignores SIGTERM ends too (tests/test_tool_processes.py). -The shared finder, version 1.0.2 (app/engine/agent_lookup.py, hash in setup/agents.py `LOOKUP_HASHES`). On Windows `start_argv` no longer puts cmd.exe in front of an npm, pnpm or bun shim: `shim_target` reads the .cmd and runs the .exe it names, or node.exe (beside the shim, then on PATH) and the script it names. A shim of another kind still goes through cmd.exe, now with /d, and only when every word passes `cmd_safe`: no control character, %, " or !, and & | < > ^ ( ) only in a word that list2cmdline quotes; otherwise the start is refused with an OSError. The Claude Code chat run passes its child environment to `start_argv`, so node is looked for on the same PATH the program gets (tests/test_windows_start.py; not run on Windows). The other Form engines still carry 1.0.1. +The shared finder, version 1.0.2 (app/engine/agent_lookup.py, hash in setup/agents.py `LOOKUP_HASHES`). On Windows `start_argv` no longer puts cmd.exe in front of an npm, pnpm or bun shim: `shim_target` reads the .cmd and runs the .exe it names, or node.exe (beside the shim, then on PATH) and the script it names. A shim of another kind still goes through cmd.exe, now with /d, and only when every word, the program's path included, passes `cmd_safe`: none of & | < > ^ ( ) ! % " and no control character (\x00-\x1f, \x7f), with or without spaces, because the shim reads its arguments again through %* and quoting does not hold there; otherwise the start is refused with an OSError that says to pass long text through stdin or a file. A name ending in .cmd or .bat followed by dots or spaces counts as a shim too. The Claude Code chat run passes its child environment to `start_argv`, so node is looked for on the same PATH the program gets (tests/test_windows_start.py; not run on Windows). The other Form engines still carry 1.0.1. diff --git a/backend/app/engine/agent_lookup.py b/backend/app/engine/agent_lookup.py index 1052ade..182200a 100644 --- a/backend/app/engine/agent_lookup.py +++ b/backend/app/engine/agent_lookup.py @@ -389,28 +389,36 @@ def shim_target(path: str | os.PathLike, env: dict | None = None) -> list[str] | return None +CMD_SPECIAL = re.compile(r'[\x00-\x1f\x7f&|<>^()!%"]') +CMD_REFUSED = ("an argument holds a character the Windows command interpreter would read (& | < > ^ ( ) ! % \" or a control " + "character); pass long text through stdin or a file if the program supports it") + + def cmd_safe(word: str) -> bool: - """Whether the command interpreter reads word as one plain argument: no control character, %, " or !, and the - characters & | < > ^ ( ) only in a word that is quoted (one with a space or a tab).""" - if re.search(r'[\x00-\x1f\x7f%"!]', word): - return False - return not word or bool(re.search(r"[ \t]", word)) or not re.search(r"[&|<>^()]", word) + """Whether word can go through the command interpreter: none of & | < > ^ ( ) ! % " and no control character, + quoted or not, because a .cmd shim reads its arguments again through %*.""" + return not CMD_SPECIAL.search(word) + + +def _shim_ending(word: str) -> bool: + return word.rstrip(" .").lower().endswith((".cmd", ".bat")) def start_argv(cmd: list, env: dict | None = None, platform: str | None = None) -> list[str]: """How a program is started, the same for a tab, Chat and a check: through the person's login shell on macOS and Linux (exec, so the process is the program), directly on Windows. A .cmd or .bat shim is replaced by the program it starts; - only a shim of another kind goes through the command interpreter, and then every word must pass cmd_safe.""" + only a shim of another kind goes through the command interpreter, and then every word, the program's path included, + must pass cmd_safe or the start is refused.""" words = [str(c) for c in cmd] env = os.environ if env is None else env if windows(platform): - if not words[0].lower().endswith((".cmd", ".bat")): + if not _shim_ending(words[0]): return words - direct = shim_target(words[0], env) + direct = shim_target(words[0].rstrip(" ."), env) if direct: return [*direct, *words[1:]] if not all(cmd_safe(w) for w in words): - raise OSError(22, "an argument holds a character the Windows command interpreter would read as a command") + raise OSError(22, CMD_REFUSED) return [env.get("COMSPEC") or "cmd.exe", "/d", "/c", *words] shell = login_shell(env, platform) fish = Path(shell).name == "fish" diff --git a/backend/tests/test_windows_start.py b/backend/tests/test_windows_start.py index 6fb99dc..df96368 100644 --- a/backend/tests/test_windows_start.py +++ b/backend/tests/test_windows_start.py @@ -35,19 +35,54 @@ def test_a_shim_that_names_an_exe_runs_the_exe(tmp_path): assert agent_lookup.start_argv([str(shim), "--version"], {"PATH": ""}, "win32") == [str(exe), "--version"] -@pytest.mark.parametrize("word", ["a\nb", "tab\x7f", "100%", "%PATH%", 'say "hi"', "x&calc", "a|b", "a>b", "a^b", "(a)", "hey!"]) -def test_an_unknown_shim_refuses_words_the_command_interpreter_would_read(tmp_path, word): - shim = tmp_path / "other.cmd" +SPECIAL = ["a\nb", "tab\x7f", "nul\x00", "esc\x1b", "100%", "%PATH%", 'say "hi"', "x&calc", "a|b", "a>b", "a Date: Sun, 29 Nov 2026 14:21:19 -0500 Subject: [PATCH 16/16] test: run the bash tool process tests with the sandbox off On a machine with bubblewrap, as the CI runner has, the bash tool ran each test command in bwrap, whose empty /tmp hid the stand-in shell the test setup puts in SHELL, so no command started and the SIGTERM test found no pid file. bwrap's own pid namespace would also hide the child's real pid. An autouse fixture sets sandbox.kind to None for this file, as test_sandbox_profile.py already sets kind itself. The backend HASHOUT log records why. Checked with python -m pytest tests with bwrap installed: 233 passed, 1 skipped. --- backend/HASHOUT_LOG.md | 2 ++ backend/tests/test_tool_processes.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index f8120cd..386c3e6 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -1354,4 +1354,6 @@ Git transports. Every git call runs with `protocol.ext.allow=never`, so a source Tool processes, second pass. `_kill` waits up to 3 seconds for the whole process group, not only its leader, and then sends SIGKILL to the group if anything in it still runs, so a child that ignores SIGTERM ends too (tests/test_tool_processes.py). +Tool process tests and the sandbox. tests/test_tool_processes.py turns the sandbox off for its tests with an autouse fixture (`sandbox.kind` returns None), as tests/test_sandbox_profile.py already sets `kind` itself. On a machine with bubblewrap, as the CI runner has, `_bash` ran each command in bwrap: its `--tmpfs /tmp` hid the stand-in shell conftest puts in `$SHELL` under the temp folder, so no command started and the SIGTERM test found no pid file. Even with the shell visible, `--unshare-pid` makes `$!` a pid inside the sandbox, which the test cannot check from outside. The tests are about the process group, which they now see unsandboxed; the bubblewrap path is not covered by them. Seen: with bwrap installed, the file failed the same way as CI and now passes, and the suite reads 233 passed, 1 skipped. + The shared finder, version 1.0.2 (app/engine/agent_lookup.py, hash in setup/agents.py `LOOKUP_HASHES`). On Windows `start_argv` no longer puts cmd.exe in front of an npm, pnpm or bun shim: `shim_target` reads the .cmd and runs the .exe it names, or node.exe (beside the shim, then on PATH) and the script it names. A shim of another kind still goes through cmd.exe, now with /d, and only when every word, the program's path included, passes `cmd_safe`: none of & | < > ^ ( ) ! % " and no control character (\x00-\x1f, \x7f), with or without spaces, because the shim reads its arguments again through %* and quoting does not hold there; otherwise the start is refused with an OSError that says to pass long text through stdin or a file. A name ending in .cmd or .bat followed by dots or spaces counts as a shim too. The Claude Code chat run passes its child environment to `start_argv`, so node is looked for on the same PATH the program gets (tests/test_windows_start.py; not run on Windows). The other Form engines still carry 1.0.1. diff --git a/backend/tests/test_tool_processes.py b/backend/tests/test_tool_processes.py index 9aa0649..36effb7 100644 --- a/backend/tests/test_tool_processes.py +++ b/backend/tests/test_tool_processes.py @@ -4,7 +4,12 @@ import pytest -from app.engine import tools +from app.engine import sandbox, tools + + +@pytest.fixture(autouse=True) +def no_sandbox(monkeypatch): + monkeypatch.setattr(sandbox, "kind", lambda: None) @pytest.mark.skipif(os.name == "nt", reason="uses a POSIX shell command")