[codex] Avoid untrusted binary lookup paths#2111
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
| (``.exe``, ``.bat``, ``.cmd``). On Unix-like systems, executables | ||
| are identified by the ``X_OK`` (execute) permission bit. | ||
|
|
||
| The process current working directory and ``PATH`` are not searched. |
There was a problem hiding this comment.
I could understand the logic of not searching the current working directory for these binaries, but not searching PATH seems like a mistake. If someone did a userspace installation of the toolkit in a non-standard way, inserting something like nvcc on the PATH would be the correct behavior and expected way for us to find it.
Additionally, given we already allow environment variable based override it doesn't open up any other attack surface that isn't already exposed.
There was a problem hiding this comment.
The spirit of the warning was preventing any directory that wasn't explicitly programmed into pathfinder. So if we agree that we want to prevent then it follows that we should prevent solutions that use PATH as well b/c its not a formalized path that was baked into the tool.
|
I asked Cursor GPT-5.5 1M Extra High for an analysis and recommendation, based on enumerating pros-and-cons of
Below is what it gave me. The recommendation is exactly what I was hoping for :-) PR 2111 is really about making
|
|
Part of the linux installation guide for CUDA indicates that If someone follows this installation guide and sets |
|
It would be helpful that every PR has a corresponding issue created first, and we triage the issue and ensure work needs to happen. I am clueless what we're trying to solve here... By my standard I would just close this PR right away 😛 |
|
I read the security report that Keith shared offline. The way I look at, it is not even about any security issue. This PR actually ensures we honor the pathfinder contract better. Assuming a pathological case where my CWD is |
Summary
This PR updates
cuda.pathfinder.find_nvidia_binary_utility()to search only the trusted binary directories it constructs internally instead of delegating toshutil.which().It was created in response to the security scan that highlighted a vulnerability where Windows
shutil.which(..., path=...)may search the process current working directory before the explicitly supplied trusted search path. That could allow binary planting if a caller executes the returned utility path.Root Cause
On Windows, CPython
shutil.which()can prepend the current working directory to executable resolution. Becausefind_nvidia_binary_utility()is a public API intended to return paths that callers execute, a maliciousnvcc.exeor other supported utility in an attacker-controlled CWD could be returned before the real CUDA, Conda, or NVIDIA wheel binary.Changes
shutil.which()with an explicit loop over trusted directories.PATHare not searched.Validation
pixi run pytest tests/test_find_nvidia_binaries.pypixi run pytest tests/git diff --check