Area
CLI; Platform (Linux); Service lifecycle.
What are you trying to accomplish?
I need to run ocx claude --dangerously-skip-permissions in a root-owned VPS/container deployment without patching src/cli/claude.ts after every OpenCodex upgrade, while preserving OpenCodex's current fail-closed behavior for all operators who do not explicitly opt in.
Claude Code 2.1.205+ exits when all of these are true:
- process UID is 0;
- bypass permissions was explicitly requested;
IS_SANDBOX != 1;
- no recognized external sandbox marker is present.
What prevents this today?
Issue #1688 accurately diagnosed the workflow. The upstream resolution intentionally refused to set IS_SANDBOX=1 automatically because UID 0 is not proof of isolation. That is the correct safe default, but root-only deployments have no supported operator-level override in OpenCodex.
The only working local workaround is this source patch in buildClaudeEnv():
if (typeof process.getuid === "function" && process.getuid() === 0) {
setDefault("IS_SANDBOX", "1");
}
It has been validated across OpenCodex updates, but it leaves the installed package different from the official npm tarball and must be reapplied after upgrades.
What should OpenCodex do?
Expose a deliberately named, default-false config option for operators who explicitly accept this risk, for example:
{
"claudeCode": {
"allowRootSandbox": true
}
}
When and only when all conditions are met:
- the config flag is
true;
process.getuid() === 0;
- the launch explicitly includes
--dangerously-skip-permissions;
OpenCodex should call setDefault("IS_SANDBOX", "1") for the child environment and emit a concise warning. An explicitly exported IS_SANDBOX=0 must continue to win. Ordinary Claude launches must remain unchanged.
This preserves the secure default from #1688 while giving VPS/container operators an auditable, supported opt-in instead of requiring an out-of-tree patch.
Example usage or interface
{
"claudeCode": {
"allowRootSandbox": true
}
}
# Explicit operator opt-in + explicit dangerous CLI flag
ocx claude --dangerously-skip-permissions --print "reply OK"
# Expected warning
# OpenCodex: root sandbox override enabled by claudeCode.allowRootSandbox
Expected guards:
# Default config: still fail closed
ocx claude --dangerously-skip-permissions
# Explicit user opt-out wins even when config is true
IS_SANDBOX=0 ocx claude --dangerously-skip-permissions
# Ordinary launch: no override injected
ocx claude --print "reply OK"
Alternatives or workarounds
- Patch
src/cli/claude.ts after every npm update: works but creates permanent package drift.
- Export
IS_SANDBOX=1 manually: not centrally auditable and easy to apply too broadly.
- Run OpenCodex as a non-root user: preferable where possible, but not always available in existing root-owned VPS/container deployments.
- Create/verify a real OS sandbox: strongest design, but significantly larger in scope; the proposed flag remains an explicit risk acceptance, not a claim that UID 0 is isolated.
Additional context
Checks
Area
CLI; Platform (Linux); Service lifecycle.
What are you trying to accomplish?
I need to run
ocx claude --dangerously-skip-permissionsin a root-owned VPS/container deployment without patchingsrc/cli/claude.tsafter every OpenCodex upgrade, while preserving OpenCodex's current fail-closed behavior for all operators who do not explicitly opt in.Claude Code 2.1.205+ exits when all of these are true:
IS_SANDBOX != 1;What prevents this today?
Issue #1688 accurately diagnosed the workflow. The upstream resolution intentionally refused to set
IS_SANDBOX=1automatically because UID 0 is not proof of isolation. That is the correct safe default, but root-only deployments have no supported operator-level override in OpenCodex.The only working local workaround is this source patch in
buildClaudeEnv():It has been validated across OpenCodex updates, but it leaves the installed package different from the official npm tarball and must be reapplied after upgrades.
What should OpenCodex do?
Expose a deliberately named, default-false config option for operators who explicitly accept this risk, for example:
{ "claudeCode": { "allowRootSandbox": true } }When and only when all conditions are met:
true;process.getuid() === 0;--dangerously-skip-permissions;OpenCodex should call
setDefault("IS_SANDBOX", "1")for the child environment and emit a concise warning. An explicitly exportedIS_SANDBOX=0must continue to win. Ordinary Claude launches must remain unchanged.This preserves the secure default from #1688 while giving VPS/container operators an auditable, supported opt-in instead of requiring an out-of-tree patch.
Example usage or interface
{ "claudeCode": { "allowRootSandbox": true } }Expected guards:
Alternatives or workarounds
src/cli/claude.tsafter every npm update: works but creates permanent package drift.IS_SANDBOX=1manually: not centrally auditable and easy to apply too broadly.Additional context
IS_SANDBOXhandling insrc/cli/claude.ts.Checks