# Untrusted PATH binary resolution

External tool looked up by name on PATH and run without ownership, writability or env checks

_Area: Software supply chain and CI/CD. Seen in 3 disclosed reports; latest 2026-11-16. Updated 2026-11-18._

## How it works
A helper needs an external tool (an interpreter, a renderer, a CLI). It looks the tool up by name through PATH or a search path, gets back whatever path resolves first, and executes it. The broken assumption is that "the binary named `dot` on PATH is the trusted one." If any earlier PATH directory is writable by the attacker (or by the victim, in a shared account), a planted file with that name wins the lookup and runs with the caller's privileges. The gap widens when the resolved path is executed with a raw subprocess call that skips the project's hardened spawn helper, so ownership checks and environment scrubbing never happen [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).

## Where it shows up
- A `find_binary`/`which`-style lookup followed by `subprocess.run`/`exec` on the returned path, with no `env=` and no ownership check [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).
- A project that documents a security chokepoint (e.g. `spawn_trusted`) but has call sites that bypass it [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).
- Lookup helpers that only refuse the current directory but still accept other writable PATH entries [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).
- Security docs that list an external tool under one module only, while other modules invoke the same tool [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).

## How to review
Find every place an external tool is invoked. For each, confirm the invariant: the executed path is either an absolute, trusted location, or it passed through the hardened spawn helper that verifies ownership/writability and scrubs loader environment variables. Grep for the binary name and for raw `subprocess.run`/`exec` to catch bypasses [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md). Check both text and binary branches of the caller, since they may share the same unsafe invocation [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).

## How finders spotted it
- Audited the project's native-tool security model against a prior advisory's remediation: noticed the security doc listed Graphviz `dot` only under `translate/api.py`, then read `dependencygraph.py` and found `dot2img` got the lookup change but not the hardened spawn routing [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).
- Refuted duplicate/shadowing objections with a negative control (`./dot` with none on PATH raises LookupError), proving the lookup, not shadowing, was the issue, and confirmed both text and binary branches share the flaw [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).

## Variants seen
- PATH-resolved external binary run without the trusted-spawn chokepoint [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).

## Impact and severity
Local code execution as the victim account, enabling lateral movement [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md). The unscrubbed child environment adds loader-injection surface, giving a second execution path [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md). Severity rises with reach: shared build hosts and CI runners turn a local trojan into supply-chain compromise [E3](https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md).

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **nltk (pip)** <= 3.10.3, fixed in 3.10.4: NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH  (CVE-2026-128134). Report: https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md. Fix: https://github.com/nltk/nltk/commit/b002a7288c22db86fd6ca2d9526e3f91d6fda797
- **hydra-core (pip)** >= 1.3.4, < 1.3.7, fixed in 1.3.7: Hydra: Mutable instantiate policy sets allow target blocklist bypass (CVE-2026-106439). Report: https://bugbountylibrary.com/r/ghsa%3AGHSA-mwj6-rfh8-7qf4.md. Fix: https://github.com/hydra-ecosystem/hydra/commit/0dd18084589a3d3e577d1f1a8a48fb485c94a5e6
- **Markdown Preview Enhanced** (WaveDrom renderer) fixed in v0.8.28: Supply Chain Security Analysis of a 9.5M-Install VS Code Extension (CVE-2026-50733, CVE-2026-54566). Report: https://bugbountylibrary.com/r/blog%3Aprojectdiscovery-io-blog-a-9-5m-install-vs-code-extension-one-markdown-file-and-a-supply-chain-foothold.md

## Evidence
- E1: https://bugbountylibrary.com/r/blog%3Aprojectdiscovery-io-blog-a-9-5m-install-vs-code-extension-one-markdown-file-and-a-supply-chain-foothold.md
- E2: https://bugbountylibrary.com/r/ghsa%3AGHSA-mwj6-rfh8-7qf4.md
- E3: https://bugbountylibrary.com/r/ghsa%3AGHSA-7mxv-7h3q-9324.md
