GitHub advisory · PyPI
virtualenv: Xonsh activation literals depend on the script decoding codec
Description
Caller-supplied prompt text can become executable syntax in the xonsh activation script. An attacker must influence the value passed to virtualenv, and a user must subsequently activate the environment.
Xonsh reads a UTF-8 activation script using a legacy multibyte encoding such as GBK. Printable non-ASCII bytes can change how the reader recognizes an adjacent quote. The report concerns POSIX activation. It does not establish exposure through unrelated activators.
The attacker controls prompt or destination data passed as a virtualenv argument. The user later sources the generated activation script.
The relevant 21.14.8 source is in xonsh quote(), UTF-8 template writer.
The generator writes activate.xsh as UTF-8. Its quote() used repr(), which leaves printable non-ASCII characters
in the file and backslash-escapes an embedded quote. Xonsh's source reads the file using $XONSH_ENCODING. With GBK
or Big5, the UTF-8 bytes of 中 end in 0xad, which pairs with the following 0x5c backslash as one decoded character.
The backslash no longer escapes the quote. A prompt containing both quote kinds can then close its Python string literal
and supply statements that run during activation. With UTF-8 source decoding, the same value stays inside the literal.
The original scanner finding, ANT-2026-PAUVP7YL, demonstrated this byte-level failure in activate_this.py: a hostile
prompt loaded through exec(open(file).read(), ...) under GBK created a marker, while UTF-8 and runpy.run_path
controls did not. The xonsh path in this advisory was identified in the subsequent maintainer-provided…
Manual fix · PyPI
pip install --upgrade "virtualenv>=21.14.9"Sources