Skip to content

cargo / crates.io is not immutable - potential risk of left-pad incident #5263

@fschutt

Description

@fschutt

This is an issue that I'm a bit concerned about: When yanking a crate, cargo does not check if that crate is dependent upon by other crates. Therefore, a left-pad incident can currently happen. If someone would decide to yank libc right now, for example, all hell would break loose.

Example: https://crates.io/crates/libfoo-test

Here we have libfoo, which depends on libbaz version 0.1.0. I was able to yank libbaz 0.1.0, thereby breaking libfoo in the process. What you have to do is to publish a new version of libbaz, then yank the (version - 1) crate. For some reason, cargo neither does semver-checks (it could, for example, see that version 0.1.0 and 0.2.0 are identical) nor does it allow libfoo access to libbaz (in a "you know my sha1, so I'll give you access, even though the crate is yanked" way).

If you try to depend on libfoo now, all you get is:

    Updating registry `https://github.com/rust-lang/crates.io-index`
error: no matching version `^0.1.0` found for package `libbaz-test`
location searched: registry `https://github.com/rust-lang/crates.io-index`
versions found: 0.2.0
required by package `libfoo-test v0.1.0`
    ... which is depended on by `dependency-test v0.1.0 (file:///home/felix/Development/dependency-test)`

This is dangerous because now the maintainer of libfoo has to be notified to manually update his package to upgrade to libbaz 0.2.0. If libbaz has lots of dependents, this can break a lot of builds. Yes, the maintainer can upgrade to the new version, but the damage is done at first. This violates the "immutability" of cargo - once a package (in this case libfo) is uploaded, it should always build. Is this the intentional design? If yes, why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions