Skip to content

🐛 fix(bash): quote Unicode source as ASCII - #3695

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/bash-prompt-encoding
Nov 20, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/bash-prompt-encoding

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Under GB18030, a crafted Unicode prompt could execute a shell command when a virtualenv user sourced Bash activation. Bash activation now keeps the generated source syntax ASCII and reconstructs each original value as data at runtime (draft advisory ANT-2026-UMMZJBBH).

The Bash activator keeps shell quoting for ASCII runs and emits non-ASCII bytes through quoted octal substitutions. Bash and dash use their builtins; zsh also uses its builtin even when an external printf is absent or a shell function overrides the name. The substitutions remain quoted so custom IFS values cannot split them.

This change covers source parsing. Bash prompt redraw after a locale change is tracked separately in draft advisory ANT-2026-CR2KPIYY. Reported by oss-scanner: ANT-2026-UMMZJBBH.

@gaborbernat gaborbernat added bug security Fixes a vulnerability or hardens the supply chain, CI or release labels Nov 20, 2026
@gaborbernat
gaborbernat force-pushed the fix/bash-prompt-encoding branch from 554a97b to 8b450db Compare November 20, 2026 15:16
Legacy multibyte shell decoders can absorb a quote after a non-ASCII
byte sequence in an activation script. Emit Unicode bytes through
quoted octal substitutions and use the shell builtin in zsh, which
may have no external printf.
@gaborbernat
gaborbernat force-pushed the fix/bash-prompt-encoding branch from 8b450db to f8e6e9a Compare November 20, 2026 15:34
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 17:44
@gaborbernat
gaborbernat merged commit ab083de into pypa:main Nov 20, 2026
138 of 165 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant