Skip to content

Commit 4c7534e

Browse files
committed
Extend documentation on security concerns of crate names in a registry.
1 parent dba478b commit 4c7534e

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/doc/src/reference/registries.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,23 @@ directories:
159159
> package names in `Cargo.toml` and the index JSON data are case-sensitive and
160160
> may contain upper and lower case characters.
161161
162-
Registries may want to consider enforcing limitations on package names added
163-
to their index. Cargo itself allows names with any [alphanumeric], `-`, or `_`
164-
character. For example, [crates.io] imposes relatively strict limitations,
165-
such as requiring it to be a valid Rust identifier, only allowing ASCII
166-
characters, under a specific length, and rejects reserved names such as
167-
Windows special filenames like "nul".
162+
Registries should consider enforcing limitations on package names added to
163+
their index. Cargo itself allows names with any [alphanumeric], `-`, or `_`
164+
characters. [crates.io] imposes its own limitations, including the following:
165+
166+
- Only allows ASCII characters.
167+
- Only alphanumeric, `-`, and `_` characters.
168+
- First character must be alphabetic.
169+
- Case-insensitive collision detection.
170+
- Prevent differences of `-` vs `_`.
171+
- Under a specific length (max 64).
172+
- Rejects reserved names, such as Windows special filenames like "nul".
173+
174+
Registries should consider incorporating similar restrictions, and consider
175+
the security implications, such as [IDN homograph
176+
attacks](https://en.wikipedia.org/wiki/IDN_homograph_attack) and other
177+
concerns in [UTR36](https://www.unicode.org/reports/tr36/) and
178+
[UTS39](https://www.unicode.org/reports/tr39/).
168179

169180
Each line in a package file contains a JSON object that describes a published
170181
version of the package. The following is a pretty-printed example with comments

0 commit comments

Comments
 (0)