Overview
A significant security vulnerability, CVE-2023-47039, has been discovered in the Windows implementation of Perl, a widely-used general-purpose scripting language. This vulnerability poses a severe threat to both individual users and organizations that leverage Perl on Windows systems. The issue arises from the way Perl on Windows attempts to find and execute the shell, `cmd.exe`, with a preference for the current working directory. This behavior can lead to the execution of malicious code, potentially compromising the entire system or leaking sensitive data.
Vulnerability Summary
CVE ID: CVE-2023-47039
Severity: High (7.8 CVSS Score)
Attack Vector: Local
Privileges Required: Low
User Interaction: Required
Impact: Potential system compromise or data leakage
Affected Products
No phone number, email, or personal info required.
Product | Affected Versions
Perl on Windows | All versions prior to the latest patch
How the Exploit Works
The exploit works by taking advantage of Perl’s default behavior on Windows systems. When running an executable that uses the Perl interpreter, Perl attempts to find and execute `cmd.exe` within the operating system. However, instead of looking for `cmd.exe` in its typical location, Perl first looks in the current working directory. This behavior allows an attacker to place a malicious `cmd.exe` in a directory with weak permissions, such as `C:\ProgramData`. When an administrator attempts to use the executable from this compromised location, the malicious code is executed instead.
Conceptual Example Code
Keeping in mind that this is a local attack vector and requires some level of user interaction, an example of how this vulnerability might be exploited is as follows:
REM Create a malicious cmd.exe in a directory with weak permissions
copy C:\path\to\malicious\cmd.exe C:\ProgramData\
REM Run a Perl script that will unknowingly use the malicious cmd.exe
perl C:\path\to\perl\script.pl
The Perl interpreter will attempt to find `cmd.exe` to execute the script, and due to the path search order issue, it will find and execute the malicious `cmd.exe` in `C:\ProgramData\` before it finds the legitimate version. This can lead to arbitrary code execution, potentially compromising the system or leading to data leakage.
To mitigate this vulnerability, apply the latest vendor patch or use a Web Application Firewall (WAF) or Intrusion Detection System (IDS) as temporary mitigation. However, the most effective solution is to update the affected systems with the latest patches from the Perl project.