#1365·khoj

Security: No setting to disable agent code-execution sandbox for self-hosted multi-user / team installs

Author: chirag127Created Jul 1, 2026Updated Aug 11, 2026

Summary

Khoj self-hosted supports agent code execution (via the Terrarium/sandbox feature). There is no admin setting to globally disable code execution for installations where this capability is not wanted — e.g. shared team or family installs where arbitrary code execution is a security and compliance concern.

Environment

  • OS: Windows 11 Enterprise 10.0.26200
  • Khoj self-hosted via Docker Desktop 4.79 (WSL2 backend)
  • Multi-user self-hosted deployment (personal + team access)

Problem

On a self-hosted instance shared with other users:

  • Any user can instruct a Khoj agent to execute arbitrary Python/shell code via the Terrarium sandbox
  • There is no admin toggle in the settings panel to disable this capability fleet-wide
  • The only mitigation is to not run the sandbox container — but this breaks the compose setup and is undocumented as a supported configuration

For a self-hosted instance whose primary purpose is semantic search / MCP knowledge retrieval (indexing notes/journal for coding agents), code execution is unnecessary and expands the attack surface significantly.

Requested feature

Add an admin setting (env var + settings panel toggle) to disable agent code execution globally:

  • KHOJ_DISABLE_CODE_EXECUTION=true env var
  • Corresponding toggle in admin panel under Security settings
  • When disabled: code execution tool is not exposed to agents; attempts return a clear refusal message rather than a sandbox error

Related security issues

  • #1347 (OS command injection via Docker Execute — directly related; disabling execution mitigates this class)
  • #1327 (cross-user data leak)
  • #1201 (CSRF)