Skip to content

🐛 fix(probe): report paths in host file system encoding - #290

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/probe-host-fs-encoding
Nov 30, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/probe-host-fs-encoding

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Discovery starts each candidate interpreter in UTF-8 Mode and reads the file names it reports. Under an older non-UTF-8 locale such as ISO-8859-1, the calling tool decodes file names differently, so a path with accented letters could name another file. Discovery could then start a program another local user placed under the look-alike name and report it as the base Python. 🔒 Candidates now report names in the caller's encoding. This addresses draft advisory ANT-2026-794CGR4Y.

With a Python install in a folder whose name is stored as UTF-8, run under a Latin-1 locale:

$ cp -a "$(dirname "$(dirname "$(readlink -f "$(uv python find 3.10)")")")" café
$ LC_ALL=en_US.iso88591 python -c 'import os
from python_discovery import get_interpreter
print(get_interpreter(os.fsdecode(os.path.abspath(b"caf\xc3\xa9/bin/python3.10"))).system_executable)' 2>&1 | tail -1

Before:

RuntimeError: failed to query /home/me/demo/caf\xe9/bin/python3.10 with code 2 err: 'No such file or directory'

After:

/home/me/demo/café/bin/python3.10

The calling tool passes its encoding to each candidate, and cached answers are stored per encoding, so an answer recorded under one locale is never reused under another.

UTF-8 locales, macOS and Windows see no difference. After upgrading, each interpreter is queried once more, because older cached answers no longer match.

Reported by oss-scanner: ANT-2026-794CGR4Y.

The interrogation script runs in UTF-8 mode, but the host decodes the paths
it gets back with its own file system encoding. Under a non-UTF-8 locale the
same text named other bytes, so discovery could run a different file and
return it as system_executable.

The host now passes its file system encoding to the script, which re-encodes
the reported paths into it. The cache entry records that encoding as well, so
an entry written under one encoding is not read under another.

Reported by oss-scanner as ANT-2026-794CGR4Y.
@gaborbernat gaborbernat added bug Something isn't working security Security fixes and advisories labels Nov 29, 2026
@gaborbernat
gaborbernat merged commit 3d0d8e2 into tox-dev:main Nov 30, 2026
28 checks passed
@gaborbernat
gaborbernat deleted the fix/probe-host-fs-encoding branch November 30, 2026 15:53
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