Status: living document. It traces the exact authority chain a security reviewer raised —
untrusted content -> agent -> MCP/plugin -> exec -> Git/SSH— and for each hop states the boundary, where it is enforced, and the test that guards it. It also states residual risk plainly. "Runs locally" is not treated as equivalent to "safely bounded."This document covers granting authority. Its companion,
execution-custody.md, covers withdrawing it once granted — the tripwire, halt, and reauthorization lifecycle.
CrewCode has three trust tiers. The whole model rests on keeping them apart:
| Tier | Who | What it can reach |
|---|---|---|
| Trusted renderer | CrewCode's own React app | All ~165 ipcMain handlers, via contextBridge (window.electronAPI) |
| Untrusted plugin UI | third-party plugin code | A sandboxed iframe with no electronAPI; reaches the main process through exactly two postMessage channels (see below) |
| Untrusted content | scraped pages, file contents, MCP tool output, agent responses | Enters the system as data, not as an authority holder |
Key principle the reviewer named: same visibility ≠ same instruction authority. Content an agent can see does not inherit the agent's power to act. Authority is re-decided at each hop's gate, not carried forward as context.
contextIsolation: true,nodeIntegration: false,sandboxdefaults preserved (src/main/index.ts:138). Verify in the running app: DevTools consolerequirethrowsReferenceError.- The renderer receives a typed
contextBridgesurface only (src/preload/index.ts:55), never raw Node oripcRenderer. - Production renderer CSP locks
default-src 'self',connect-src 'self' data: blob:(src/main/index.ts:89), so a compromised renderer cannot open arbitrary sockets.
Boundary: a network browser must not acquire privileged RPC authority through a replayed pairing link, stolen persisted file, cross-origin request, or unbounded credential guessing.
Enforcement: RemoteAccessAuth keeps pairing credentials memory-only,
short-lived, and single-use. Device session files contain SHA-256 digests rather than
bearer tokens, are written atomically with owner-only permissions, survive restart,
and enforce 30-day absolute plus 7-day idle expiry. Authenticated auth.sessions and
auth.revoke RPC expose only sanitized metadata. HTTP and WebSocket browser requests
must match the request's exact origin or a CLI-configured --public-origin.
Pairing and failed-session attempts use bounded per-peer fixed-window limits. The
brain still revalidates registered workspace roots for filesystem, Git, PTY, and
agent operations; transport authentication does not widen filesystem scope.
Tests: remote-access-auth.test.ts, remote-access-security.test.ts, and
remote-access-server.test.ts cover persistence/restart, expiry, revocation,
corrupt-store refusal, origin rejection, rate limiting, and workspace denial.
Residual limitation: the direct server does not yet have a general per-authenticated-session RPC bandwidth/request budget, remote execution custody is not fully persisted, and public deployment still depends on correctly configured TLS/reverse-proxy infrastructure. Prefer loopback or a trusted tailnet.
Boundary: injected instructions in scraped/file/MCP content must not gain execution authority.
Enforcement: this is defense-in-depth, not content trust classification.
CrewCode does not (and cannot reliably) tag content as "trusted." Instead the
downstream hops each re-gate. An injected "run git push --force" only matters
if it clears the exec gate at hop 4.
Honest note: prompt injection can influence what an agent says or attempts. That is true of every agent tool today. Our guarantee is about what it can do without passing a gate, not about immunity to being influenced.
Boundary: a plugin gets exactly the authority its manifest declared — no more — and cannot reach the privileged IPC surface directly.
Enforcement:
- Plugin UI runs in a sandboxed iframe (
allow-scripts allow-same-origin allow-forms), loaded overcrewcode-plugin://(neverfile://), withreferrerPolicy: no-referrer(PluginTabHost.tsx). It never receiveswindow.electronAPI(verify: iframe consolewindow.electronAPIisundefined). - The iframe's only path to the main process is two host-mediated channels:
plugins:invoke(permission-gated) andplugins:recordRuntimeError(logs a string). The host hardcodesregistrationIdandworkspaceRoot; the plugin cannot spoof its identity or target another workspace. - Every capability is checked against the declared permission set in
invokePluginCapabilityWithPlugins(plugin-contract.ts). Undeclared capability => denied.network:fetchandsecrets:getare denied outright in v0. - Workspace file access is path-scoped by
isSafePathUnder;../escape => denied, even with the permission granted.
Tests: security-boundary-proof.test.ts (group C), plugin-contract.test.ts.
Boundary: read/plan modes cannot silently execute; write access is an explicit, per-request or opt-in decision, never a default that untrusted input can flip.
Enforcement (per agent, because each bridge differs):
- Codex —
getModeConfig: plan/ask =>sandbox: read-only+approvalPolicy: untrusted;codexApprovalDecisionForModeauto-declines.fullis the only auto-accept, and an explicitread-onlytool policy overrides evenfull. - Claude —
getClaudeModeOptions: plan/ask/read-only putBash, Edit, MultiEdit, Write, NotebookEdit(+ExitPlanModein plan) indisallowedTools; the SDK never invokes them.bypassPermissionsis reachable only via explicitfullmode. Runtime approvals route throughcanUseTool(claude-bridge.ts:510).
Tests: security-boundary-proof.test.ts (group D), codex-bridge.test.ts.
Boundary: remote trust is pinned, external launches are allowlisted.
Enforcement:
- SSH host keys are TOFU-pinned in
~/.crewcode/known-hosts.json(0600). A changed key fails the handshake (makeHostVerifier,remote/host-keys.ts). shell.openExternalaccepts onlyhttp:/https:/mailto:(index.ts:577);setWindowOpenHandlerapplies the same allowlist.- Plugin capabilities are denied entirely on remote (
ssh://) workspaces in v0.
Tests: security-boundary-proof.test.ts (group E), remote-access-server.test.ts.
Boundary: a grant stops being valid the moment CrewCode can no longer say what it covers. Hops 1–4 decide whether authority may cross the next boundary; they are stateless and only run when something asks. Agent runs are long-lived, so the dangerous state is not "the attacker got in" — it is the system no longer knows whether its previously granted authority is still lawful, and continued anyway.
Enforcement: a persisted custody record per bridge execution, and a tripwire
that refuses, contains, preserves, reports, and requires explicit human
reauthorization. Five invariants: restart-recovery, execution-custody-lost,
authority-drift, scope-unknown, orphaned-authorization.
The governing rule, binding on all new work via AGENTS.md:
silence != success · timeout != success · lost telemetry != success
missing process state != success · clean Git state != behavioral correctness
An outcome that was never observed is recorded as unknown. It is never back-filled by inference. A mode change requested underneath a running turn is refused and deferred to the next turn rather than applied mid-flight.
Coverage, stated honestly: the desktop bridge coordinator is fully covered. The remote-access transport defers mid-turn mode changes and cancels orphaned permission requests, but does not yet persist custody records. Terminal panes, plugin capability sessions, and mid-session SSH host-key changes are not yet covered. Crew merges have their own equivalent journal.
Tests: security-boundary-proof.test.ts (group F), custody-invariants.test.ts,
custody-journal.test.ts, custody.test.ts. Full detail:
execution-custody.md.
- Install is Git-first, pinned to a reviewed commit. The installer runs no build
scripts, hooks, or package installs (no
child_processinplugins.ts). - Symlinks, submodules,
node_modules, and oversized trees are rejected. - Updates come only from the recorded repo, back up the prior folder, and re-require approval for every new revision even when permissions are unchanged.
- Provider credentials live in
userData(0600), are never in source, and are not exposed to plugins without asecrets:readroute (which is denied in v0).
Tests: plugin-git-install.test.ts.
# Boundary proofs: plugin authority, exec gates (all 6 bridges), iframe sandbox, SSH TOFU
npx vitest run src/main/security-boundary-proof.test.ts
# Renderer-boundary regression guards: CSP, isolation flags, external-URL allowlist
npx vitest run src/main/security-config.test.ts
# Execution custody: invariant detection, journal recovery, halt/reauthorize
npx vitest run src/main/agents/custody-invariants.test.ts \
src/main/agents/custody-journal.test.ts \
src/main/agents/custody.test.ts
# Full security-relevant suite
npx vitest run src/main/security-boundary-proof.test.ts \
src/main/security-config.test.ts \
src/main/plugin-contract.test.ts \
src/main/plugin-git-install.test.ts \
src/main/remote-access-server.test.ts \
src/main/agents/codex-bridge.test.ts \
src/main/agents/custody-invariants.test.ts \
src/main/agents/custody-journal.test.ts \
src/main/agents/custody.test.ts
# Live checks in the running app (DevTools console):
# main window: require -> ReferenceError
# plugin iframe: window.electronAPI -> undefinedSplit into what has been hardened and what is inherent (true of every tool in this class — the honest move is to frame it, not fake a patch).
A caution about the word "inherent." A failure mode can be inherent to a component without its consequence being inherent to the system. Prompt injection inherently influences an agent; an MCP server inherently runs with user privilege. That bounds what those components can be trusted to do — it does not license CrewCode to keep executing once one of those risks stops being hypothetical. Hop 5 above exists because of exactly that distinction: the items below describe what cannot be prevented, not what cannot be contained after the fact.
- Renderer authority boundary. CSP,
contextIsolation/nodeIntegration, and the external-URL launch allowlist now live in one pure module (security-config.ts) and are pinned bysecurity-config.test.ts(CSP has nounsafe-eval/wildcard,object-src/base-uriare'none',connect-srcstays off the open internet, only http/https/ mailto launch externally). This does not make renderer script-execution impossible — a dependency compromise remains the real risk — but it forecloses accidental loosening. - Plugin iframe isolation. Each plugin loads from
crewcode-plugin://<pluginId>, a distinct standard-scheme origin — cross-origin to the app renderer and to every other plugin.allow-same-origingrants the frame only its own origin (for asset loading); it cannot reachparent. The sandbox token set is pinned by test so it can't gainallow-top-navigation/allow-popups/allow-modals. Verified live: iframewindow.electronAPIisundefined. - Exec gate across ALL six agent bridges. Previously only Codex/Claude were proven.
Now OpenCode, Hermes, pi, Grok, CrewCoder(ACP), and Claude/Codex each have a boundary
test that read-only/ask/plan block writes and that
full/bypass is reachable only by explicit opt-in. Ollama and OpenRouter expose no tool surface at all (pure chat streamers), so they cannot write or exec regardless of mode. - Crew-lane authority can be withdrawn after it was granted. Previously CrewCode
could only deny the next action; a grant already in flight was good until the lane
ended, and an execution whose outcome was never observed left no trace. For synthetic
crew lane bridge threads, a persisted custody journal records execution, an interrupted
turn is recovered as halted rather than assumed complete, mid-turn authority mutations
are refused and deferred, and a tripped invariant refuses privileged actions until a
human explicitly reauthorizes — reporting the exact failed invariant and affected
scope, with the interrupted prompt and partial response preserved. Ordinary solo chats
and crew supervisors deliberately retain normal provider error/retry behavior. See hop 5 and
execution-custody.md. Coverage gaps (remote transport, PTY, plugin sessions) are named there rather than implied away.
-
Prompt injection at hop 1. Mitigated by downstream gates, not eliminated. An agent can still be socially engineered into proposing bad actions; the defense is that acting on them requires clearing the hop 3/4 gates above. No agent tool on the market eliminates this; claiming otherwise is a red flag. What is not inherent is continuing afterwards: if an injected action leaves execution in a state CrewCode can no longer account for, hop 5 halts the thread rather than carrying the grant forward.
-
User-enabled Full Access — now backstopped by a hard tripwire.
fullmode deliberately removes the per-action gate; it is a user opt-in, never the default (default isbuild, pinned by test). On top of that, a hard denylist tripwire (agents/dangerous-command.ts) forces a confirmation prompt for catastrophic shell commands even in Full Access —rm -rf,git push --force,curl|sh,dd/mkfs,sudo, fork bombs,chmod -R 777 /,terraform destroy, etc. Benign commands stay friction-free (verified it does not flagnpm install,git push,chmod +x, ...). This directly limits the compound risk of prompt-injection (#5) + Full Access.Per-agent coverage (stated honestly):
- Claude — full coverage. Full Access routes through
canUseTool(no more nativebypassPermissions), so every command is classified; denylisted ones pause. Highest priority because Claude's Full Access is an unsandboxed shell. - Grok — full coverage. Full Access now routes through
session/request_permission(--permission-mode defaultinstead ofbypassPermissions); benign commands auto-approve, denylisted ones pause. Also an unsandboxed shell, so high priority. - CrewCoder(ACP), Hermes(ACP) — covered via the tool call's
rawInput; denylisted commands fall through to a confirmation prompt instead of auto-approving. - Codex — defense-in-depth tripwire wired into its approval handler, AND Full Access
runs under a
workspace-writesandbox (writes scoped to the workspace, network off). The sandbox alone already blocks most of the denylist (curl|sh, force-push,dd,mkfs,sudo,chmod /all need network or out-of-workspace access it denies); the only residual is destroying files inside the workspace, which is git-recoverable. - pi — not covered. pi's protocol has no pre-execution permission request that
carries the command string (its
confirmchannel omits it, andtool_execution_startis informational — it cannot block). A tripwire here needs a pi protocol change; a best-effort hook would be false confidence, so it is deliberately omitted and tracked. - Ollama, OpenRouter — N/A (no tool surface; cannot exec).
- Claude — full coverage. Full Access routes through
-
MCP servers run with user privilege. A user-configured MCP server is trusted code on the host; CrewCode gates which sessions may use it, not what the server binary itself can do — the same trust model as installing any CLI tool. What CrewCode does control is its own record of which servers a live grant covers: an MCP server appearing or disappearing under a running execution is
authority-driftand halts the thread.
Every gate we can enumerate is proven to deny by an executable test, and every privileged path from untrusted code is mapped to a gate above. That is the achievable definition of "completely tested." It is not a mathematical proof that no bypass exists anywhere — no test suite provides that. The residual-risk section is where we keep that honest.