GHSA-cc5r-64rf-75hg: NLTK: Untrusted search path in prover9/mace4 config allows local code execution via relative binary_location
- Source:
- OSV.dev
- Published:
- Fetched:
- Updated:
- Affects:
- nltk
https://osv.dev/vulnerability/GHSA-cc5r-64rf-75hg ↗
NLTK: Untrusted search path in prover9/mace4 config allows local code execution via relative binary_location ## Summary `Prover9Parent.config_prover9(binary_location=...)` (and `Mace`, which inherits it) accepts a relative `binary_location` and passes it as `path_to_bin` to `find_binary`, which disables the CWD-relative rejection guard. Unlike the boxer/senna/malt/repp siblings, prover9/mace apply no `os.path.isabs()` filter, so the resolved relative program path (e.g. `./prover9`) is executed from the current working directory via `subprocess.Popen`. A local attacker who can plant `./prover9` (or `./mace4`) in the resolved directory achieves local code execution. ## Root Cause `nltk/inference/prover9.py:121-135` calls `find_binary(name, path_to_bin=binary_location, env_vars=["PROVER9"], ...)`. A truthy `path_to_bin` sets `searching_bare_name = not path_to_bin and ...` → False (`internals.py:935`), so the guard `if searching_bare_name and not os.path.isabs(path): continue` (`internals.py:940`) never runs. The result is stored in `self._prover9_bin`; on the next `prove()`, `_call` → `subprocess.Popen([binary]+args, ...)` (`prover9.py:207`) execs it. `Mace(Prover9Parent)` inherits `config_prover9` (`mace.py:229`). By contrast boxer's `_find_binary` (`sem/boxer.py:251-266`) iterates `find_binary_iter` and returns only the first `os.path.isabs()` result; repp/malt/senna similarly reject a relative explicit bin dir. prover9/mace have no such filter. ## Impact Local arbitrary code execution: an attacker-planted `./prover9`/`./mace4` runs as the invoking user when the application is configured with a relative `binary_location` and the attacker can write to the resolved directory. ## Proof of Concept In a directory containing an executable `./prover9`: ```python from nltk.inference.prover9 import Prover9 p = Prover9(); p.config_prover9(binary_location='.') # p._prover9_bin == './prover9'; subsequent prove() Popens it from CWD ``` Runtime-confirmed: `find_binary('prover9', path_to_bin='.')` → `'./prover9'`; bare `find_binary('prover9')` and relative `PROVER9='.'` via default `_find_binary` both raise `LookupError` (the default path is protected). ## Attack Chain 1. Entry: app calls `config_prover9(binary_location= )` / `config_mace(...)`. Guard: CWD-rejection in `find_binary_iter`. Bypass proof: truthy `path_to_bin` sets `searching_bare_name=False` → filter never runs. 2. Resolution: `find_binary` returns `'./prover9'`. Guard: boxer's `if os.path.isabs(binary): return`. Bypass proof: prover9/mace have no such loop — relative first match stored verbatim. 3. Sink: `subprocess.Popen(['./prover9']+args)` (prover9.py:207) — separator-containing path ⇒ execvp runs it relative to CWD, bypassing `$PATH`. 4. Impact: planted `./prover9`/`./mace4` executes = local code execution. ## Bypass Evidence Runtime: `find_binary('prover9', path_to_bin='.') -> './prover9'`; `find_binary('prover9') -> LookupError`. `git log -- nltk/inference/prover9.py nltk/inference/mace.py` shows only copyright/formatting commits — no security fix. GHSA-6hwm-xvph-95vm (CWE-426/427) is Affected: PyPI:nltk Fixed in: 3.10.4 References: https://github.com/nltk/nltk/security/advisories/GHSA-cc5r-64rf-75hg https://nvd.nist.gov/vuln/detail/CVE-2026-129234 https://github.com/nltk/nltk/pull/3887 https://github.com/nltk/nltk/commit/4ca190b744ec72500c4c8a8259aece7792a46877 https://github.com/nltk/nltk/commit/992884a02f6fb5180a992ed12d20103b4b5cb8a0 https://github.com/nltk/nltk/commit/d4f0309bb8649f77e88c2c435e5fa31e6c5ab225 https://github.com/nltk/nltk/commit/f0a75c66506977c0f683281c0f5275dbfbaee3b2 https://github.com/nltk/nltk