← Index berkoc · research
High published

conda/conda: entry-point path traversal in noarch:python install (arbitrary file write)

parse_entry_point_def in conda only strips the command field. A malicious noarch:python package writes an executable Python wrapper outside the install prefix, or clobbers an in-prefix entry point such as bin/pip. This is the canonical Python implementation of the same primitive reported in conda/rattler.

Vendor
conda/conda · pypi
CVE
CVE-2026-53940
GHSA
GHSA-9m8m-c4j3-rj2c
CWE
CWE-22
CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H (8.8)
Disclosed

Background

conda/conda is the reference Python implementation of the conda package manager, maintained by the conda organisation under Anaconda Inc. and the community. It is the install engine behind conda install, conda env create, conda env update, the Python frontends of mamba in mixed configurations, conda build's in-process install, and the Anaconda / Miniconda / Mambaforge distributions. It is the upstream that conda/rattler (Rust) and mamba-org/mamba (C++ libmamba) reimplement.

A noarch:python package declares console-script entry points in info/link.json. During a transaction, conda turns each entry point into an executable Python wrapper script under the prefix's bin/ (Unix) or Scripts/ (Windows). The name of that wrapper is taken from the package metadata. It is never validated against path traversal.

This advisory is the canonical Python instance of the class already documented in the conda/rattler case study: an auto-generated console-script wrapper whose name field is derived from a package-metadata string and joined onto the install prefix without a containment check. rattler is the Rust reimplementation and inherits the same wire format and the same gap. The conda details below are sourced from the same audit and were independently re-traced against the pinned conda source.

The parser

parse_entry_point_def in conda/common/path/python.py is the only parser in the chain. It splits on : and = and strips whitespace:

def parse_entry_point_def(ep_definition):
    cmd_mod, func = ep_definition.rsplit(":", 1)
    command, module = cmd_mod.rsplit("=", 1)
    command, module, func = command.strip(), module.strip(), func.strip()
    return command, module, func

command.strip() is the entire defence. There is no rejection of /, \, \0, embedded newlines, .., a leading ., or an absolute path. The attacker-controlled string reaches this parser through read_package_metadata in conda/gateways/disk/read.py, which is a bare json.loads followed by PackageMetadata(**data) with no field-shape validation beyond package_metadata_version. The schema field is Noarch.entry_points = ListField(str, ...) in conda/models/package_info.py, which only requires each element to be a string.

The linker

CreatePythonEntryPointAction.create_actions in conda/core/path_actions.py f-string-interpolates command into a path:

def this_triplet(entry_point_def):
    command, module, func = parse_entry_point_def(entry_point_def)
    target_short_path = f"{BIN_DIRECTORY}/{command}"
    if on_win:
        target_short_path += "-script.py"
    return target_short_path, module, func

The full path is built by PrefixPathAction.target_full_path, which is a plain join(target_prefix, win_path_ok(target_short_path)). win_path_ok is the identity function on non-Windows. Python's os.path.join keeps .. components literal (the kernel resolves them at open() time) and discards the left side entirely when the right side is absolute, matching Rust's Path::join semantics in the rattler sibling.

The per-action verify() is the no-op base-class method on CreateInPrefixPathAction:

def verify(self):
    self._verified = True

There is no canonicalisation and no starts_with(target_prefix) check anywhere on this action class. execute() calls create_python_entry_point in conda/gateways/disk/create.py, which opens target_full_path for write, renders the entry-point template into it, and on Unix calls make_executable (sets S_IXUSR | S_IXGRP | S_IXOTH). The only safety check is lexists(target_full_path), which raises BasicClobberError only when the target already exists, and even then maybe_raise downgrades it to a warning under the documented --clobber workflow that conda users routinely invoke to recover from partial installs. For a fresh out-of-prefix write the existence check never fires.

Reproducer

The cleanest pivot is clobbering an existing in-prefix entry point. info/link.json:

{
  "package_metadata_version": 1,
  "noarch": {
    "type": "python",
    "entry_points": [
      "../bin/pip = innocuous_pkg.evil:main"
    ]
  }
}

After parse_entry_point_def, command = "../bin/pip". The linker computes target_short_path = "bin/../bin/pip" and target_full_path = <prefix>/bin/../bin/pip, which the kernel resolves to <prefix>/bin/pip at open() time. The existing pip is overwritten with the rendered template at the world-executable mode. On the victim's next pip install, attacker Python runs in the prefix with the user's environment. The same pivot works against any existing wrapper the developer invokes after install: pytest, pre-commit, aws, dvc, jupyter, mypy.

Two further variants follow from the same primitive. An out-of-prefix write lands wherever the parent directory already exists. create_python_entry_point does not os.makedirs the parent, so the target's parent must exist naturally on the victim box (~/.config/jupyter/ where Jupyter has run, ~/.ipython/profile_default/startup/, a home dotfile to clobber):

