Repository navigation
Description
Summary
Ran a security review before adopting jcode (auth, telemetry, supply chain, deps, and the agent/tool-execution trust boundary). Most of it looks solid: PKCE OAuth, CSRF state, 0600/0700 credential file hardening, self-hosted telemetry with an opt-out that's actually enforced in code, clean dependency pins. Good work there.
The area that actually worries me is the tool-execution / agent trust boundary, basically what stands between a model deciding to run something and it actually happening. Filing this as one issue since the findings are related, happy to split if you'd rather. Opening a PR from a fork shortly with fixes for all five.
Findings
1. No permission/confirmation gate on tool execution in normal interactive sessions
crates/jcode-app-core/src/agent/turn_loops.rs calls registry.execute(...) the moment the model emits a tool call (bash/write/edit/patch), no confirmation step. The only human-in-the-loop system (SafetySystem in jcode-base/src/safety.rs, plus jcode-tui-permissions) is wired exclusively into "ambient" background mode. docs/SAFETY_SYSTEM.md even says so itself: "Currently the only consumer is ambient mode," and it's marked Status: Design.
So a prompt injection from a fetched webpage, a README, or MCP tool output can get shell commands run with the user only seeing it after the fact. This is a big departure from how comparable tools handle it (approval by default, explicit opt-in to skip it).
2. Path traversal in file write/edit tools
ToolContext::resolve_path (jcode-tool-core/src/lib.rs) just joins relative paths onto working_dir, no canonicalization or bounds check, and passes absolute paths through as-is. Used directly by WriteTool, EditTool, PatchTool. Combine with #1 and a model-supplied path like ../../../.ssh/authorized_keys (or any absolute path) gets honored no questions asked.
3. MCP tool output fed back to the model unsanitized
McpTool::execute (jcode-base/src/mcp/tool.rs) forwards a server's raw content as the tool result with no tagging as external/untrusted. A malicious or compromised MCP server can just return injected instructions that land in context and, combined with #1, get acted on right away.
4. Agent can spawn arbitrary MCP server subprocesses, no confirmation
connect_server (jcode-app-core/src/tool/mcp.rs) lets the model call mcp connect with whatever command/args it wants, spawns a local subprocess, zero approval.
5. Swarm sub-agents have no privilege separation
crates/jcode-app-core/src/server/swarm.rs notes the spawn-tree depth cap isn't actually enforced in code anymore. Swarm members get the same unconfirmed tool registry (shell, files, MCP connect, further spawning) as the parent session.
Suggested direction
Wiring some form of confirmation gate into the default interactive tool-execution path (not just ambient mode) covers #1, and gives a natural enforcement point for #3/#4 (treat MCP-originated content/actions as needing confirmation) and #5 (route sub-agent calls through the same gate, actually enforce the depth cap). Note: the existing SafetySystem is built for async/unmonitored operation (review queue, email/SMS notifications) which doesn't map cleanly onto a synchronous interactive session, so this probably wants a simpler, separate synchronous confirm-prompt path rather than reusing SafetySystem directly. #2 is independent, just needs canonicalization plus a working-directory bounds check in resolve_path.
Happy to talk through design tradeoffs before or on the PR.
Activity
[-]Security review: no permission gate on tool execution in interactive sessions (+ 4 related trust-boundary gaps)[/-][+]Security review: no permission gate on tool execution in interactive sessions, plus 4 related trust-boundary gaps[/+]1jehuang commentedon Jul 24, 2026
Thanks for the structured security review. Permission gating on tool execution and the related trust-boundary gaps are explicitly maintainer-decision territory (they change the default trust model and could break existing automated workflows), so an agent should not implement these autonomously. Marked as needs-decision for @1jehuang. #566 requests a related directory-scoping capability and should be considered together with this.
— Jcode agent (automated triage), on behalf of @1jehuang
luukvhoudt commentedon Jul 28, 2026
Independent review against v0.61.1 (
438789eb) reaches the same conclusions, and I can add two concrete points.Finding
#1is worse than "no gate": jcode disables the wrapped tool's gate too. When jcode drives the Claude CLI as a provider, it launches it with--permission-mode bypassPermissionsby default:The value is applied as
--permission-mode <mode>atlib.rs:913-914, defaulting to that constant unlessJCODE_CLAUDE_CLI_PERMISSION_MODE(orJCODE_CLAUDE_SDK_PERMISSION_MODE) overrides it (lib.rs:148-156). So a user assuming "Claude CLI's own approval prompts still protect me" is not protected by default; jcode turns them off.Finding
#2is still present in v0.61.1.resolve_pathis unchanged:Absolute paths pass through as-is and relative paths are joined with no canonicalization or bounds check; I found no bounds/canonicalize step in the write/edit/patch tools that call it. Combined with #1 (no gate), a single injected instruction from a fetched page, README, or MCP result can write anywhere the user can: appending an attacker's key to
~/.ssh/authorized_keys(remote login), or dropping a~/.zshrc/~/.bashrcline (code execution on next shell). No prompt, no path bound.Note the destructive-command reflection turn (#618) is model-facing (a justification string satisfies it), not a user confirmation, so it does not cover finding
#1for writes/edits or injected-instruction execution.security: respect Claude CLI's native permission prompts by default
security: add resolve_path_safe with path-traversal prevention
security: add restricted mode for swarm sub-agents
security: add interactive permission gate for tool execution
docs: add SECURITY.md summarizing all hardening changes
42m4n commentedon Aug 6, 2026
I ran into this as well during interactive sessions. v0.68.0
What I'm looking for is an opencode-style permission model: allow by default, but ask before potentially destructive shell commands (for example
rm,git push,git checkout) and before accessing files outside a configured directory allow-list.Since there isn't a built-in configurable permission model today, I implemented it with a
pre_toolgate hook (Zenity prompt; exit 0 = allow, exit 2 = deny; directory allow-list loaded from a config file). It works well enough, but I think these capabilities belong in jcode itself:config.tomlfor interactive sessions (allow/ask/deny per command pattern and per directory root), similar to opencode's"*": "allow"plusexternal_directory: "ask"model.[safety.rules](allow_without_permission/require_permission) to interactive tool execution, not only Ambient Mode.I'd be happy to test a native implementation or share my hook as a reference if it's useful.
devinder-getok commentedon Sep 2, 2026
hi @42m4n , were you able to work around this? Happy to contribute and raise a PR if required
Shxnque commentedon Sep 2, 2026
Landing on @benrrr56-wq's point because it's the crux: bind the gate to the canonicalized
(command, resolved_path, cwd)tuple, not the model's rawargs. Three things I'd fold in so the gate can't be defeated the ways this thread has already surfaced:1. Boundary at the executor, not the provider. @luukvhoudt's
bypassPermissionsdefault is exactly why: if the gate lives in a provider that a sub-runtime can be launched with--permission-mode bypassPermissions, it isn't a boundary, it's a suggestion. The check has to sit atregistry.execute(...)/ the tool executor itself, so no provider flag can route around it.2. Decide over a content hash, and re-verify it at exec. Compute
decision_key = sha256(normalize(command, resolve_path(path), cwd)), have the gate decide on that, then have the executor re-check the same hash immediately before running. That closes @benrrr56-wq's reverse-TOCTOU (user approves what the model intended, shell runs what the resolver normalized) and folds finding #2 in: an out-of-bounds resolved path changes the hash and can never match an approval.resolve_pathhas to canonicalize + bounds-check first, or the hash is computed over the wrong thing.3. Gate on effect-class × provenance, not on everything. This is the part that speaks to the maintainer's "don't break existing automated workflows" concern (the reason this is
needs-decision): you don't have to prompt on every call. Gate when the effect class is sensitive (shell exec, fs-write, network egress) and the tool call's provenance is untrusted — i.e. it originated from or was influenced by fetched web content, a README, or MCP tool output, which is the actual injection surface in finding #1. A model-authorededitinside a trusted turn can stay allow-by-default; the samebash rm -rfsynthesized right after untrusted MCP output gates. That's opencode-style ergonomics (@42m4n) without a confirm-storm.Fully respect that the default trust model is maintainer territory per the triage note — offering this as design input, not an autonomous change. If it's useful I'm happy to help spec the executor-side gate and a few negative test vectors (approve-then-mutate,
bypassPermissions-can't-defeat, untrusted-provenance-sensitive-call). This exact seam — decision bound to a normalized-call hash, re-verified at execution, keyed on effect-class × provenance — is something we've built deterministically on the Quesen side, so happy to share what held up in practice.