GHSA-cc5r-64rf-75hg

Suggest an improvement
Source
https://github.com/advisories/GHSA-cc5r-64rf-75hg
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-cc5r-64rf-75hg/GHSA-cc5r-64rf-75hg.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-cc5r-64rf-75hg
Aliases
Published
2026-11-19T23:46:54Z
Modified
2026-11-20T00:00:04Z
Severity
  • 7.3 (High) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H CVSS Calculator
Summary
NLTK: Untrusted search path in prover9/mace4 config allows local code execution via relative binary_location
Details

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:

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=<relative>) / 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 scoped to the dot binary and names the swept class as senna/weka/boxer/malt/repp/hunpos — prover9/mace absent.

Affected Versions

<= 3.10.3 — present on latest release and HEAD; no fix.

Suggested Fix

Mirror boxer: accept only the first os.path.isabs() result from find_binary_iter, or reject a relative binary_location in config_prover9/config_mace.


Reported by zx (Jace) — GitHub: @manus-use

Fix status (2026-09-28)

Status: IN PROGRESS (fix on an open pull request, not yet on develop).

PR: #3887 "Resolve every executed tool binary absolute-only: prover9/mace4, megam, tadm, java, hunpos (untrusted search path, CWE-426/427)", open; head 3ac1c5641 at the time of this note (a develop merge on top of 16b1de8ee, the head on which the verdicts below were measured).

Fix commits: f0a75c665 (a relative binary_location is rejected in prover9/mace, megam and tadm), 4ca190b74 (find_binary_absolute refuses a match containing '..'; config_java, hunpos and the prover9 helpers resolve absolute-only), 992884a02 (the JVM is resolved before spawning and spawned through spawn_trusted), d4f0309bb (own PATH walk without which, pathsec-gated tool locations, a pre-commit hook that keeps every spawn on pathsec).

Probe: nltk/test/unit/security_probes/ghsa_cc5r_64rf_75hg.py (on the PR). Verdict on the PR head: FIXED (213 relative locations refused across 9 entry points; with an install configured every form resolved to it and never to a CWD decoy; a PATH climbing into the decoy directory was refused; a world-writable install was refused at launch). The same probe run against develop 2fa3f48fe: VULNERABLE (config_prover9('./') took the CWD-relative binary ./prover9).

Release: none.

Maintainer reply (2026-09-28)

Status: fixed on develop, unreleased.

Fix: PR #3887 "Resolve every executed tool binary absolute-only: prover9/mace4, megam, tadm, java, hunpos (untrusted search path, CWE-426/427)", merged 2026-09-28 as merge commit 0ebe329cee693e7f84cb5d477b7a3638066194c8 on develop (PR head 3ac1c5641). Fix commits: f0a75c665 (a relative binary_location is refused in prover9/mace, megam and tadm), 4ca190b74 (find_binary_absolute refuses any match with a '..' component; config_java, hunpos and the prover9 helpers resolve absolute-only), 992884a02 (the JVM is resolved before spawning and spawned through spawn_trusted), d4f0309bb (own PATH walk without shelling out to which, pathsec-gated tool locations, and a pre-commit hook that keeps every subprocess spawn in nltk on the pathsec chokepoint). Prover9Parent.config_prover9 and Mace now resolve through nltk.internals.find_binary_absolute, which returns only an absolute candidate with no '..' component, so a relative binary_location can never select a file under the current working directory; the spawn itself goes through nltk.pathsec.spawn_trusted, which refuses a relative or untrusted executable even if one were handed to it directly.

Verification on develop 0ebe329ce with env -u PYTHONPATH /usr/local/bin/python3.13 (CPython 3.13.7, macOS). The proof of concept was run literally: an executable ./prover9 and ./mace4 planted in the working directory, each writing a marker file when run, PROVER9 unset, PATH pointing at an empty directory. Prover9().config_prover9('.') and Mace().config_prover9('.') both raise LookupError ("NLTK found 'prover9' only in the current working directory, which is not a trusted location for executables"), the later prove() and build_model() calls raise LookupError as well, and the marker file is never written. The reporter's bypass primitive find_binary('prover9', path_to_bin='.') now raises LookupError. Every relative form was tried at config time ('.', './', 'sub', './sub', './prover9', ''), through the PROVER9 variable ('.'), and through PATH entries ('.', '', 'sub', './sub'); all refused. With an absolute install configured through PROVER9, every one of those forms resolves to the install and never to the planted decoy. The regression probe nltk/test/unit/security_probes/ghsa_cc5r_64rf_75hg.py reports FIXED on develop (213 relative locations refused across 9 entry points; a PATH entry climbing into the decoy directory refused; a world-writable install refused at launch); the same probe reported VULNERABLE on develop 2fa3f48fe before the merge. nltk/test/unit/test_tool_search_path_security.py: 93 passed, 1 skipped, including the literal end-to-end proof of concept for Prover9 and Mace.

Severity reassessment. Reviewed and kept at High. CVSS 3.1 vector CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H, base score 7.3, unchanged from the report. Reasoning: the planted binary has to be on the local filesystem (AV:L); the vulnerability needs the application to be configured with a relative binary_location, and the CVSS 3.1 user guide (section 2.3.3) says a configuration-dependent vulnerability is scored assuming that configuration, so attack complexity stays Low (AC:L); the attacker needs write access to the resolved directory, a low-privileged local account (PR:L); the victim has to run the prover or model builder with that configuration (UI:R); the effect stays within the process (S:U); the planted binary runs as the invoking user (C:H, I:H, A:H). This matches how CWE-426 untrusted search path issues are scored in the NVD (7.3 with UI:R, 7.8 with UI:N) and sits at the same level as the sibling Graphviz dot advisory in this repository.

Release status. Not yet released; no tag contains 0ebe329ce. The latest release v3.10.3 (2026-08-12) predates the fix. The fix will ship in the next release.

Closing this advisory as fixed on develop.

Database specific
{
    "cwe_ids": [
        "CWE-426",
        "CWE-427"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-11-19T23:46:54Z",
    "nvd_published_at": "2026-11-19T17:17:56Z",
    "severity": "HIGH"
}
References

Affected packages

PyPI / nltk

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
3.10.4

Affected versions

2.*
2.0.1rc2-git
2.0b4
2.0b5
2.0b6
2.0b7
2.0b8
2.0b9
2.0.1rc1
2.0.1rc3
2.0.1rc4
2.0.1
2.0.2
2.0.3
2.0.4
2.0.5
0.*
0.8
0.9
0.9.3
0.9.4
0.9.5
0.9.6
0.9.7
0.9.8
0.9.9
3.*
3.0.0b1
3.0.0b2
3.0.0
3.0.1
3.0.2
3.0.3
3.0.4
3.0.5
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.3
3.4
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.5b1
3.5
3.6
3.6.1
3.6.2
3.6.3
3.6.4
3.6.5
3.6.6
3.6.7
3.7
3.8
3.8.1
3.9b1
3.9
3.9.1
3.9.2
3.9.3
3.9.4
3.10.0
3.10.1
3.10.2
3.10.3

Database specific

last_known_affected_version_range
"<= 3.10.3"
source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-cc5r-64rf-75hg/GHSA-cc5r-64rf-75hg.json"