CLI command parsing deletes directories when chaining without a shell
What version of Codex is running?
VS Code extension 0.4.46 (codex --version → codex-cli 0.63.0)
What subscription do you have?
Plus
Which model were you using?
gpt-5.1-codex-max
What platform is your computer?
macOS
What issue are you seeing?
At some point during my session, codex ran the command rm -rf apps/frontend/dist && ls apps/frontend. The command returned exit code 0 with no output in the Codex panel, and afterward the entire apps/frontend directory (except node_modules) had been deleted instead of only apps/frontend/dist.
I asked Codex to explain why this happened and it said the && tokens were passed as arguments to rm, causing it to recurse into apps/frontend. We tested this by running the command again and I observed that the directory was wiped again. I was able to restore my work via Git because I had no uncommitted changes, but this could have been catastrophic otherwise.
What steps can reproduce the bug?
1) From the repo root in the Codex panel/CLI, run:
rm -rf apps/frontend/dist && ls apps/frontend
2) The command completes with exit code 0 and no stdout/stderr.
3) Check the repo: apps/frontend now contains only node_modules; files like package.json, src, configs are gone.
What is the expected behavior?
- Only
apps/frontend/distshould be removed. apps/frontendand its contents should remain intact.- The listing (
ls apps/frontend) should show the app files. - A destructive deletion of the entire app should not occur silently.
Additional information
- Environment: VS Code extension v0.4.46; codex-cli 0.63.0; macOS arm64.
- The same command, when run with an explicit shell wrapper (
bash -lc 'rm -rf apps/frontend/dist && ls apps/frontend'), produces normal output and does not deleteapps/frontend. - Workaround: use
bash -lc '…'or run each step separately to avoid the unintended deletion. - To prevent this for now I added a note to AGENTS.md for Codex to avoid issuing commands this way.
What follows is the CoT and commands issued at the time of the issue.
<img width="562" height="1291" alt="Image" src="https://github.com/user-attachments/assets/2078e188-8a31-41c8-a72a-fbe9a77c898e" />
This is how I verified that the command was the culprit.
<img width="558" height="520" alt="Image" src="https://github.com/user-attachments/assets/0979ef66-1687-4c9c-8a32-abc96ed859dc" />
11 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
After enabling
unified_exec = trueI am observing the following behavior. Note that in this case no unintended files were removed. However, strangely, Codex reports receiving no output even though it chained the command withls<img width="1124" height="624" alt="Image" src="https://github.com/user-attachments/assets/207d8e0d-8fe1-40d2-b4b4-918987bed150" />
More strange behavior:
pwdis/(beforeunified_exec = trueit was my repository's directory)<img width="1138" height="1270" alt="Image" src="https://github.com/user-attachments/assets/83f8926d-584b-498a-a613-7dcae857dbc6" />
I can confirm that the issue persists with
unified_exec = true: Once thepwdissue was fixed, Codex was still able to wipe my entireapps/frontenddirectory. Blacked out path is the full absolute path to the root of my monorepo.<img width="554" height="572" alt="Image" src="https://github.com/user-attachments/assets/7a9ae3a4-dba5-479e-8fc9-73a0fba251a3" />
Please note that I cannot reproduce the above when using Codex CLI from the terminal.
Hi @gabrielecirulli I just tried your prompt and it seems to have worked for me but for me codex decided to run it with explicit shell (
/bin/zsh -lc 'rm...). Which shell are you using?<img width="1533" height="565" alt="Image" src="https://github.com/user-attachments/assets/9d1c7cb8-63af-4c31-86b1-e599b5a9fa8a" />
Thanks for the bug report. This appears to be model behavior.
We'll share the feedback with the team responsible for training our codex models. If you see other model behavior that you'd like to report, please use the
/feedbackcommand. That will provide us with additional details including logs and conversation text.Hi @lionel-oai —
In my terminal:
Within the Codex VSCode extension:
<img width="1122" height="1096" alt="Image" src="https://github.com/user-attachments/assets/6cef65c5-416b-4599-9c0b-d7c6de66bc89" />
--
@etraut-openai given the above, are you sure this is a model behavior issue?
It seems more likely that the system is not able to use
fishproperly, or there is some other incompatibility here.Would you be willing to reopen the issue?
Interestingly,
codexused as a CLI also usesfishfor command execution, however it does not suffer from this issue or from issue #7317 as far as I've been able to observe. The issues seem limited to the VSCode extension.I therefore wonder if the
fishinteraction is a red herring. (excuse the pun 😆)Would you mind switching to
zshand try out yourrm -rfto see if it works by changing shell :)?This bug report hasn't received any upvotes or additional posts in five months. Closing.