{ "entry_points": ["../../../.config/jupyter/jupyter_notebook_config.py = innocuous_pkg.evil:main"] }

And because os.path.join discards the left side on an absolute right side, an absolute path writes anywhere the process can:

{ "entry_points": ["/tmp/PWN = innocuous_pkg.evil:main"] }

The Windows path doubles the primitive: it writes both Scripts/<command>-script.py and a launcher Scripts/<command>.exe, so the same traversal drops an executable into the user's StartUp folder.

The analysis is static. I did not assemble a .conda and run it through conda. The chain was re-traced at the pinned commit b874ca9, the os.path.join semantics were confirmed against the documented behaviour, and the same primitive in the sibling pip + vendored-distlib case has a live end-to-end PoC. An independent reviewer re-read every cited file:line at the same commit and confirmed the trace.

Impact

Arbitrary file write with attacker-controlled, executable Python content during the default install flow of any conda or mamba transaction that resolves a malicious noarch:python package. No flag, prompt, or post-link-script opt-in is involved; entry-point creation is part of the linker pipeline, so defences aimed at post-link scripts do not cover it.

This is realistic supply-chain RCE the moment the dropped wrapper is invoked. conda-forge carries roughly 32 000 noarch:python packages with hundreds of new uploads per day. The attacker model is any author of a package the victim resolves: a compromised conda-forge maintainer account (the same threat model as CVE-2025-31484), a typosquat on defaults, or an insider on a private corporate channel. CI runners building Docker images (RUN conda install ... in continuumio/miniconda3, mambaorg/micromamba, quay.io/condaforge/mambaforge) frequently execute as root, magnifying blast radius from a single laptop to every container pulled from a poisoned image.

CVSS 3.1 AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H = 8.8 High, in the same band as the rattler sibling (CVE-2026-47425, scored 8.5 under a conservative local vector); the network attack vector here reflects that the malicious package is fetched over the network during the install command. A scope-changed argument (S:C) is defensible for out-of-prefix writes into the user's home directory and would push the score toward Critical; the conservative scope-unchanged number is used here because the practical pivot, the in-prefix bin/pip clobber, is scope-unchanged.

The fix

Validate command after .strip() in parse_entry_point_def: reject empty, reject any /, \, \0, newline, or carriage return, reject . and .. and leading-dot names, and reject absolute paths (including after os.path.normpath). Add defence-in-depth in CreatePythonEntryPointAction.create_actions and the Windows .exe launcher action: after building target_short_path, require os.path.normpath(target_short_path).startswith(BIN_DIRECTORY + os.sep) and refuse otherwise. The module and function fields should additionally be validated against a Python-identifier pattern, since the template interpolates them into the rendered script body verbatim, which is a second injection surface.

Class-wide pattern

This is the canonical Python instance of a five-codebase class: auto-generated console-script wrappers whose name field is derived from a package-metadata string and never validated against path traversal. The siblings, reported under coordinated disclosure across Anaconda, Prefix.dev, Quansight, PyPA, and Astral, are astral-sh/uv, pypa/pip (vendored distlib), conda/rattler, and mamba-org/mamba (libmamba). The Rust sibling is documented in the conda/rattler case study (CVE-2026-47425). The prior art in the same class is GHSA-pjjw-68hj-v9mw (uv uninstall-side path traversal, fixed April 2026).

Timeline

  • 2026-05-14: PGP-signed advisory submitted to conda/conda as a private GitHub Security Advisory, part of the coordinated multi-codebase disclosure.
  • 2026-06-11: CVE-2026-53940 assigned by the GitHub CNA. Reporter credit on berkant-koc.
  • Advisory GHSA-9m8m-c4j3-rj2c was published by the conda maintainers on 2026-07-01 (fix in conda 26.5.2, PR #16168); the CVE record CVE-2026-53940 went public at cve.org on 2026-09-21 (GitHub CNA). This entry was re-stamped on 2026-09-23 after the status update.

References

  • CVE-2026-53940: https://www.cve.org/CVERecord?id=CVE-2026-53940
  • GHSA-9m8m-c4j3-rj2c: https://github.com/conda/conda/security/advisories/GHSA-9m8m-c4j3-rj2c
  • Sibling advisory (Rust reimplementation): CVE-2026-47425 / GHSA-q53q-5r4j-5729 (conda/rattler)
  • Prior art: GHSA-pjjw-68hj-v9mw (uv uninstall-side path traversal)
  • CWE-22: Improper Limitation of a Pathname to a Restricted Directory ("Path Traversal")
  • Pinned audit commit: b874ca9

Both the CVE record and the GHSA advisory may not resolve publicly until the maintainer publishes the advisory.