You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tracking: Limit the range of valid toolchain names, take caution in rust-toolchain.toml #4059
@rami3l
I think we should be pretty conservative for custom toolchain names only (i.e. [A-Za-z0-9._-]+) while still rejecting
none
+prefix
official/resolvable toolchain names
names containing / or \
This IMO keeps common names a user might use and just removes whitepsaces, quotes, shell metacharacters, etc. that seemingly makes error messages or terminal output easier to weaponize.
Now I guess this is technically a compatibility break for existing linked custom toolchains with names such as spaces or #/parentheses, since ToolchainName::try_from is also used when listing installed toolchains...
But given the goal of this issue is to make legal toolchain names clearly defined and safer to display, I think the allowlist is preferable to continuing with “anything except a few banned characters.”
However there might be some existing normalization rules about slashes that we might want to keep.
This is later categorized into official and custom toolchain names so in principle, as you have noticed above, the two cannot overlap. If you have found any counter-examples existing in our current logic, please don't hesitate to file another issue.
What names we want to reserve that may have special meaning in the future. For now we have none, but we may want more than that just in case.
This is later categorized into official and custom toolchain names so in principle, as you have noticed above, the two cannot overlap. If you have found any counter-examples existing in our current logic, please don't hesitate to file another issue.
It would be nice to structure the code such that the type system can enforce this.
I think we can be more forgiving then [A-Za-z0-9._-]+ and allow any non-ascii character. I cannot see us using anything but ascii for special characters (and control characters are ascii too). I do worry that being too restrictive will break some real-world usage (e.g. people using toolchain names in their own language). Though for rust-toolchain.toml I can definitely see the wisdom in being more restrictive (maybe use something more like rust's identifiers which use XID_CONTINUE).
I think we can be more forgiving then [A-Za-z0-9._-]+ and allow any non-ascii character.
I do worry that being too restrictive will break some real-world usage (e.g. people using toolchain names in their own language).
... and we can make #4053 resurface if we are not careful enough about what to include. Also, many possible confusions around normalization and other Unicode-specific stuff as I can imagine...
warning: identifier contains an uncommon character:'ᅟ'
...
= note: this character is included in the Unicode general security profile
= note: `#[warn(uncommon_codepoints)]` on by default
We could be more restrictive than the rust default (e.g. effectively act as if #![forbid(uncommon_codepoints)] is enabled). I do worry that the more restrictive we are the more likely we are to break people, especially as attacks are only an issue for rust-toolchain.toml.
Though maybe it is worth testing the most restrictive version. Unfortunately I don't think many people use our betas...
If you consider something more like the Rust identifier, the pattern might should look more or less like this (not available on the official playground, but you can try with this link):
@ChrisDenton Is that what you'd expect in your previous reply? I'm still worried about é vs é, o vs ο and other things this doesn't resolve. Of course those will be existing issues so we can retain the status quo in that respect.
Activity
cachebag commentedon Jun 29, 2026
@rami3l
I think we should be pretty conservative for custom toolchain names only (i.e.
[A-Za-z0-9._-]+) while still rejectingThis IMO keeps common names a user might use and just removes whitepsaces, quotes, shell metacharacters, etc. that seemingly makes error messages or terminal output easier to weaponize.
Now I guess this is technically a compatibility break for existing linked custom toolchains with names such as spaces or
#/parentheses, sinceToolchainName::try_fromis also used when listing installed toolchains...But given the goal of this issue is to make legal toolchain names clearly defined and safer to display, I think the allowlist is preferable to continuing with “anything except a few banned characters.”
What do you think?
rami3l commentedon Jun 29, 2026
@cachebag I think we are pretty much discussing 2 things with the naming restrictions here:
[A-Za-z0-9._-]+might already be enough for 99% of the cases. This seems to be a very good decision considering[a-zA-Z_][a-zA-Z_0-9]*from the common identifier rule and1.23.0-beta.2from feat: support for parsing beta versions with tags in the toolchain #3858).none, but we may want more than that just in case.rustup runand proxies (Environment variable to disablerust-toolchain.toml#2793), so in this case it might also be interesting to choose a prefix to ban.+file:has been proposed as a placeholder inrust-toolchain.toml: support multiple channels, or rather support nightly AND stable version. #4391 (comment) because it starts with+, however I'm not entirely sure if that's the best idea XDdjc commentedon Jun 30, 2026
It would be nice to structure the code such that the type system can enforce this.
ChrisDenton commentedon Jul 2, 2026
I think we can be more forgiving then
[A-Za-z0-9._-]+and allow any non-ascii character. I cannot see us using anything but ascii for special characters (and control characters are ascii too). I do worry that being too restrictive will break some real-world usage (e.g. people using toolchain names in their own language). Though forrust-toolchain.tomlI can definitely see the wisdom in being more restrictive (maybe use something more like rust's identifiers which useXID_CONTINUE).rami3l commentedon Jul 2, 2026
@ChrisDenton My 2 cents as a Chinese: this smells like homograph attack to me :o
For example, according to https://github.com/jagracey/Awesome-Unicode#user-content-variable-identifiers-can-effectively-include-whitespace, this is valid Rust:
This is how it looks in my Ghostty:
... and we can make #4053 resurface if we are not careful enough about what to include. Also, many possible confusions around normalization and other Unicode-specific stuff as I can imagine...
ChrisDenton commentedon Jul 2, 2026
That does trigger a rustc warning (playground):
We could be more restrictive than the rust default (e.g. effectively act as if
#![forbid(uncommon_codepoints)]is enabled). I do worry that the more restrictive we are the more likely we are to break people, especially as attacks are only an issue forrust-toolchain.toml.Though maybe it is worth testing the most restrictive version. Unfortunately I don't think many people use our betas...
ChrisDenton commentedon Jul 2, 2026
Basically I think there's two issues here:
rust-toolchain.tomlwe want to further restrict valid charactersrami3l commentedon Jul 3, 2026
If you consider something more like the Rust identifier, the pattern might should look more or less like this (not available on the official playground, but you can try with this link):
@ChrisDenton Is that what you'd expect in your previous reply? I'm still worried about
évsé,ovsοand other things this doesn't resolve. Of course those will be existing issues so we can retain the status quo in that respect.feat(toolchain/names): accept unicode identifiers in toolchain names
feat(toolchain/names): accept unicode identifiers in toolchain names
feat(toolchain/names): accept unicode identifiers in toolchain names
settings.tomland its stability guarantees #4944settings.tomland its stability guarantees #4944feat(toolchain/names): accept unicode identifiers in toolchain names