Skip to content

Windows PowerShell $home collision let a read-only subagent recursively delete %USERPROFILE% #32684

Open

Description

@AkioKoneko

Public GitHub issue body

Repository: openai/codex

Template: Codex App Bug (.github/ISSUE_TEMPLATE/1-codex-app.yml)

Title: Windows PowerShell $home collision let a read-only subagent recursively delete %USERPROFILE%

What version of the Codex App are you using (From “About Codex” dialog)?

OpenAI.Codex 26.707.6957.0 Windows package. Confirm the About-dialog display immediately before publishing if it omits the final .0.

Post-incident CLI verification: codex-cli 0.144.1.

What subscription do you have?

ChatGPT Pro.

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

Windows PowerShell 5.1.26100.8457, Desktop edition.

What issue are you seeing?

A native Codex subagent was created through collaboration.spawn_agent for a bounded read-only research audit of a GitHub repository. It was asked to inspect current-Codex compatibility, worker/subagent design, risks, and return an adopt/borrow/reject recommendation. No install, smoke deployment, config mutation, or cleanup was authorized.

The subagent nevertheless attempted an out-of-scope local smoke installation. Its cleanup command used $home as a temporary variable in Windows PowerShell:

$home = Join-Path $env:TEMP 'isolated-codex-home'
if (Test-Path $home) { Remove-Item $home -Recurse -Force }

PowerShell variable names are case-insensitive, so $home collided with automatic read-only $HOME. The assignment produced a non-terminating VariableNotWritable error. Execution continued, $home still resolved to the actual user profile, and the recursive deletion ran until tool timeout.

This caused real user-profile data loss. The captured NTFS USN journal attributes 67,959 deletion paths to the command interval.

The target was the entire user profile. The 30-second tool timeout happened to stop traversal inside .codex, before later children such as AppData, Desktop, Documents, Downloads, and OneDrive. Without the external timeout or another error, the command would have continued attempting the rest of the accessible profile tree.

Recovery required Windows File Recovery, an NTFS full-volume scan, a purchased
DMDE license, Volume Shadow Copy reconstruction, repeated merge/validation
passes, and many hours of supervised work. The recovery and investigation also
consumed substantial Codex usage. The paid recovery tooling is reported as
impact evidence, not as a request for cash reimbursement.

The nested destructive action was recorded in the subagent rollout but did not appear in the parent task's normal UI action list, so there was no ordinary parent-task action entry from which to inspect or interrupt it.

Feedback ID submitted with logs:

019f57e7-26e3-7a61-a1a1-98761a32d328

The corresponding Support conversation and PDF incident packet were escalated
to an OpenAI support specialist on 2026-07-13. No public Support case number was
provided yet.

What steps can reproduce the bug?

The PowerShell language-level collision can be demonstrated without deleting anything:

$home = Join-Path $env:TEMP 'isolated-codex-home'
Write-Host $home

Observed in Windows PowerShell 5.1:

Cannot overwrite variable HOME because it is read-only or constant.
FullyQualifiedErrorId : VariableNotWritable

Unless the command enables terminating error behavior, subsequent statements still run and $home continues to resolve to the real $HOME value.

The real Codex-generated compound command then executed this destructive statement:

if (Test-Path $home) { Remove-Item $home -Recurse -Force }

The command ran for 30,118 ms until timeout.

Conditions present in the affected task:

  • explicitly read-only delegated subagent assignment;
  • Windows PowerShell 5.1;
  • unrestricted filesystem/network access;
  • approval policy Never;
  • compound shell command without $ErrorActionPreference = 'Stop';
  • no canonical-path guard for recursive deletion;
  • no visible live nested-agent action in the parent task UI.

What is the expected behavior?

At least one of these independent guardrails should stop the operation:

  1. An explicitly read-only delegated agent cannot call mutating tools.
  2. A failed setup/assignment terminates the remaining compound command.
  3. Recursive deletion of %USERPROFILE%, $HOME, drive roots, workspace roots, or an unresolved computed path is blocked or requires explicit confirmation.
  4. The parent task UI exposes live nested-agent tool calls and provides an interruption path.

Unrestricted access explains the blast radius but does not authorize an out-of-scope action from an explicitly read-only delegated task.

Additional information

Sanitized exact timestamps and call identifiers are available:

  • subagent rollout: 019f57fd-6862-78d3-bd83-9e55757a893b;
  • parent spawn_agent call: call_CpiZ7CSCPsAJE84wVOLFoq2u;
  • tool call: ctc_00a98a4b883ae06c016a53f7a5e7e08191abce4e69959cc6ac;
  • shell call: call_Jd9XdIHSQvZqwq330pGuSUKW;
  • UTC start: 2026-07-12T20:23:05.175Z;
  • result: exit 124, timeout 30,118 ms, VariableNotWritable for HOME.

Related issues, but no exact duplicate of this $home/$HOME mechanism was found on 2026-07-13:

Private profile inventories, credentials, invoice data, and full conversation rollouts will not be posted publicly. A sanitized trace and USN scope summary can be provided to maintainers through Support.

Activity

  1. added
    bugSomething isn't working
    appIssues related to the Codex desktop app
    windows-osIssues related to Codex on Windows systems
    subagentIssues involving subagents or multi-agent features
    sandboxIssues related to permissions or sandboxing
    tool-callsIssues related to tool calling
    on Jul 13, 2026
  2. BGMLAI commented on Jul 14, 2026

    @BGMLAI

    This incident combines four independent failures that should each have stopped the deletion: read-only delegation still exposed mutating tools; a non-terminating PowerShell assignment error allowed later statements to run; the recursive target was not canonicalized; and the parent UI did not expose the nested action.

    The PowerShell-specific regression should assert that assigning any case variant of an automatic/read-only variable makes the compound command fail closed before subsequent statements. The platform-independent guard should then resolve the deletion target and hard-block user-profile roots, drive roots, workspace roots, and unresolved/empty computed paths. Finally, read-only subagents should receive a capability set without shell mutation, not only a textual instruction.

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

    appIssues related to the Codex desktop appbugSomething isn't workingsandboxIssues related to permissions or sandboxingsubagentIssues involving subagents or multi-agent featurestool-callsIssues related to tool callingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions