Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(marketplace): a community plugin no longer inherits the owner's keys
Harald147e5a99b90f
diff --git a/docs/marketplace/community-registry.md b/docs/marketplace/community-registry.mdindex 47ec8de540..a657572365 100644--- a/docs/marketplace/community-registry.md+++ b/docs/marketplace/community-registry.md@@ -50,8 +50,17 @@ the TTL-gated refresh.1. **Registry CI** (`scripts/validate.py` there): naming rules + reservedbuilt-in names, https-only URLs, stdio launcher allowlist- (`npx`/`uvx`/`docker`) with pinned versions, `$plugin_…` placeholders- only (no literal credentials anywhere), size limits, secret-pattern scan.+ (`npx`/`uvx`/`docker`), `$plugin_…` placeholders only (no literal+ credentials anywhere), size limits, secret-pattern scan.+ The launcher allowlist covers its ARGUMENTS too, and has to: each of the+ three launchers has options that run anything at all (`npx -c`, `uvx+ --with`, `docker -v/--privileged`), so allowing only the name would allow+ everything. The package a launcher fetches must be a pinned name from its+ own registry — never a git ref, URL or path, all of which name code that+ changes after review — and env keys may not name the machinery that starts+ the server (`PATH`, `LD_PRELOAD`, …). The data half of these rules is+ published in `rules.json` so the other two layers read the values rather+ than retyping them.2. **Ownership**: first merged submission claims the name in`registry.json`; updates auto-merge only from the same GitHub accountand must increase the version. The auto-merge gate runs trusted@@ -62,7 +71,14 @@ the TTL-gated refresh.4. **Consent dialog** (app + storefront detail view): shows verbatim theMCP URL (where requests and the token go) or the stdio argv (what runslocally) BEFORE install. Community entries are badged "not reviewed".-5. Existing blast-radius limits apply unchanged: per-plugin connect+5. **Environment isolation**: a connected community plugin's stdio process+ starts WITHOUT the app's environment (`jarvis/mcp/env_isolation.py`) — it+ gets what a process needs to run and reach the network, plus its own+ token. A child process otherwise inherits every exported credential on the+ machine, which is one `os.environ` read away from code the user only ever+ saw in a dialog. Does not reach the delegated worker path, where the+ claude CLI starts the server itself.+6. Existing blast-radius limits apply unchanged: per-plugin connectisolation, per-turn relevance gate, `ToolExecutor` as the singleexecution path, skill Draft/Validated lifecycle.diff --git a/jarvis/marketplace/plugin_mcp.py b/jarvis/marketplace/plugin_mcp.pyindex c5a7df6c1c..6795d388d9 100644--- a/jarvis/marketplace/plugin_mcp.py+++ b/jarvis/marketplace/plugin_mcp.py@@ -66,6 +66,13 @@ def plugin_to_mcp_server_spec(description=plugin.description,install_command=resolved_install,transport="stdio",+ # A community entry is a command line somebody else wrote, and the+ # user approved it from a dialog, not from reading the code. It+ # starts with the environment it needs and its own token — never+ # with the owner's other credentials (jarvis.mcp.env_isolation).+ # A seed plugin is this project's own; a locally uploaded one the+ # user put there themselves.+ isolate_env=plugin.source == "community",)return server_spec, env_overridesdiff --git a/jarvis/mcp/client.py b/jarvis/mcp/client.pyindex 181272dc3d..2884c85519 100644--- a/jarvis/mcp/client.py+++ b/jarvis/mcp/client.py@@ -390,6 +390,16 @@ class MCPClient:command, *args = expanded# env: system env as the base, overrides on top. String values only.+ #+ # Unless the server is untrusted — then the base is the smallest+ # environment a process can start in, because "the system env" on the+ # owner's machine is where their API keys live and a community plugin+ # is a stranger's code running as our child (jarvis.mcp.env_isolation).+ if self.spec.isolate_env:+ from jarvis.mcp.env_isolation import isolated_environment++ return command, args, isolated_environment(self._env_overrides)+env = dict(os.environ)env.update({k: str(v) for k, v in self._env_overrides.items()})return command, args, envdiff --git a/jarvis/mcp/env_isolation.py b/jarvis/mcp/env_isolation.pynew file mode 100644index 0000000000..047768a2af--- /dev/null+++ b/jarvis/mcp/env_isolation.py@@ -0,0 +1,122 @@+"""The environment an untrusted MCP server is allowed to see.++A community plugin is code from a stranger that the user pressed Install on.+It runs as a child process of Jarvis, and a child process inherits its+parent's environment — which on a normal developer machine is where the+OPENAI_API_KEY, the ANTHROPIC_API_KEY, the GITHUB_TOKEN and every other+credential the owner ever exported happen to live. Reading them costs a+plugin one line, and nothing about that line looks like an attack.++So an untrusted server does not get the environment. It gets the smallest+one a process can still start and reach the network in, plus the values its+own manifest declared (``env_template``, which is checked to hold nothing but+``$plugin_…`` placeholders resolved from that plugin's own token).++The list is an ALLOWLIST for the same reason the launcher rules are: naming+the secrets to remove means being wrong the day someone invents a new one.++Not covered, and worth knowing: the delegated worker path+(`marketplace.mcp_bridge`) hands a server definition to the claude CLI, and+that process starts the server itself with an environment this code never+sees. Isolation there would have to come from the CLI.+"""++from __future__ import annotations++import os+import sys++__all__ = ["isolated_environment"]++#: Everything a process needs to start, find its libraries, write a temp file+#: and resolve a host. Nothing here identifies the user to a remote service.+_POSIX_KEEP = (+ "PATH",+ "HOME",+ "LANG",+ "LC_ALL",+ "LC_CTYPE",+ "TMPDIR",+ "TERM",+ "TZ",+ "SHELL",+ "USER",+ "LOGNAME",+)++#: The Windows equivalent. SYSTEMROOT and friends are not optional — without+#: them the loader cannot even find the C runtime, and the process dies before+#: its first line with an error that names nothing.+_WINDOWS_KEEP = (+ "PATH",+ "PATHEXT",+ "SYSTEMROOT",+ "SYSTEMDRIVE",+ "WINDIR",+ "COMSPEC",+ "TEMP",+ "TMP",+ "APPDATA",+ "LOCALAPPDATA",+ "PROGRAMDATA",+ "PROGRAMFILES",+ "PROGRAMFILES(X86)",+ "PROGRAMW6432",+ "COMMONPROGRAMFILES",+ "HOMEDRIVE",+ "HOMEPATH",+ "USERPROFILE",+ "NUMBER_OF_PROCESSORS",+ "PROCESSOR_ARCHITECTURE",+ "OS",+)++#: Reaching the outside world at all. `npx`/`uvx` download a package on first+#: run, so a machine behind a corporate proxy has plugins that simply never+#: start without these.+#:+#: Honest trade-off: a proxy URL can carry `user:pass@`, so this hands a+#: plugin one credential in exchange for working at all on those machines. It+#: is a far smaller loss than the API keys the whole environment would leak,+#: and a plugin that talks to the network sees the proxy either way.+_NETWORK_KEEP = (+ "HTTP_PROXY",+ "HTTPS_PROXY",+ "NO_PROXY",+ "http_proxy",+ "https_proxy",+ "no_proxy",+ "SSL_CERT_FILE",+ "SSL_CERT_DIR",+ "REQUESTS_CA_BUNDLE",+ "NODE_EXTRA_CA_CERTS",+)++#: `docker run` is one of the three allowed launchers and cannot find the+#: daemon without this on a non-default setup (Colima, a remote engine, a+#: rootless socket). It names a socket, not a secret.+_LAUNCHER_KEEP = ("DOCKER_HOST", "DOCKER_CONTEXT", "DOCKER_CONFIG")+++def _keep_names() -> tuple[str, ...]:+ base = _WINDOWS_KEEP if sys.platform == "win32" else _POSIX_KEEP+ return base + _NETWORK_KEEP + _LAUNCHER_KEEP+++def isolated_environment(overrides: dict[str, str] | None = None) -> dict[str, str]:+ """The environment for an untrusted stdio server.++ ``overrides`` are the plugin's own declared variables and are applied+ last, so a plugin can still be handed its own token — and only its own.+ """+ keep = _keep_names()+ # Windows environment names are case-insensitive; matching on the upper+ # form keeps `Path` and `PATH` the same variable, which they are.+ if sys.platform == "win32":+ wanted = {name.upper() for name in keep}+ env = {key: value for key, value in os.environ.items() if key.upper() in wanted}+ else:+ env = {key: os.environ[key] for key in keep if key in os.environ}+ if overrides:+ env.update({str(k): str(v) for k, v in overrides.items()})+ return envdiff --git a/jarvis/mcp/registry.py b/jarvis/mcp/registry.pyindex 2fc4485044..a9b65e96f1 100644--- a/jarvis/mcp/registry.py+++ b/jarvis/mcp/registry.py@@ -46,6 +46,13 @@ class MCPServerSpec:# HTTP headers for the http transport. Values may contain ``$SECRET``# placeholders resolved against the Credential Manager at connect time.headers: dict[str, str] = field(default_factory=dict)+ # Start this stdio server WITHOUT the process environment (see+ # ``jarvis.mcp.env_isolation``). Set for servers whose command line came+ # from someone other than the user — a community plugin would otherwise+ # inherit every API key the owner ever exported. Off by default: a server+ # from the user's own mcp.json is theirs, and cutting its environment+ # would break the many that read a token straight out of it.+ isolate_env: bool = False# ----------------------------------------------------------------------diff --git a/tests/unit/marketplace/test_plugin_mcp.py b/tests/unit/marketplace/test_plugin_mcp.pyindex 601d1d1576..979deae006 100644--- a/tests/unit/marketplace/test_plugin_mcp.py+++ b/tests/unit/marketplace/test_plugin_mcp.py@@ -5,7 +5,7 @@ from jarvis.marketplace.catalog import PluginSpecfrom jarvis.marketplace.token_store import Tokens-def _spec(mcp_server) -> PluginSpec:+def _spec(mcp_server, source: str = "builtin") -> PluginSpec:return PluginSpec(id="google-calendar",display_name="Google Calendar",@@ -15,6 +15,7 @@ def _spec(mcp_server) -> PluginSpec:auth={"mode": "pat_paste", "token_creation_url": "x", "token_prefix": "ya29","validation_endpoint": "x", "instruction_md": "x"},mcp_server=mcp_server,+ source=source,)@@ -47,6 +48,37 @@ def test_stdio_transport_resolves_install_and_env():assert env_overrides == {"CAL_TOKEN": "TOK123"}+_STDIO = {+ "transport": "stdio",+ "install": ["npx", "-y", "@calendar/[email protected]"],+ "env_template": {"CAL_TOKEN": "${plugin_google-calendar_access_token}"},+}+++def test_a_community_plugin_starts_without_the_owners_environment():+ """A stranger's command line must not inherit the user's API keys.++ Without this flag the plugin process is started with `dict(os.environ)`,+ which on a developer's machine is where every exported provider key lives+ — one `os.environ` read away from code the user only saw in a dialog.+ """+ plugin = _spec(dict(_STDIO), source="community")+ result = plugin_to_mcp_server_spec(plugin, Tokens(access="TOK123"))+ assert result is not None+ assert result[0].isolate_env is True+++def test_the_users_own_plugins_keep_their_environment():+ """A seed plugin is this project's own code and a local upload is the+ user's; cutting their environment would break servers that legitimately+ read a token straight out of it."""+ for source in ("builtin", "local"):+ plugin = _spec(dict(_STDIO), source=source)+ result = plugin_to_mcp_server_spec(plugin, Tokens(access="TOK123"))+ assert result is not None+ assert result[0].isolate_env is False, source++def test_unsupported_transport_returns_none():plugin = _spec({"transport": "rest_wrapper", "url": "x"})assert plugin_to_mcp_server_spec(plugin, Tokens(access="TOK123")) is Nonediff --git a/tests/unit/mcp/test_env_isolation.py b/tests/unit/mcp/test_env_isolation.pynew file mode 100644index 0000000000..6ad9fe612a--- /dev/null+++ b/tests/unit/mcp/test_env_isolation.py@@ -0,0 +1,104 @@+"""What a community plugin's process is allowed to see.++The point of the isolation is a single sentence: a stranger's code running as+our child process must not be able to read the owner's API keys by looking at+its own environment.+"""++from __future__ import annotations++import sys++import pytest++from jarvis.mcp.env_isolation import isolated_environment++# The shapes a real machine actually leaks: exported provider keys, a token a+# shell profile set, and the credential helpers a developer accumulates.+SECRETS = {+ "OPENAI_API_KEY": "sk-not-a-real-key-000000000000",+ "ANTHROPIC_API_KEY": "sk-ant-not-real-000000000000",+ "GITHUB_TOKEN": "gho_notarealtoken0000000000",+ "AWS_SECRET_ACCESS_KEY": "not-real",+ "JARVIS_CONTROL_KEY": "not-real",+}+++def machine(monkeypatch: pytest.MonkeyPatch) -> None:+ for name, value in SECRETS.items():+ monkeypatch.setenv(name, value)+ # The variables a process genuinely needs, so the test proves the cut is+ # selective rather than total.+ monkeypatch.setenv("PATH", "/usr/bin")+ if sys.platform == "win32":+ monkeypatch.setenv("SYSTEMROOT", r"C:\Windows")+++def test_no_credential_survives(machine: None) -> None:+ env = isolated_environment()+ for name in SECRETS:+ assert name not in env, f"{name} reached an untrusted plugin"+++def test_the_process_can_still_start(machine: None) -> None:+ env = isolated_environment()+ assert env.get("PATH") == "/usr/bin"+ if sys.platform == "win32":+ # Without SYSTEMROOT the loader cannot find the C runtime and the+ # process dies before its first line.+ assert "SYSTEMROOT" in env+++def test_the_plugin_still_gets_its_own_token(machine: None) -> None:+ env = isolated_environment({"TODOFOX_TOKEN": "tfx_this_plugins_own"})+ assert env["TODOFOX_TOKEN"] == "tfx_this_plugins_own"+ assert "OPENAI_API_KEY" not in env+++def test_a_proxy_survives_because_nothing_installs_without_it(+ machine: None, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setenv("HTTPS_PROXY", "http://proxy.internal:8080")+ assert isolated_environment()["HTTPS_PROXY"] == "http://proxy.internal:8080"+++def test_the_client_actually_honours_the_flag(machine: None) -> None:+ """The end of the wire.++ `isolated_environment` can be perfect and the flag can be set correctly on+ every community plugin, and the credentials still leak if the one place+ that builds the child's environment ignores both.+ """+ from jarvis.mcp.client import MCPClient+ from jarvis.mcp.registry import MCPServerSpec++ def build(isolate: bool) -> dict[str, str]:+ spec = MCPServerSpec(+ name="todo-fox",+ display="TodoFox",+ description="Tasks",+ install_command=["npx", "-y", "@todofox/[email protected]"],+ transport="stdio",+ isolate_env=isolate,+ )+ client = MCPClient(spec, env_overrides={"TODOFOX_TOKEN": "tfx_own"})+ return client._resolve_install_command()[2]++ isolated = build(True)+ assert "OPENAI_API_KEY" not in isolated+ assert isolated["TODOFOX_TOKEN"] == "tfx_own"++ # The default is unchanged: the user's own servers still see everything.+ assert build(False)["OPENAI_API_KEY"] == SECRETS["OPENAI_API_KEY"]++[email protected](sys.platform != "win32", reason="Windows env names are case-insensitive")+def test_windows_matches_a_name_in_any_case(monkeypatch: pytest.MonkeyPatch) -> None:+ """`Path` and `PATH` are the same variable on Windows, and os.environ can+ hand back either spelling depending on who set it."""+ monkeypatch.setenv("Path", "C:\\bin")+ monkeypatch.setenv("OPENAI_API_KEY", "sk-not-real-0000000000000")+ env = isolated_environment()+ assert any(key.upper() == "PATH" for key in env)+ assert "OPENAI_API_KEY" not in env