Skip to content

Treat an empty CONDA_PREFIX as "no conda env" in find_nvidia_binary_utility - #2498

Open
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:pathfinder-empty-conda-prefix
Open

Treat an empty CONDA_PREFIX as "no conda env" in find_nvidia_binary_utility#2498
LeSingh1 wants to merge 1 commit into
NVIDIA:mainfrom
LeSingh1:pathfinder-empty-conda-prefix

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown

find_nvidia_binary_utility() gates its conda step on CONDA_PREFIX being set rather than non-empty:

if (conda_prefix := os.environ.get("CONDA_PREFIX")) is not None:

os.path.join("", "bin") is "bin", so an empty CONDA_PREFIX puts a CWD-relative directory into the trusted search list. The assert directory guard in _resolve_in_trusted_dirs() does not catch it, because the joined value is non-empty. A ./bin/nvcc in the process working directory is then returned as an absolute path, and the caller executes it — the same CWD-leakage class as #2119.

An empty-but-set CONDA_PREFIX is not exotic: container images and CI setups that export it unconditionally produce exactly that, as do shells that blank it instead of unsetting it.

Every other pathfinder search step already uses the truthiness rule — search_steps.find_in_conda, _static_libs, _headers — and test_search_steps.py::test_returns_none_with_empty_conda_prefix pins it for dynamic libs. This brings the binary finder in line.

The test plants a decoy ./bin/nvcc, sets CONDA_PREFIX="", and asserts None; it returns the decoy path without the fix.

NOTE: developed with the assistance of an AI coding agent. The new test carries @pytest.mark.agent_authored per AGENTS.md. I reviewed and verified the change and the reproduction before submitting.

…tility

`find_nvidia_binary_utility()` accepted any CONDA_PREFIX that was merely set,
including the empty string. `os.path.join("", "bin")` is `"bin"`, so an empty
CONDA_PREFIX added a CWD-relative directory to the trusted search list. The
`assert directory` guard in `_resolve_in_trusted_dirs()` does not catch this
because the joined value is non-empty, so a planted `./bin/nvcc` in the
process working directory could be returned as an absolute path -- the same
CWD-leakage class that NVIDIA#2119 fixed.

Every other pathfinder search step (`search_steps.find_in_conda`,
`_static_libs`, `_headers`) already treats an empty CONDA_PREFIX as "not in a
conda environment"; this brings the binary finder in line.
@copy-pr-bot

copy-pr-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.pathfinder Everything related to the cuda.pathfinder module label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.pathfinder Everything related to the cuda.pathfinder module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant