codex icon indicating copy to clipboard operation
codex copied to clipboard

Windows Defender detects Codex-generated PowerShell command as Trojan:Win32/RegPersis.B!MTB

Open vieworldpl opened this issue 1 day ago • 1 comments

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

OpenAI.CodexPrimaryRuntime 26.1123.915.0 (x64)

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows 11 26H2 x64, Microsoft Surface Laptop Studio (1st Gen), Intel Core i7, 32 GB RAM, NVIDIA RTX A2000.

What issue are you seeing?

On December 3, 2026, while using ChatGPT with the local Codex runtime to work on a website development project, Microsoft Defender detected a Codex-generated PowerShell command as a severe Trojan threat.

The task was legitimate: creating a PowerShell script to recover publicly accessible images and PDF documents from an old WordPress website and the Internet Archive.

The detected command originated from the PowerShell executable bundled with OpenAI.CodexPrimaryRuntime.

Microsoft Defender reported the following:

ThreatName: Trojan:Win32/RegPersis.B!MTB
ThreatID: 2147955909
SeverityID: 5
DidThreatExecute: False
IsActive: False
ActionSuccess: True
ThreatStatusErrorCode: 0
ThreatStatusID: 4
AMProductVersion: 4.18.26100.4
InitialDetectionTime: 2026-12-03 17:06:58 CET
RemediationTime: 2026-12-03 17:07:17 CET

The detected resource was the command line associated with:

C:\Program Files\WindowsApps\OpenAI.CodexPrimaryRuntime.v26-1123-915-0_26.1123.915.0_x64__3k8sg7r9htsxt\dependencies\native\powershell\pwsh.exe

The generated command was intended to create a local PowerShell script and validate its syntax. It was not intended to execute the generated download script at that stage.

This raises concerns regarding the security and reliability of locally executed AI-generated commands, especially when working with professional projects and confidential client files.

Please investigate whether this is a Microsoft Defender false positive, an issue with the Codex PowerShell execution mechanism, or a genuine security problem.

What steps can reproduce the bug?

  1. Use ChatGPT with local Codex runtime access on Windows 11 with Microsoft Defender real-time protection enabled.
  2. Open a local website development project.
  3. Ask the assistant to create a PowerShell script that downloads publicly accessible images and PDF files from an old WordPress website and the Internet Archive.
  4. During the original incident, Codex attempted to create the script using its bundled PowerShell executable and a multiline -Command argument.
  5. Microsoft Defender detected the command as Trojan:Win32/RegPersis.B!MTB and remediated the threat.

The detected command also contained a PowerShell startup workaround referencing PowerShell/PowerShell#27899.

The incident occurred once. I have not deliberately attempted to reproduce the detection or bypass Microsoft Defender.

What is the expected behavior?

Codex should be able to perform legitimate local file creation and authorized development tasks without triggering severe malware detections.

The application should remain fully compatible with Microsoft Defender and other Windows security mechanisms without requiring users to disable antivirus protection, add security exclusions, or weaken their system configuration.

If a generated command is detected as malware, Codex should stop the affected operation, clearly inform the user, and provide appropriate diagnostic information.

I would also expect OpenAI to investigate confirmed antivirus false positives in cooperation with Microsoft.

Additional information

I use ChatGPT professionally for website development, local project management, graphics, and automation involving client files.

The issue is particularly concerning because the detection originated from an official OpenAI runtime installed under WindowsApps, rather than from manually downloaded third-party software.

A static review of the generated command did not reveal obvious registry persistence, credential theft, antivirus tampering, or execution of downloaded binaries. However, this is not sufficient to establish that the detection was a false positive.

Microsoft Defender reported successful remediation, and the threat is currently listed as inactive.

Please clarify:

  • Whether OpenAI is aware of this specific detection.
  • Whether the bundled PowerShell runtime and its command-generation mechanism have been investigated.
  • Whether this detection is a confirmed false positive.
  • Whether OpenAI can provide a permanent resolution that does not require security exclusions.

The complete Defender diagnostic output and detected command can be provided privately if required.

image

vieworldpl avatar Dec 04 '26 10:12 vieworldpl

Defender reports DidThreatExecute: False, so the command was blocked before it ran. A few checks to confirm nothing was left behind, and a way to keep working:

1. See exactly what Defender flagged

Get-MpThreatDetection | Sort-Object InitialDetectionTime -Descending |
  Select-Object -First 1 -ExpandProperty Resources

That prints the full command line it matched, so you can see which part looked like persistence.

2. Check the usual persistence spots (the detection name points to registry persistence):

Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run',
                 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run'

Also glance at Task Scheduler for tasks created on 3 Dec. If both are clean and the command never executed, nothing persisted.

3. If you're confident it's a false positive, report it to Microsoft: https://www.microsoft.com/en-us/wdsi/filesubmission (choose "incorrectly detected"). Include the command line from step 1.

4. Don't add an exclusion for the Codex runtime folder or pwsh.exe. That would also let a genuinely bad generated command through.

5. To keep working: ask Codex to write the script to a .ps1 file with its file-edit tool instead of a long multi-line pwsh -Command string, then check syntax without running it:

$t = $null; $e = $null
[void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path .\script.ps1), [ref]$t, [ref]$e)
$e   # empty = no syntax errors

I haven't confirmed this avoids the detection; it removes the long inline command line, which is what behaviour-based rules tend to inspect.

Disclosure: I keep a free 10-question check that scores what an AI agent on your setup could break and lists the 3 fixes that matter most (runs in your browser): https://aireviewready.in/tools/agent-blast-radius/?s=ghdefender

abhi12337 avatar Dec 04 '26 10:12 abhi12337