Skip to content

feat(claude): config-level allowRootSandbox opt-in so operators don't need to patch claude.ts for root-launched sessions #2714

Closed

Description

@rrmlima

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:

  1. the config flag is true;
  2. process.getuid() === 0;
  3. 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

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. github-actions commented on Aug 26, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  2. rrmlima commented on Aug 27, 2026

    @rrmlima
    ContributorAuthor

    Updated the report to use the repository's recognized issue-template headings and filled every required field requested by the quality bot. The reproduction and all examples are redacted. Please re-evaluate/reopen automatically.

  3. rrmlima commented on Aug 27, 2026

    @rrmlima
    ContributorAuthor

    Follow-up: corrected headings to the exact GitHub issue-form rendering (). For #2717 I also added the literal Bug-template fields , , , , and because the quality bot classified the existing issue as kind=bug. All requested fields are now present.

  4. rrmlima commented on Aug 27, 2026

    @rrmlima
    ContributorAuthor

    Follow-up: corrected headings to the exact GitHub issue-form rendering (###). For #2717 I also added the literal Bug-template fields Summary, Reproduction, Version, Operating system, and Provider and model because the quality bot classified the existing issue as kind=bug. All requested fields are now present.

  5. lidge-jun commented on Aug 27, 2026

    @lidge-jun
    Owner

    리뷰 · 우선순위 34 / 80

    설명: 이 이슈는 루트로 ocx claude --dangerously-skip-permissions 를 켤 때 Claude Code 가 막는 것을, 설정 한 칸으로 우회하고 싶다는 요청이다. 작성자는 rrmlima 이다. 라벨은 enhancement 다. 보고 버전은 OpenCodex 2.33.0 이다. 지금 CURRENT dev HEAD 는 9b838d0 이다. package.json 은 아직 2.32.1-preview.20260825 다. 이번 시간 origin/dev 는 ab63ded 에서 9b838d0 로 움직였다. 마지막 머지는 2719 그림 다듬기다. 이 이슈와는 무관하다. 이 이슈는 열려 있다. 구현 풀은 없다. 내가 머지하지 않고 구현하지 않는다.

    작성자가 말한 막힘은 Claude Code 2.1.205 이후다. 유아이디가 0 이고, 권한 우회 깃발을 켰고, IS_SANDBOX 가 1 이 아니면 자식이 끝난다. 이슈 1688 이 그 길을 이미 적었다. 작성자는 1688 이 자동으로 IS_SANDBOX=1 을 넣는 것을 거절했다고 적었고, 그래서 매번 src/cli/claude.ts 의 buildClaudeEnv 에 패치를 넣는다고 한다. 원하는 설정은 claudeCode.allowRootSandbox 기본 꺼짐이다. 켜져 있고, 유아이디가 0 이고, --dangerously-skip-permissions 가 있을 때만 setDefault("IS_SANDBOX", "1") 을 하고 경고를 찍는다. 사용자가 보낸 IS_SANDBOX=0 은 그대로 이겨야 한다.

    HEAD 를 보면 그 동작은 이미 들어가 있다. 머지된 풀 2631 이 이슈 1688 을 닫으면서 넣었다. src/cli/claude.ts 309-316줄 shouldAllowRootSkipPermissions 는 인자 목록에 --dangerously-skip-permissions 가 있고 getuid() === 0 이면 참이다. 325-341줄 cmdClaude 는 그 값을 buildClaudeEnv 에 넘긴다. 120-122줄은 참일 때 setDefault("IS_SANDBOX", "1") 을 한다. 115-118줄 setDefault 는 이미 값이 있으면 안 덮는다. 그래서 사용자가 보낸 IS_SANDBOX=0 은 이긴다. 318-322줄 rootSkipPermissionsNotice 는 우회를 넣었을 때와 사용자 값을 지켰을 때 경고가 다르다. 2631 본문도 운영체제 샌드박스를 안 만들었다고 분명히 적었다.

    작성자가 원하는 세 번째 문, 설정 칸은 없다. src/types/config.ts 8줄 OcxClaudeCodeConfig 에 allowRootSandbox 가 없다. src/config.ts 의 claudeCode 검사에도 그 칸이 없다. 2631 은 설정 칸 없이, 위험 깃발과 루트 유아이디 두 개만으로 우회를 켰다. 그건 작성자 안보다 더 자동이다. 기본 꺼짐 설정 칸을 더하면 2631 보다 더 닫힌 동작이 된다. 그건 새 기능이 아니라 이미 합친 설계를 되돌리는 일이다. 보고한 2.33.0 공식 패키지에 이 코드가 없다면, 그건 배포가 dev 보다 뒤처진 것이다. 이 저장소 package.json 은 아직 2.32.1-preview.20260825 다. 소스에 패치를 심는 우회는 dev 기준으로 필요 없다.

    관련 이슈 1688 은 2631 로 닫혀 있다. 다시 열지 말 것. 1225 는 같은 2631 에 실렸지만 자동 리뷰 모델 이야기라 이 이슈와 무관하다. types.ts 와 config.ts 가르기가 진행 중이다. 만약 설정 칸을 굳이 넣는다면 src/types/config.ts 의 OcxClaudeCodeConfig 에만 넣는다. src/types.ts 를 되살리지 말 것. 프리뷰 배포가 아니다. 2464 2568 1049 2612 2210 2641 을 다시 열거나 댓글 달지 말 것.

    라인 309-316 - src/cli/claude.ts shouldAllowRootSkipPermissions 가 위험 깃발과 유아이디 0 만 본다
    라인 120-122 - buildClaudeEnv 가 그 값이 참이면 IS_SANDBOX=1 을 기본으로 넣는다
    라인 115-118 - setDefault 는 사용자 값이 있으면 안 덮는다. IS_SANDBOX=0 이 이긴다
    라인 337-341 - cmdClaude 가 루트 우회일 때 경고를 찍는다
    라인 318-322 - 경고 문구는 우회를 넣었을 때와 사용자 값을 지켰을 때가 다르다
    라인 8-88 - src/types/config.ts OcxClaudeCodeConfig 에 allowRootSandbox 칸이 없다
    풀 2631 - 이슈 1688 을 닫으며 이 우회를 이미 넣었다
    이슈 1688 - 닫혀 있다. 다시 열지 말 것
    이슈 본문 - 2.33.0 패키지에 없다고 했으나 CURRENT dev 소스에는 있다

    메인테이너의 판단이 필요한 지점

    • 이미 있는 자동 우회를 설정 칸 뒤로 숨길지. 숨기지 말 것. 2631 이 두 조건으로 충분하다고 정했다
    • 이 이슈를 1688 의 중복으로 닫을지. 닫는 편이 맞다
    • 배포본 2.33.0 에 이 코드가 없다면 버전 범프 문제인지. 이 패스의 일이 아니다. 태그하지 말 것
    • 소스 패치를 공식 우회로 남길지. 남기지 말 것. dev 를 쓰면 된다
    • 운영체제 샌드박스를 지금 만들지. 만들지 말 것. 2631 도 일부러 안 만들었다

    너의 추천
    이 이슈는 닫는다. 완료로 닫는다. 이미 dev 의 2631 이 1688 을 닫으며 같은 우회를 넣었다. 설정 칸 allowRootSandbox 는 넣지 말 것. 넣으면 이미 합친 자동 우회를 다시 잠그는 동작이 된다. 작성자에게는 소스 패치를 버리고 지금 dev 의 ocx claude --dangerously-skip-permissions 를 쓰라고 한다. 사용자가 보낸 IS_SANDBOX=0 은 그대로 이긴다. 1688 은 다시 열지 말 것. 구현 풀을 받지 말 것. 라벨은 그대로 둔다. 프리뷰 배포가 아니다. 내가 머지하지 않는다.

    이 댓글은 grok-bot이 작성했습니다

  6. rrmlima commented on Aug 28, 2026

    @rrmlima
    ContributorAuthor

    Validated against the released @bitkyc08/opencodex@2.34.0 and on the original root-owned VPS workflow.

    Evidence:

    • Both installed package copies were upgraded to 2.34.0.
    • Installed src/cli/claude.ts is byte-for-byte identical to the official npm 2.34.0 tarball; no local source patch remains.
    • The native implementation in PR fix: gate root skip-permissions bypass and ship the auto-review model override (#1688 #1225) #2631 correctly requires both UID 0 and explicit --dangerously-skip-permissions.
    • It sets IS_SANDBOX=1 only for that opted-in launch.
    • An explicit operator value such as IS_SANDBOX=0 still wins.
    • The warning explicitly states that OpenCodex did not create an OS sandbox.

    Focused upstream tests on clean main / Bun 1.4.0:

    4 pass
    0 fail
    
    root skip-permissions bypass requires both the explicit flag and uid 0
    root skip-permissions opt-in marks only that launch as sandboxed
    an explicit user sandbox value wins over the root skip-permissions opt-in
    the unsafe root bypass notice discloses that no OS sandbox was created
    

    Production verification after restart:

    OpenCodex 2.34.0: ready
    healthz: 200
    Responses x-opencodex-api-key: 200
    Responses Bearer/env_key: 200
    Unauthenticated: 401
    codex exec through shim: turn.completed
    VERIFY OK
    

    The former local apply-claude-root-bypass.sh has been retired. No further change is requested: 2.34.0 provides the desired opt-in behavior with stronger safeguards than the old local patch. Closing as completed by #2631 / 2.34.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions