Skip to content

codex/claude-code: Ubuntu 24.04 bwrap-userns-restrict profile breaks Claude Code's sandbox; suggest Claude Code's bwrap profile #1309

Open

Description

@sumanthratna

On Ubuntu 24.04, the AppArmor setup that the codex module's README links to breaks Claude Code's sandbox when the claude-code module runs in the same workspace. A profile from Claude Code's docs works for both agents.

Background

#1251 was closed by #1258. That PR made the codex module warn when bwrap is missing and linked to Codex's sandboxing docs. For Ubuntu 24.04, those docs recommend Ubuntu's bwrap-userns-restrict profile from apparmor-profiles.

That profile runs every process bwrap starts under the unpriv_bwrap profile. Claude Code's sandbox creates a nested user namespace inside bwrap for its seccomp helper, and unpriv_bwrap blocks it:

apply-seccomp: write /proc/self/setgroups (nested userns is capability-restricted; caller must provide CAP_SYS_ADMIN)

Repro

Tested on Ubuntu 24.04.5 with distro bubblewrap installed and Codex 0.171.0. Each check writes to /etc from inside the agent's sandbox.

Setup codex sandbox -- Claude Code sandboxed Bash
No AppArmor profile, restriction on bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted not run
bwrap-userns-restrict (Codex docs) runs; write blocked apply-seccomp error above
bwrap-userns-restrict + kernel.apparmor_restrict_unprivileged_userns=0 not run same error
Claude Code docs' profile, restriction on runs; write blocked runs; write blocked

The profile that works for both:

abi <abi/4.0>,
include <tunables/global>

profile bwrap /usr/bin/bwrap flags=(unconfined) {
  userns,
  include if exists <local/bwrap>
}

Suggested changes

  1. In the codex and claude-code module READMEs, recommend the profile above for Ubuntu 24.04, or note that bwrap-userns-restrict breaks Claude Code's sandbox. The claude-code README currently doesn't mention bubblewrap or AppArmor.
  2. Optional: warn when kernel.apparmor_restrict_unprivileged_userns=1 and no AppArmor profile covers /usr/bin/bwrap. Today's check only looks for bwrap on PATH, so the RTM_NEWADDR failure from codex: document and check Linux bubblewrap/AppArmor prerequisites #1251 gets no warning when bwrap is installed.

Related: #1251, #1258, #1266 (a container variant with a different error).

Activity

  1. linear-code commented on Nov 20, 2026

    @linear-code
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions