GHSA-xmj3-9gf7-h52w setuptools: Windows path escape via namespace_packages.txt during legacy wheel installation Description
- Published
- Updated
- Exploit status
- No public exploit known
Description
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:
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:
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:
__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.
Upgrade path
1 package: 1 fixed.
| Package | Affected | Fixed in | Status |
|---|---|---|---|
| pypi setuptools(PyPI) | = 38.2.3; = 38.2.4; = 38.2.5; = 38.3.0 +319 more | 84.1.0 | Fixed |
Affected products
| Product | Affected versions | Fixed in |
|---|---|---|
| pypi setuptools(PyPI) | >= 38.2.2, < 84.1.0 | 84.1.0 |
| pypi setuptools(PyPI) | = 38.2.3 | No fix listed |
| pypi setuptools(PyPI) | = 38.2.4 | No fix listed |
| pypi setuptools(PyPI) | = 38.2.5 | No fix listed |
| pypi setuptools(PyPI) | = 38.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 38.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 38.4.1 | No fix listed |
| pypi setuptools(PyPI) | = 38.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 38.5.1 | No fix listed |
| pypi setuptools(PyPI) | = 38.5.2 | No fix listed |
| pypi setuptools(PyPI) | = 38.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 38.6.1 | No fix listed |
| pypi setuptools(PyPI) | = 38.7.0 | No fix listed |
| pypi setuptools(PyPI) | = 39.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 39.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 39.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 39.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 40.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.4.1 | No fix listed |
| pypi setuptools(PyPI) | = 40.4.2 | No fix listed |
Show 175 more
| Product | Affected versions | Fixed in |
|---|---|---|
| pypi setuptools(PyPI) | = 40.4.3 | No fix listed |
| pypi setuptools(PyPI) | = 40.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.6.1 | No fix listed |
| pypi setuptools(PyPI) | = 40.6.2 | No fix listed |
| pypi setuptools(PyPI) | = 40.6.3 | No fix listed |
| pypi setuptools(PyPI) | = 40.7.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.7.1 | No fix listed |
| pypi setuptools(PyPI) | = 40.7.2 | No fix listed |
| pypi setuptools(PyPI) | = 40.7.3 | No fix listed |
| pypi setuptools(PyPI) | = 40.8.0 | No fix listed |
| pypi setuptools(PyPI) | = 40.9.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 41.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 41.5.1 | No fix listed |
| pypi setuptools(PyPI) | = 41.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 42.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 42.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 42.0.2 | No fix listed |
| pypi setuptools(PyPI) | = 43.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 44.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 44.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 44.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 45.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 45.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 45.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 45.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 46.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 46.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 46.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 46.1.2 | No fix listed |
| pypi setuptools(PyPI) | = 46.1.3 | No fix listed |
| pypi setuptools(PyPI) | = 46.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 46.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 46.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 46.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 47.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 47.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 47.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 47.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 47.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 47.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 47.3.2 | No fix listed |
| pypi setuptools(PyPI) | = 48.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 49.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 49.1.2 | No fix listed |
| pypi setuptools(PyPI) | = 49.1.3 | No fix listed |
| pypi setuptools(PyPI) | = 49.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.2.1 | No fix listed |
| pypi setuptools(PyPI) | = 49.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 49.3.2 | No fix listed |
| pypi setuptools(PyPI) | = 49.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 49.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 50.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 50.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 50.0.2 | No fix listed |
| pypi setuptools(PyPI) | = 50.0.3 | No fix listed |
| pypi setuptools(PyPI) | = 50.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 50.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 50.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 50.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 50.3.2 | No fix listed |
| pypi setuptools(PyPI) | = 51.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 51.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 51.1.0.post20201221 | No fix listed |
| pypi setuptools(PyPI) | = 51.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 51.1.2 | No fix listed |
| pypi setuptools(PyPI) | = 51.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 51.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 51.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 51.3.2 | No fix listed |
| pypi setuptools(PyPI) | = 51.3.3 | No fix listed |
| pypi setuptools(PyPI) | = 52.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 53.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 53.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 54.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 54.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 54.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 54.1.2 | No fix listed |
| pypi setuptools(PyPI) | = 54.1.3 | No fix listed |
| pypi setuptools(PyPI) | = 54.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 56.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 56.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 56.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 57.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 57.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 57.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 57.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 57.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 57.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 58.0.2 | No fix listed |
| pypi setuptools(PyPI) | = 58.0.3 | No fix listed |
| pypi setuptools(PyPI) | = 58.0.4 | No fix listed |
| pypi setuptools(PyPI) | = 58.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 58.5.1 | No fix listed |
| pypi setuptools(PyPI) | = 58.5.2 | No fix listed |
| pypi setuptools(PyPI) | = 58.5.3 | No fix listed |
| pypi setuptools(PyPI) | = 59.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 59.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 59.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.7.0 | No fix listed |
| pypi setuptools(PyPI) | = 59.8.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.0.1 | No fix listed |
| pypi setuptools(PyPI) | = 60.0.2 | No fix listed |
| pypi setuptools(PyPI) | = 60.0.3 | No fix listed |
| pypi setuptools(PyPI) | = 60.0.4 | No fix listed |
| pypi setuptools(PyPI) | = 60.0.5 | No fix listed |
| pypi setuptools(PyPI) | = 60.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 60.10.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 60.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.7.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.7.1 | No fix listed |
| pypi setuptools(PyPI) | = 60.8.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.8.1 | No fix listed |
| pypi setuptools(PyPI) | = 60.8.2 | No fix listed |
| pypi setuptools(PyPI) | = 60.9.0 | No fix listed |
| pypi setuptools(PyPI) | = 60.9.1 | No fix listed |
| pypi setuptools(PyPI) | = 60.9.2 | No fix listed |
| pypi setuptools(PyPI) | = 60.9.3 | No fix listed |
| pypi setuptools(PyPI) | = 61.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 61.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 61.1.1 | No fix listed |
| pypi setuptools(PyPI) | = 61.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 61.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 61.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 62.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 62.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 62.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 62.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 62.3.1 | No fix listed |
| pypi setuptools(PyPI) | = 62.3.2 | No fix listed |
| pypi setuptools(PyPI) | = 62.3.3 | No fix listed |
| pypi setuptools(PyPI) | = 62.3.4 | No fix listed |
| pypi setuptools(PyPI) | = 62.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 62.5.0 | No fix listed |
| pypi setuptools(PyPI) | = 62.6.0 | No fix listed |
| pypi setuptools(PyPI) | = 63.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 63.0.0b1 | No fix listed |
| pypi setuptools(PyPI) | = 63.1.0 | No fix listed |
| pypi setuptools(PyPI) | = 63.2.0 | No fix listed |
| pypi setuptools(PyPI) | = 63.3.0 | No fix listed |
| pypi setuptools(PyPI) | = 63.4.0 | No fix listed |
| pypi setuptools(PyPI) | = 63.4.1 | No fix listed |
| pypi setuptools(PyPI) | = 63.4.2 | No fix listed |
| pypi setuptools(PyPI) | = 63.4.3 | No fix listed |
| pypi setuptools(PyPI) | = 64.0.0 | No fix listed |
| pypi setuptools(PyPI) | = 64.0.1 | No fix listed |
References
- github.com vendor-advisory
- github.com patch
- github.com patch
- github.com product
- github.com
- github.com