Skip to content

🐛 fix(py-info): reject sysconfig format widths - #229

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:bug/xid4aaxx-sysconfig-width
Nov 3, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:bug/xid4aaxx-sysconfig-width

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

PythonInfo.sysconfig_path() expanded an interpreter-reported path pattern with str.format(). A reported field width made one install_path("purelib") call allocate a 2 GB string in the caller, as issue #199 reproduces. The method now rejects format specifiers before expanding the pattern. Fixes #199.

An interpreter-controlled width reached str.format()

The Python format specification syntax permits field widths after a colon. The interpreter collector records unexpanded sysconfig path patterns, and the old sysconfig_path() passed those patterns to str.format(). The new check uses Formatter.parse() to reject nonempty format specifications before formatting.

Behavior changes

When a candidate reports a format specifier in a sysconfig path, sysconfig_path() and install_path() raise ValueError naming the key. Patterns with ordinary placeholders keep their existing path results on POSIX and Windows.

Reported by Anthropic's OSS Scanner: ANT-2026-XID4AAXX.

An interpreter can report a path pattern with a field width large enough
to exhaust the caller when it requests an installation path. Reject format
specifiers before expanding the pattern.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 3, 2026
@gaborbernat
gaborbernat merged commit 8befe13 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sysconfig format widths can allocate gigabyte paths

1 participant