---
schema_version: '1.0'
id: security-20261024-b057c2
title: 'GHSA-xmj3-9gf7-h52w: setuptools: Windows path escape via namespace_packages.txt
  during legacy wheel installation  Description'
url: https://osv.dev/vulnerability/GHSA-xmj3-9gf7-h52w
url_hash: b057c29dcd5199b94518ee4eb05f9e51745f18b5b92f5d03aadbc4e80bae719b
canonical_url: https://osv.dev/vulnerability/GHSA-xmj3-9gf7-h52w
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- GHSA-xmj3-9gf7-h52w
- severity:CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:A/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N
- setuptools
- PyPI
lang: en
published_at: '2026-10-23T21:44:11Z'
fetched_at: '2026-10-24T12:01:09.015098Z'
updated_at: '2026-10-26T12:10:37.406775Z'
status: published
content_hash: 03f5bc7cb7e2be7878e2d92909ebe84b3458c0ed7aadedb6fec1d7bc2ffa2f3d
content_changed_at: null
license_note: full
summary: 'setuptools: Windows path escape via namespace_packages.txt during legacy
  wheel installation  Description'
summary_source: rss
summary_en: 'setuptools: Windows path escape via namespace_packages.txt during legacy
  wheel installation  Description'
summary_omitted_reason: null
redistribution: true
keywords_en:
- cve
- Description
- during
- escape
- GHSA-xmj3-9gf7-h52w
- installation
- legacy
- library vulnerability
- namespace_packages.txt
- Olivia Smith
- path
- Patturaja Murugaboopathy
- PyPI
- setuptools
- severity:CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:A/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N
- Shay McVeigh
- software security
- via
- wheel
- Windows
entities_en:
- name: Olivia Smith
  type: person
- name: Patturaja Murugaboopathy
  type: person
- name: Shay McVeigh
  type: person
- name: Windows
  type: product
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: Shay McVeigh
  type: person
- name: Windows
  type: product
- name: Patturaja Murugaboopathy
  type: person
- name: Olivia Smith
  type: person
key_facts: []
related: []
related_auto:
- name: Bristol Crown Court
  type: organization
  weight: 1.0
- name: Bristol Magistrates Court
  type: organization
  weight: 1.0
computed_at: '2026-10-24T12:35:20Z'
---

# GHSA-xmj3-9gf7-h52w: setuptools: Windows path escape via namespace_packages.txt during legacy wheel installation  Description

## TL;DR
setuptools: Windows path escape via namespace_packages.txt during legacy wheel installation  Description

## Key Points
- cve / GHSA-xmj3-9gf7-h52w / severity:CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:A/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N / setuptools / PyPI

## Details
**Severity:** CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:A/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N
**Advisory:** GHSA-xmj3-9gf7-h52w

**Details:**
### Summary

On Windows, attacker-controlled content in a wheel's
`.dist-info/namespace_packages.txt` can cause setuptools' legacy wheel
installation path to create an `__init__.py` outside the requested
`destination_eggdir`.

The attacker can influence the destination path, but not the contents of
the created file.

### Details

Tested setuptools commit:

`6ead555c5fb29bc57fe6105b1bffc163f56fd558`

Relevant source:

`setuptools/wheel.py`

SHA-256:

`359b7e0d5dd8c3135653abe08a8ed5dc0352eadfd7df22cb5e2b5303b7c3cafd`

The relevant call path is:

`Wheel(wheel_path).install_as_egg(destination)`
→ `_install_as_egg`
→ `_convert_metadata`
→ `_fix_namespace_packages`

A wheel can provide attacker-controlled content in:

`<distribution>.dist-info/namespace_packages.txt`

The namespace value is eventually used approximately as:

```python
mod_dir = os.path.join(destination_eggdir, *mod.split('.'))
mod_init = os.path.join(mod_dir, '__init__.py')

If mod is a Windows drive-qualified absolute path containing no dots,
mod.split('.') preserves it as a single component.
On Windows, os.path.join(destination_eggdir, absolute_component) discards
the original base directory and resolves to the attacker-supplied absolute
path.
The existing wheel filename and ZIP traversal checks do not validate this
metadata value before it is subsequently interpreted as a filesystem path.

```markdown
### PoC

The reproduction was performed entirely inside a disposable temporary
directory.

Layout:

```text
sandbox/
    destination/
    outside/
    input/
    canary.txt
```

A synthetic wheel was created containing:

`demo_pkg-1.0.dist-info/namespace_packages.txt`

whose content was the absolute path of:

`sandbox\outside`

The real acquired setuptools implementation was then invoked:

```python
setuptools.wheel.Wheel(synthetic_wheel).install_as_egg(
    sandbox_destination
)
```

The operation completed without exception.

Expected metadata was created under:

`sandbox\destination\EGG-INFO`

but setuptools also created:

`sandbox\outside\__init__.py`

The file did not exist before execution.

Its contents were:

```python
__import__('pkg_resources').declare_namespace(__name__)
```

The unrelated canary remained byte-identical.

The sandbox was deleted after recording the evidence.
```


### Impact

A crafted wheel can cause setuptools to create a fixed-content
`__init__.py` outside the intended installation directory at a
filesystem path influenced by the wheel, with the permissions of the
process performing the installation.

The demonstrated reproduction required the target parent directory to
already exist.

**References:**
- https://github.com/pypa/setuptools/security/advisories/GHSA-xmj3-9gf7-h52w
- https://github.com/pypa/setuptools/pull/5329
- https://github.com/pypa/setuptools/commit/6d07b8d17890dda58d944ac51e58f54af92d52af
- https://github.com/pypa/setuptools
- https://github.com/pypa/setuptools/releases/tag/v84.1.0

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-xmj3-9gf7-h52w_

## Source
元記事: [GHSA-xmj3-9gf7-h52w: setuptools: Windows path escape via namespace_packages.txt during legacy wheel installation  Description](https://osv.dev/vulnerability/GHSA-xmj3-9gf7-h52w) — published 2026-10-23T21:44:11Z
