CVE-2025-40909

Perl threads have a working directory race condition where file operations may target unintended paths

Published May 30, 2025 CVSS 3.1 · 5.9 Medium EPSS < 1% KEV · Not listed
Description
Perl threads have a working directory race condition where file operations may target unintended paths.

If a directory handle is open at thread creation, the process-wide current working directory is temporarily changed in order to clone that handle for the new thread, which is visible from any third (or more) thread already running.

This may lead to unintended operations such as loading code or accessing files from unexpected locations, which a local attacker may be able to exploit.

The bug was introduced in commit 11a11ecf4bea72b17d250cfb43c897be1341861e and released in Perl version 5.13.6

Analysis

AI-generated

Technical impact

A race condition exists during thread creation when a directory handle is open. The process-wide current working directory is temporarily altered to clone that handle for the new thread, an effect that is visible to any other threads already running. This flaw can cause file operations—such as loading code or reading data—to target unintended paths. The weakness is identified by CWE-362 (Race Condition), CWE-426 (Insecure Direct Object Reference), and CWE-689 (Improper Handling of Working Directory). The result is a localized attack surface that may allow a local adversary to execute arbitrary code or read/write files that should not be accessible.

Affected Systems

The vulnerability affects the Perl interpreter provided by the https://perl.org organization, specifically the 5.13.6 release. Versions that incorporate the referenced patch or any later revision that eliminates the race condition are considered unaffected. No other vendors or product lines are listed as impacted.

Risk and Exploitability

The CVSS score of 5.9 indicates moderate severity, and the EPSS score of less than 1% reflects a very low exploitation probability. The vulnerability is not listed in the CISA KEV catalog. Likely attack vectors involve a local attacker who can spawn threads within the same process; they would need to coordinate timing to exploit the directory change. Because the flaw requires a concurrent thread and the resulting privilege is limited to the running process, the risk is medium but still significant for components handling sensitive file paths.

Remediation

Vendor Solution

Update perl to an unaffected version, or apply the patch provided in the references section.


OpenCVE Recommended Actions

  • Upgrade Perl to a release that incorporates the fix for 5.13.6; refer to vendor advisories for the safe version
  • If upgrading is not immediately possible, apply the specific patch provided in the vendor references to patch the race condition
  • For applications that cannot be patched, restructure code so that no directory handles are opened before threads are created or set the working directory explicitly for each thread, thereby preventing unintended path resolution

Generated by OpenCVE AI on April 20, 2026 at 15:33 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4538-1 perl security update
EUVD EUVD EUVD-2025-16506 Perl threads have a working directory race condition where file operations may target unintended paths. If a directory handle is open at thread creation, the process-wide current working directory is temporarily changed in order to clone that handle for the new thread, which is visible from any third (or more) thread already running. This may lead to unintended operations such as loading code or accessing files from unexpected locations, which a local attacker may be able to exploit. The bug was introduced in commit 11a11ecf4bea72b17d250cfb43c897be1341861e and released in Perl version 5.13.6
Ubuntu USN Ubuntu USN USN-7678-1 Perl vulnerability
History
Type Values Removed Values Added
Weaknesses CWE-689
Type Values Removed Values Added
Metrics epss

{'score': 0.00017}

epss

{'score': 6e-05}

Type Values Removed Values Added
Metrics cvssV3_1

{'score': 5.9, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L'}

ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description Perl threads have a working directory race condition where file operations may target unintended paths. If a directory handle is open at thread creation, the process-wide current working directory is temporarily changed in order to clone that handle for the new thread, which is visible from any third (or more) thread already running. This may lead to unintended operations such as loading code or accessing files from unexpected locations, which a local attacker may be able to exploit. The bug was introduced in commit 11a11ecf4bea72b17d250cfb43c897be1341861e and released in Perl version 5.13.6
Title Perl threads have a working directory race condition where file operations may target unintended paths
Weaknesses CWE-362
CWE-426
References
Weaknesses
  • CWE-362

    Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

  • CWE-426

    Untrusted Search Path

  • CWE-689

    Permission Race Condition During Resource Copy

Sources

Status
PUBLISHED
Assigner
CPANSec
Published
Updated
Apr 18, 2026, 2:15 PM
Reserved
Apr 16, 2025, 9:05 AM
Status
Deferred
Published
May 30, 2025, 1:15 PM
Modified
Jun 17, 2026, 9:22 AM
Severity
Moderate
Public date
May 30, 2025, 12:20 PM