openai/codex · error

error applying legacy Linux sandbox restrictions

Error message

error applying legacy Linux sandbox restrictions: {e:?}

What it means

The legacy Landlock-only enforcement path failed to apply sandbox restrictions to the current thread. This panic in run_main fires on the fallback path (used when bubblewrap sandboxing is not enabled) when apply_permission_profile_to_current_thread with Landlock enabled returns an Err, meaning the filesystem/network rules could not be installed and the command must not run unsandboxed.

Solutions

  1. Read the embedded error to identify whether Landlock rule creation or network enforcement failed
  2. Verify the kernel supports Landlock (Linux 5.13+) and the required Landlock ABI version
  3. Prefer the non-legacy bwrap path if the environment supports it
  4. Report with kernel version if restrictions fail on supported kernels
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:332 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/f2fdcdcedb6996d3. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:332

            &sandbox_policy_cwd,
            command_cwd.as_deref(),
            &file_system_sandbox_policy,
            network_sandbox_policy,
            inner,
            !no_proc,
            allow_network_for_proxy,
        );
    }

    // Legacy path: Landlock enforcement only, when bwrap sandboxing is not enabled.
    if let Err(e) = apply_permission_profile_to_current_thread(
        &permission_profile,
        &sandbox_policy_cwd,
        /*apply_landlock_fs*/ true,
        allow_network_for_proxy,
        /*proxy_routed_network*/ false,
    ) {
        panic!("error applying legacy Linux sandbox restrictions: {e:?}");
    }
    exec_or_panic(command);
}

#[derive(Debug, Clone)]
struct EffectivePermissions {
    permission_profile: PermissionProfile,
    file_system_sandbox_policy: FileSystemSandboxPolicy,
    network_sandbox_policy: NetworkSandboxPolicy,
}

#[derive(Debug, PartialEq, Eq)]
enum ResolvePermissionProfileError {
    MissingConfiguration,
}

impl fmt::Display for ResolvePermissionProfileError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View on GitHub (pinned to 339751715c)