# CVE-2025-40909: Perl threads have a working directory race condition where file operations may target unintended paths

> A local attacker can exploit a race condition in Perl threads to execute code or read files from unintended paths.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 30 May 2025
- **Updated:** 18 Apr 2026
- **Also known as:** ALSA-2025:11805, ALSA-2026:8096, AZL-62067, AZL-62069, BELL-CVE-2025-40909, CLSA-2025-1755270634, CLSA-2025-1755270847, CLSA-2025-1755513271, DEBIAN-CVE-2025-40909, ECHO-5693-3efb-b660, GHSA-jpf5-526x-c5hw, MINI-459h-j68x-8hp4, MINI-f2gm-5xq6-49fx, MINI-wwfx-85jf-frcx, OESA-2025-1631, RHSA-2025:11545, RHSA-2025:11804, RHSA-2025:11805, RHSA-2025:12056, RHSA-2026:37070, RHSA-2026:8096, RLSA-2025:11804, RLSA-2025:11805, RLSA-2025:12056, RLSA-2026:8096, ROOT-OS-DEBIAN-11-CVE-2025-40909, SUSE-SU-2025:02027-1, SUSE-SU-2025:02051-1, SUSE-SU-2025:20456-1, UBUNTU-CVE-2025-40909, USN-7678-1, openSUSE-SU-2025:15258-1

## What is CVE-2025-40909?

CVE-2025-40909 is a medium-severity vulnerability in perl, published on 30 May 2025. It can only be exploited from the same machine or local network, with no action from the victim.

### Official 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

Weakness: CWE-689 (Permission Race Condition During Resource Copy), CWE-426 (Untrusted Search Path)

