Skip to content

Windows: PowerShell here-string Python literal data falsely blocked as forced deletion #45232

Open

Description

@oguzhanpisgin

What version of the Codex App are you using?

Windows desktop; the executable used by the running app-server reports codex-cli 0.154.0-alpha.6.2. The separately installed CLI reports 0.154.0 and was not the affected execution surface.

What platform is your computer?

Windows with PowerShell 7. The active task uses approval policy never with filesystem sandbox disabled/full access. No local exec-policy rule files were loaded. Observed September 13, 2026 UTC.

What issue are you seeing?

Codex's command tool rejects PowerShell here-string data sent to Python as a forced file deletion. The command only prints two literal words. It contains no PowerShell deletion command, Python file operation, network operation, or URL.

What steps can reproduce the bug?

Submit this exact command through the Windows desktop command-execution tool:

@'
print('Remove-Item', '-Force')
'@ | python -

Observed in the installed runtime: immediate pre-process rejection, approximately 0.3 seconds:

exec_command failed: CreateProcess { message: "Rejected(... rejected: blocked by policy)" }

The tool did not create PowerShell or execute Python. A separate direct literal-output control did execute and returned exit code 0:

Write-Output 'Remove-Item example.txt -Force'

That control also only prints text; it requests no deletion. We did not retry a real destructive command or weaken any policy.

What is the expected behavior?

The Python command should print Remove-Item -Force. Here-string contents and external-program data must not be interpreted as PowerShell command invocations. Preserve the intended protection for actual forced deletions.

Additional information

A read-only parse with PowerShell's own AST of the original diagnostic that led to this minimized example found python as its sole command name and no PowerShell command parameters. That diagnostic was searching local logs; no deletion operation was requested.

The behavior is consistent with the public Windows safety heuristic flattening/tokenizing script text and has_force_delete_cmdlet recognizing deletion words and force flags inside rough segments, without preserving here-string/data boundaries:

This is source correlation, not an assertion that the public commit exactly built the installed executable. The rejection above was observed directly.

Related: #40060 concerns an unrelated URL plus a launch verb. This example contains no URL and no launch verb and exercises the forced-deletion/data boundary instead.

Please provide a parser-aware fix, regression tests covering literal data/here-strings, and a supported fixed release/version. Please expose a stable classifier/reason identifier and triggering span instead of only the generic policy rejection. An allow-all setting or disabled protection is not requested.

Submitted by Codex at the account owner's explicit request. No credentials, private paths, repository content, or raw session logs are included.

