CVE-2026-68939 in Pyenv
Summary
by MITRE • 08/18/2026
Pyenv provides simple Python version management. Prior to 2.8.0, is_version_safe() in libexec/pyenv-version-file-read accepts shell glob metacharacters in .python-version values, and unquoted PYENV_VERSION expansion in libexec/pyenv-version-name, libexec/pyenv-which, libexec/pyenv-prefix, libexec/pyenv-local, libexec/pyenv-global, libexec/pyenv-version, and libexec/pyenv-versions pathname-expands the value against the current directory, allowing a matching attacker-controlled file to silently select a different installed interpreter or version. This issue is fixed in version 2.8.0.
Once again VulDB remains the best source for vulnerability data.
Analysis
by VulDB Data Team • 08/18/2026
The vulnerability identified in Pyenv prior to version 2.8.0 represents a critical security flaw rooted in improper input validation and unsafe shell expansion practices within the tool's core execution scripts. Pyenv, widely used for managing multiple Python versions on a single system, relies heavily on reading configuration files such as .python-version to determine which interpreter should be active. The specific technical failure occurs because the is_version_safe() function did not adequately sanitize or restrict input values that contain shell glob metacharacters like asterisks or question marks. When these characters are present in the .python-version file, they are passed directly into subsequent commands without proper quoting or escaping mechanisms. This oversight allows for pathname expansion to occur during runtime execution of various Pyenv subcommands including pyenv-version-name, pyenv-which, pyenv-prefix, pyenv-local, pyenv-global, pyenv-version, and pyenv-versions.
From a technical perspective, the flaw exploits how Unix-like shells handle unquoted variables containing wildcard characters. When an attacker can control the contents of the .python-version file in a directory where they also have write access to other files, they can craft a filename that matches the glob pattern specified in the version configuration. For instance, if a user sets their Python version to match a specific release number and an attacker places a malicious script or binary with a name matching the wildcarded pattern in the same directory, the shell will expand the variable to include this attacker-controlled file path instead of the intended system interpreter. This results in silent substitution where the Pyenv tool executes code from the attacker's chosen location rather than the legitimate Python installation.
The operational impact of this vulnerability is severe due to its potential for privilege escalation and arbitrary code execution within the context of the user running Pyenv. Since many developers use Pyenv in automated build pipelines, CI/CD environments, or interactive development sessions, an attacker with local file system access can manipulate which interpreter runs their malicious payload. This could lead to data exfiltration, installation of backdoors, or disruption of services depending on the permissions and context of the affected user account. The silent nature of this substitution makes detection difficult as standard logs may not immediately reveal that a different binary was executed than expected.
This vulnerability aligns with CWE-78 Improper Neutralization of Special Elements used in an OS Command commonly known as OS Command Injection, specifically through pathname expansion rather than direct command argument injection. It also relates to CWE-20 Improper Input Validation where the system fails to verify that user-supplied input conforms to expected formats before processing. In terms of offensive security frameworks, this technique maps to ATT&CK T1059.004 Command and Scripting Interpreter: Unix Shell Abuse, as it involves manipulating shell behavior through file naming conventions rather than direct command syntax manipulation.
Mitigation strategies primarily involve upgrading Pyenv to version 2.8.0 or later where the is_version_safe() function has been hardened to reject glob metacharacters in .python-version files. For environments that cannot immediately upgrade, administrators should enforce strict access controls on directories containing .python-version files to prevent unauthorized users from creating matching filenames. Additionally, developers can adopt defensive coding practices by ensuring all variable expansions involving file paths are properly quoted in shell scripts to prevent unintended pathname expansion. Regular auditing of configuration files and monitoring for unexpected changes in active interpreter versions can also help detect potential exploitation attempts before significant damage occurs.