## Which versions are affected by CVE-2025-40909?


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `perl` | AlmaLinux:8 | All versions | 4:5.26.3-423.el8_10 |
| `perl` | AlmaLinux:8 | All versions | 4:5.32.1-474.module_el8.10.0+4162+0aac7c4c |
| `perl-Algorithm-Diff` | AlmaLinux:8 | All versions | 1.1903-10.module_el8.6.0+2766+8bf0b7ce |
| `perl-Archive-Tar` | AlmaLinux:8 | All versions | 2.38-3.module_el8.6.0+2766+8bf0b7ce |
| `perl-Archive-Zip` | AlmaLinux:8 | All versions | 1.68-3.module_el8.6.0+2766+8bf0b7ce |
| `perl-Attribute-Handlers` | AlmaLinux:8 | All versions | 0.99-423.el8_10 |
| `perl-Attribute-Handlers` | AlmaLinux:8 | All versions | 1.01-474.module_el8.10.0+4162+0aac7c4c |
| `perl-AutoLoader` | AlmaLinux:8 | All versions | 5.74-474.module_el8.10.0+4162+0aac7c4c |
| `perl-AutoSplit` | AlmaLinux:8 | All versions | 5.74-474.module_el8.10.0+4162+0aac7c4c |
| `perl-B` | AlmaLinux:8 | All versions | 1.80-474.module_el8.10.0+4162+0aac7c4c |
| `perl-Benchmark` | AlmaLinux:8 | All versions | 1.23-474.module_el8.10.0+4162+0aac7c4c |
| `perl-CPAN` | AlmaLinux:8 | All versions | 2.28-5.module_el8.6.0+2766+8bf0b7ce |
| `perl-CPAN-DistnameInfo` | AlmaLinux:8 | All versions | 0.12-13.module_el8.6.0+2766+8bf0b7ce |
| `perl-CPAN-Meta` | AlmaLinux:8 | All versions | 2.150010-397.module_el8.6.0+2766+8bf0b7ce |
| `perl-CPAN-Meta-Requirements` | AlmaLinux:8 | All versions | 2.140-397.module_el8.6.0+2766+8bf0b7ce |
| `perl-CPAN-Meta-YAML` | AlmaLinux:8 | All versions | 0.018-1001.module_el8.6.0+2766+8bf0b7ce |
| `perl-Carp` | AlmaLinux:8 | All versions | 1.50-439.module_el8.6.0+2766+8bf0b7ce |
| `perl-Class-Struct` | AlmaLinux:8 | All versions | 0.66-474.module_el8.10.0+4162+0aac7c4c |
| `perl-Compress-Bzip2` | AlmaLinux:8 | All versions | 2.28-2.module_el8.6.0+2766+8bf0b7ce |
| `perl-Compress-Bzip2` | AlmaLinux:8 | All versions | 2.28-2.module_el8.6.0+3181+91434291 |
| `perl-Compress-Raw-Bzip2` | AlmaLinux:8 | All versions | 2.096-1.module_el8.6.0+2766+8bf0b7ce |
| `perl-Compress-Raw-Bzip2` | AlmaLinux:8 | All versions | 2.096-1.module_el8.6.0+3181+91434291 |
| `perl-Compress-Raw-Lzma` | AlmaLinux:8 | All versions | 2.096-1.module_el8.6.0+2766+8bf0b7ce |
| `perl-Compress-Raw-Lzma` | AlmaLinux:8 | All versions | 2.096-1.module_el8.6.0+3181+91434291 |
| `perl-Compress-Raw-Zlib` | AlmaLinux:8 | All versions | 2.096-2.module_el8.10.0+3779+d5938d28 |
| `perl-Config-Extensions` | AlmaLinux:8 | All versions | 0.03-474.module_el8.10.0+4162+0aac7c4c |
| `perl-Config-Perl-V` | AlmaLinux:8 | All versions | 0.32-441.module_el8.6.0+2766+8bf0b7ce |
| `perl-DBM_Filter` | AlmaLinux:8 | All versions | 0.06-474.module_el8.10.0+4162+0aac7c4c |
| `perl-DB_File` | AlmaLinux:8 | All versions | 1.855-1.module_el8.6.0+2766+8bf0b7ce |
| `perl-DB_File` | AlmaLinux:8 | All versions | 1.855-1.module_el8.6.0+3181+91434291 |
| `perl-Data-Dumper` | AlmaLinux:8 | All versions | 2.174-440.module_el8.6.0+2766+8bf0b7ce |
| `perl-Data-Dumper` | AlmaLinux:8 | All versions | 2.174-440.module_el8.6.0+3181+91434291 |
| `perl-Data-OptList` | AlmaLinux:8 | All versions | 0.110-7.module_el8.6.0+2766+8bf0b7ce |
| `perl-Data-Section` | AlmaLinux:8 | All versions | 0.200007-8.module_el8.6.0+2766+8bf0b7ce |
| `perl-Devel-PPPort` | AlmaLinux:8 | All versions | 3.62-1.module_el8.6.0+2766+8bf0b7ce |
| `perl-Devel-PPPort` | AlmaLinux:8 | All versions | 3.62-1.module_el8.6.0+3181+91434291 |
| `perl-Devel-Peek` | AlmaLinux:8 | All versions | 1.26-423.el8_10 |
| `perl-Devel-Peek` | AlmaLinux:8 | All versions | 1.28-474.module_el8.10.0+4162+0aac7c4c |
| `perl-Devel-SelfStubber` | AlmaLinux:8 | All versions | 1.06-423.el8_10 |
| `perl-Devel-SelfStubber` | AlmaLinux:8 | All versions | 1.06-474.module_el8.10.0+4162+0aac7c4c |

## How do I fix CVE-2025-40909?

Apply the vendor's patch.

## Is CVE-2025-40909 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-40909 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-40909 and fix it if it is affected.

What it is: CVE-2025-40909 is a medium-severity vulnerability in perl, published on 30 May 2025. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-40909 exists.

Affected product: perl. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-40909/ (Markdown: https://insights.sbomify.com/CVE-2025-40909/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-40909
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-40909
- OSV: https://osv.dev/vulnerability/CVE-2025-40909

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-40909/
Summaries are generated and may contain mistakes; the official description above is the record.