Activity

  1. added
    bug
    app
    windows-os
    sandbox
    tool-calls
    on Sep 13, 2026
  2. post1917a commented on Oct 1, 2026

    @post1917a

    Fresh reproduction on 2026-10-01, Windows desktop, with the actual parent command runner reporting codex-cli 0.159.2. Desktop package: OpenAI.Codex 26.928.2636.0. Effective task context: approval_policy=never, sandbox_policy=danger-full-access, permission_profile=disabled.

    I independently reproduced the literal-output example through the desktop exec_command tool. Only the Python executable path below is substituted; the Python statement and PowerShell here-string/pipeline shape are unchanged:

    @'
    print('Remove-Item', '-Force')
    '@ | & 'C:/Tools/Python/python.exe' -X utf8 -I -B -

    Actual result: pre-process rejection ending in CreateProcess ... rejected: blocked by policy. The Python statement only prints two literal words; it performs no file operation, process launch, or network request.

    The independent control:

    Write-Output 'Remove-Item example.txt -Force'

    ran successfully, exit code 0, and printed Remove-Item example.txt -Force.

    This follows an earlier rejection of a larger here-string Python script whose purpose was to write diagnostic findings to a local coordination journal. The deletion words appeared only in diagnostic string data, not in commands submitted for execution. The small printing example above now provides a separately executed reproduction.

    Read-only comparison on 2026-10-01 found identical bytes for windows_dangerous_commands.rs, powershell_parser.ps1, and core/src/exec_policy.rs across the official rust-v0.159.2, rust-v0.159.3, and then-current main. No newer client was installed or runtime-tested in this comparison. In 0.159.2's exec policy, a dangerous match under Never returns Forbidden; the observed error does not itself identify the classifier branch.

    Please preserve the distinction between PowerShell invocations and literal data supplied to another program, and add regression coverage for this non-mutating example. A stable reason and triggering span would also help. No protection setting was changed and no actual deletion was attempted in these probes.

  3. olinkluzz1v commented on Oct 18, 2026

    @olinkluzz1v

    I’m seeing a similar pattern in Codex desktop on Windows with PowerShell. Under Full access (danger-full-access, approval policy never), some commands were rejected before execution with only blocked by policy, without identifying the matching rule.

    We also observed a permissions mismatch: the UI showed Full access, but a resumed turn still used on-request / workspace-write and displayed approval prompts.

    What worked for us:

    1. Stop the current turn.
    2. Select Ask for approval and send a new message directly in that chat.
    3. Approve the exact original command—it then succeeded unchanged.
    4. Stop the turn, select Full access, and send another direct message. The fresh turn then correctly reported Full access.

    Programmatically resuming the chat did not reliably pick up the changed setting in our case.

    This is a workaround, not a confirmed permanent fix. We did not change security policies or disable safeguards. Possible command-parsing false positives remain unconfirmed because the rejection did not expose the matching rule.

  4. soonong commented on Oct 18, 2026

    @soonong

    The same false-positive family also affects a read-only binary/string inspection in the Windows desktop runtime codex-cli 0.163.0-alpha.10.2.

    Installed desktop: app 26.1013.40934, build 20770, prod channel; Windows package 26.1013.4894.0. The official updater reports up_to_date. The affected turn uses approval_policy: never with danger-full-access.

    The observed command was rejected before process creation with blocked by policy. It reads the Codex executable as bytes, searches for diagnostic strings, and lists cache file names. The diagnostic search array includes this literal data:

    @('remove-item','RemoveItem','-recurse','-force','RmForce','DangerousCommandMatch','is_dangerous_command.rs')

    PowerShell's native AST parses the exact recorded command with zero errors. Its only CommandAst names are Get-Command, Get-ChildItem, and Select-Object; the other operations read bytes or inspect strings. There is no deletion invocation. The rejected command was not rerun or disguised through another execution path.

    I compared the recorded input with the public source tag matching the executable version, rust-v0.163.0-alpha.10.2:

    1. The limited PowerShell lowering parser does not support the assignment/foreach/dynamic expressions in this script. The exec-policy fallback therefore retains the original command as Generic.
    2. parse_powershell_invocation applies shlex to the whole script.
    3. has_force_delete_cmdlet splits rough segments/atoms and matches the search-array DATA remove-item and -force together. The later Get-ChildItem -Force is not needed for the match.
    4. Dangerous + Never becomes Forbidden. The Other rejection reason is only blocked by policy.

    A static JavaScript port of the tagged shlex/segment algorithm matches that same array segment. This is exact recorded-input/source correlation, not a newly instrumented or compiled Rust execution trace. Two reviewers independently checked the source chain.

    The newer URL-specific change #54076 / 80b88a7 leaves this forced-deletion predicate and the opaque-script path in place; it does not address this case.

    Please fix command-versus-data provenance for this path and identify the supported fixed desktop/runtime release. Please also return a specific classifier/reason and triggering span instead of the generic message. An allow-all rule or disabled safety check is not requested.

    Suggested regression coverage, not newly executed shell commands:

    • Read-only foreach/search arrays containing deletion words and force flags.
    • The original here-string data example in this issue.
    • A force flag belonging to a separate read-only command.
    • Actual forced deletion, including aliases and nested blocks, remains protected.
    • Dynamic invocation and Invoke-Expression remain conservative: do not solve this by blindly ignoring every quoted string.

    No credentials, private file paths, application data, or raw session logs are included.

  5. dmytro1973 commented on Oct 26, 2026

    @dmytro1973

    Reproduced on 2026-10-26 against the unmodified Rust classifier from rust-v0.163.0-alpha.11.2, commit 51f97c6bca5500edbb986f6d9fe64fa2e63cbdd4.

    The active Windows desktop command runner reports codex-cli 0.163.0-alpha.11.2. Desktop updater metadata reports app 26.1016.62342, build 21477, prod channel. A read-only diagnostic containing deletion words only as literal marker data was rejected with CreateProcess ... Rejected(... blocked by policy).

    I isolated windows_dangerous_commands.rs in a small Rust test crate. The source was unchanged and verified identical after writing it locally. Direct dependencies match that tag's Cargo.lock: once_cell 1.21.4, regex 1.12.3, shlex 1.3.0, url 2.5.8. Toolchain: rustc/cargo 1.93.1.

    Results:

    • All 40 original tests pass.
    • Two added tests checking detection of actual forced-deletion syntax pass.
    • Two added benign regression tests fail, because the classifier returns true.
    • Total: 42 passed, 2 failed.

    The following strings were passed only to is_dangerous_command_windows as synthetic argv data. None were executed by a shell.

    fn detected(script: &str) -> bool {
        let argv = ["pwsh.exe", "-NoProfile", "-Command", script]
            .map(str::to_string);
        is_dangerous_command_windows(&argv)
    }
    
    #[test]
    fn print_only_arguments_must_not_be_a_delete_command() {
        assert!(!detected("Write-Output remove-item -force"));
    }
    
    #[test]
    fn python_marker_data_must_not_be_a_delete_command() {
        let script =
            "@'\nmarkers = ['remove-item', '-force']\nprint(len(markers))\n'@ | python -";
        assert!(!detected(script));
    }
    
    #[test]
    fn actual_delete_syntax_remains_detected() {
        assert!(detected("Remove-Item 'synthetic-target' -Force"));
    }
    
    #[test]
    fn delete_after_literal_data_remains_detected() {
        assert!(detected(
            "@'\nordinary data\n'@ | Write-Output; Remove-Item 'synthetic-target' -Force"
        ));
    }

    The source of has_force_delete_cmdlet remains identical in the tested tag, rust-v0.164.0, and current main. The newer independent-command path still excludes scripts containing a pipe, retaining the opaque-token fallback for this here-string/pipeline example. This newer-version comparison is source inspection only, not a desktop runtime test.

    Please preserve command-versus-data provenance for this path, add regression coverage for the benign examples, and identify a supported fixed desktop release. Actual deletion and dynamic execution should retain their protection.

    No rejected command was replayed, no protection setting was changed, and no private paths, credentials, bank/mail data, or session logs are included.

  6. sawbg commented on Nov 11, 2026

    @sawbg

    Confirmed again on 2026-11-11 in the Windows desktop runtime codex-cli 0.167.0-alpha.3.2. This is a fresh, non-mutating reproduction of #45232, with matching controls and version-pinned source analysis.

    Environment:

    • Installed Windows package: OpenAI.Codex 26.1103.7773.0; primary runtime package 26.1110.778.0.
    • The executable belonging to the running desktop app reports codex-cli 0.167.0-alpha.3.2.
    • Windows x64, version 10.0.26300, build 26300; bundled PowerShell 7.6.9; Python 3.14.7.
    • Effective task settings: approval_policy=never, filesystem sandbox disabled/full access; configured reviewer user.
    • Inspected user command rules: 37 allow rules, no prompt/forbidden rules. No policy settings were changed.

    Executed through functions.exec calling exec_command, this command was rejected before process creation:

    @'
    audit = {'action': 'PowerShell Remove-Item -LiteralPath on exact disposable build directory with -Recurse -Force, following literal path and reparse-point checks'}
    print(audit['action'])
    '@ | python -

    Result: exec_command failed: CreateProcess ... rejected: blocked by policy.

    The otherwise equivalent control succeeded with exit code 0:

    @'
    audit = {'action': 'PowerShell cleanup audit for exact disposable build directory following literal path and reparse-point checks'}
    print(audit['action'])
    '@ | python -

    A separate literal-output control also succeeded:

    'Remove-Item -LiteralPath ''.\work\not-a-target'' -Recurse -Force' | Write-Output

    PowerShell's native Parser.ParseInput reports zero parse errors and only python as a CommandAst name in each here-string example. Python ast.parse finds only a dictionary assignment and a print call. These probes contain no file operation, dynamic evaluation, import, URL, or network request. No fixture was created or deleted.

    The matching published tag resolves to commit c40729ea5cf8e947481b130c59807273eda2f8e9. Its source supports this explanation:

    1. powershell_commands_are_independent excludes scripts containing a pipe; the opaque fallback remains available for here-string pipelines.
    2. parse_powershell_invocation and has_force_delete_cmdlet tokenize/segment script text without preserving this data boundary. A read-only port of the segment check matches the audit string's remove-item and -force atoms together; neither control matches.
    3. The policy fallback forbids a dangerous match under Never and prompts under OnRequest; the formatter gives Windows Other only the generic rejection text.

    This is an observed runtime false positive plus matching-version source correlation. The installed classifier was not instrumented, and the Rust classifier was not rebuilt in this investigation.

    Practical impact: following an authorized temporary-build cleanup rejection, a separate command meant only to write audit receipts was also rejected because its data described the cleanup. Repeating user authorization in chat cannot change the non-interactive policy branch. Official Auto-review documentation says Auto-review has no requests to evaluate under never; this error should not be attributed to a reviewer verdict without evidence.

    Please fix command-versus-data provenance for this fallback while preserving protection for real forced deletion and dynamic execution. Add coverage for these literal-data controls, expose the matched classifier condition and triggering span, and identify the supported fixed runtime release. The rejection should also explain the supported interactive review path when applicable.

    Submitted with AI assistance at the affected user's explicit request. No personal paths, project content, credentials, account/chat identifiers, or raw session logs are included. No protection was disabled, no alternative deletion executor was used, and no rejected deletion was retried during this investigation.

  7. liuzhoucheng commented on Nov 16, 2026

    @liuzhoucheng

    Fresh non-mutating reproduction and a follow-up approval-mode check.

    At the time of the reproduction, desktop updater metadata reported app 26.1106.51428, build 26605 (prod). A separately invoked local binary reported codex-cli 0.167.0-alpha.4.1; this is not asserted to identify every component of the desktop command runner.

    Successful control:

    @'
    print('CODEX_INLINE_DIAGNOSTIC_CONTROL_OK')
    '@ | python -

    A separate command was rejected before process creation:

    @'
    labels = ['Get-ChildItem -Force', 'Remove-Item']
    print('CODEX_LITERAL_LABEL_CONTROL_OK', len(labels))
    '@ | python -

    The rejected Python program only constructs two strings and prints the list length. It has no filesystem access, deletion, network request, or child-process operation. The two programs differ in structure and output, so this is not presented as a strict single-token A/B experiment.

    The complete persisted response ends with CreateProcess ... Rejected(... rejected: blocked by policy) and the command tool displays Wall time 0.0 seconds. Both calls had the same recorded effective context:

    • approval_policy: never
    • approvals_reviewer: user
    • sandbox_policy: danger-full-access
    • permission_profile: disabled

    The rejected request was submitted at 2026-11-15T16:04:34.346Z. No internal exec request ID, matched rule, decision source, or triggering span was exposed. This occurrence should not be attributed to an Auto-review verdict merely because a global default selects Auto-review.

    Follow-up on 2026-11-16: after selecting Ask for approval in this chat and starting a fresh user turn, the recorded effective policy was instead:

    {
      "approval_policy": {
        "granular": {
          "sandbox_approval": false,
          "rules": false,
          "skill_approval": false,
          "request_permissions": true,
          "mcp_elicitations": true
        }
      },
      "approvals_reviewer": "user",
      "sandbox_policy": {
        "type": "workspace-write",
        "network_access": false
      }
    }

    The developer permission block explicitly states that false categories are automatically rejected. Thus the UI selection did not establish a command-rule approval prompt path in this turn. A normal workspace-only Python file read succeeded. The previously rejected sample was not rerun, disguised, or executed through another route after this change.

    Please fix command-versus-data provenance for the literal-data case and expose a stable classifier/reason and triggering span. Please also document a supported desktop review path when rules=false prevents a command approval request from reaching the user, and identify a fixed desktop/runtime release.

    No protection was disabled. This report contains no usernames, private paths, project content, credentials, account/chat IDs, or raw session logs.

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

    appbugsandboxtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions