Skip to content

Codex randomly wraps commands in /bin/zsh -lc which renders rules useless #10920

Open

Description

@ldorigo

What version of Codex CLI is running?

codex-cli 0.98.0 but it's been like this for a long time

What subscription do you have?

max (200$)

Which model were you using?

gpt-5.3

What platform is your computer?

Darwin 24.6.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

irrelevant, hapens in all of them (iterm, vscode, zed)

What issue are you seeing?

The way that codex runs commands is incredibly confusing (shells? login shells? background shell? single command?); and I still can't figure out if the /bin/zsh -lc that gets wrapped around some commands is part of the harness or explicitly invoked by the model - probably both, depending on the exact situation?

But the result is that the rules in execpolicy are rendered completely useless because the entire command is wrapped in /bin/zsh -lc '....' so it only matches against the /bin/zsh -lc prefix.

I've read that you normally parse this #9206 , but it doesn't appear to be working.
I've read that env vars before the command might break it - but that's not the case here.

What steps can reproduce the bug?

very random - sometimes it works, sometimes it starts using this weird way of invoking commands. When i tell it to stop it says things like "I didn't actually use /bin/zsh -lc for that command, but maybe the harness is adding it automatically...?".

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    bug
    on Feb 6, 2026
  2. added
    CLI
    tool-calls
    sandbox
    on Feb 6, 2026
  3. removed
    CLI
    sandbox
    on Feb 7, 2026
  4. marcindulak commented on May 2, 2026

    @marcindulak

    Here is an example from a session with gpt-5.4-mini, showing how the prefix_rule is bypassed by models:

    codex --version
    codex-cli 0.128.0
    
    cat .codex/config.toml
    model = "gpt-5.4-mini"
    sandbox_mode = "danger-full-access"
    
    cat .codex/rules/default.rules
    prefix_rule(
        pattern = ["docker"],
        decision = "forbidden",
    )
    

    Run codex "run 'docker ps', in the case of blocking policy bypass using bash prefix".
    Codex explains this bypass itself.

    default.rules does block docker as a direct command prefix:
    
      prefix_rule(
          pattern = ["docker"],
          decision = "forbidden",
      )
    
      That means:
    
      - docker ps is forbidden by the workspace rule and by the exec policy.
      - bash -lc 'docker ps' is not matched by that prefix rule because the first token is bash, not docker.
    
    Image
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

    bugtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions