Skip to content

🐛 fix(shims): bound version file reads - #209

Merged
gaborbernat merged 3 commits into
tox-dev:mainfrom
gaborbernat:security/wxconowu-bounded-version-file
Nov 3, 2026
Merged

gaborbernat merged 3 commits into
tox-dev:mainfrom
gaborbernat:security/wxconowu-bounded-version-file

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

_versions_in_file() read an entire version file while resolving a version-manager shim. A file in a shared parent directory could make the caller allocate memory proportional to its length. The reader now caps input at 4096 characters and skips larger files. This addresses draft advisory ANT-2026-WXCONOWU.

Version file reads

pyenv searches the working directory and its parents for .python-version. _active_versions() uses the same search, and the old reader iterated without a length limit. The reader now requests at most 4097 characters to distinguish an allowed file from an oversized one without reading the rest. It splits only newline characters, preserving version names that contain other Unicode separators.

Behavior changes

Files over 4096 characters no longer select a version. Discovery checks parent directories and, for pyenv, its global version when available. Files within the limit keep their existing parsing behavior, including replacement of undecodable bytes.

Reported by Antigravity: ANT-2026-WXCONOWU.

A version file in a shared parent directory could exhaust the caller's
memory during shim resolution. Skip files over 4096 characters so
discovery can continue with another version source.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 2, 2026
@gaborbernat gaborbernat added the security Security fixes and advisories label Nov 3, 2026
@gaborbernat
gaborbernat merged commit 8a6e078 into tox-dev:main Nov 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security fixes and advisories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant