crates.io: We shouldn't let you add someone as an owner without their consent

This is a vector for abuse. We should require confirmation from the person being added before adding them, just like Github does for adding someone as an owner to a repo/team.


Implementation steps added by carols10cents:

The following tasks assume we’ll need a web UI for this in order to support users with arbitrarily old versions of cargo. I don’t think crates.io can have a state where this feature is “half on”, and even if we did, I think we’d have to stay in that state forever because people are always going to be using older versions of cargo. I’m open to hearing ideas on this issue though!

Crates.io Deployable chunk 1: Listing invitations

  • (https://github.com/rust-lang/crates.io/pull/1040) Add a new table, crate_owner_invitations or something, that has columns:
    • id of the user who ran cargo owner --add
    • id of the user who is being added
    • id of the crate involved
    • status of the invitiation the only invitations in this table should be pending invitations; accepted invitations can be removed from this table and records added to crate_owners instead; declined invitations can be removed from this table.
    • when this request was created
  • Don’t add records to this table on a cargo owner --add in this PR, add records to this table either manually with psql or in tests
  • (https://github.com/rust-lang/crates.io/pull/1040) Make an API route that can list all of the currently logged in user’s pending invitations
  • (https://github.com/rust-lang/crates.io/pull/1057) Make a frontend page that calls that API route and displays the currently logged in user’s pending invitations (don’t link to this page from anywhere yet though)

Crates.io Deployable chunk 2: Accepting invitations

Still not creating records in crate_owner_invitations when cargo owner --add is run

  • Make an API route for the currently logged in user to accept an invitation for a particular crate
    • In a transaction:
      • Add a record to the crate_owners table
      • Remove the record from the crate_owner_invitations table
  • On the frontend page that lists pending invitations, have a button that calls the accept API route (and displays success/error nicely, etc)

Crates.io Deployable chunk 3: Declining invitations

Still not creating records in crate_owner_invitations when cargo owner --add is run

  • Make an API route for the currently logged in user to decline an invitation for a particular crate
    • Delete the crate_owner_invitations record
  • On the frontend page that lists pending invitations, have a button that calls the decline API route (and displays success/error nicely, etc)

Crates.io Deployable chunk 4: Requiring approval for ownership

Assume no changes to cargo, because we can’t change old cargo anyway!

  • When someone runs cargo owner --add for a user (not a team):
    • Don’t create a record in crate_owners, instead create a record in crate_owner_invitations
    • Hopefully send a response back from crates.io that tells the person running the command that the person being added should visit the list invitations page on crates.io to accept ownership (this might not be possible depending on what cargo does today though)
  • To make the approval process discoverable as the person being added to the crate from old cargo, when someone runs cargo publish on a crate where there’s a pending invitation to add them as an owner:
    • Fail the publish
    • Return an error message from crates.io that directs the user that they have to accept the ownership invitation first by going to the list invitations page, and then they can try publishing again
  • Document this requirement in the cargo owner docs (which currently live in cargo’s repo) split into https://github.com/rust-lang/cargo/issues/4599
  • Super nice would be some sort of notification that shows up anywhere on crates.io and lets you know you have outstanding ownership invitations and you should go to the invitation list page to approve or decline them (thank you for this idea @natboehm!!!) split into https://github.com/rust-lang/crates.io/issues/1116

Cargo deployable chunk 5: adding CLI support for accept/decline

split into https://github.com/rust-lang/cargo/issues/4600

Crates.io deployable chunk 6: UI for adding someone as an owner

split into https://github.com/rust-lang/crates.io/issues/1117

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 8
  • Comments: 34 (33 by maintainers)

Commits related to this issue

Most upvoted comments

Natalie is working on the email ish https://github.com/rust-lang/crates.io/issues/808 so emails are coming.

Invitations have been turned on!!! Thank you @sunjay and @natboehm!!

I think I’m going to split the remaining tasks into separate issues, since they’re mostly enhancements, the main request is “done” at this point.

@carols10cents How many versions back of cargo do we need to support? It may be worthwhile to look at the history of what cargo has done in the --add command to see about this particular point in the implementation.

As many as we can back to what was shipped with Rust 1.0, imo.

Thank you for your comments @sunjay!

This was more of a convenience feature. The idea was that instead of having to execute a separate command at publish, we would give them the option to accept the invitation right when they need it. This would be something in addition to the --accept/–decline part of the flow. Apon further reflection, I’m not sure if it’s entirely necessary.

Yes, I don’t think integrating acceptance with publish is necessary for an MVP of this feature.

We would only need people to upgrade their cargo if they want to accept/decline/block invitations. Everything else would remain the same. Is it still not sufficient to just produce a message saying that they need to have cargo version x.x or higher? We could make this very clear in the documentation too. I’m asking because I think strict backwards compatibility while desirable is really hard to maintain and the cases where people would need to be able to do this are few.

Enterprises and linux distributions are not able to just upgrade whenever. So no, we can’t just make people upgrade in order to be able to accept/decline publishing invitations, unfortunately.

If we were to stick to command line only for now, we would still add the web UI in the future. It just wouldn’t be mandatory for the release of invitations. (I think prioritizing the bare minimum implementation is really important.)

Since we can’t make people upgrade, the bare minimum implementation can be the web UI, and we can add the command line UI in the future.

One thing I would really like as part of all of this abuse prevention work (but not this issue specifically) is to setup some integration tests that actually simulate abuse on a test user. I am happy to help out with this since I have some ideas already.

Please open a new issue to discuss the more general things you have in mind-- I’d be interested to hear what you’re thinking about that couldn’t be implemented with the tests we have today that run in CI and why they’d have to run against the live site.

Thanks! I’ll admit I felt apprehensive about sharing the idea in the first place given that I’ve never even touched the code in this repo. I’m happy to hear you both liking it. Thanks for being open to that. 😊

I can help with the cargo integration stuff in about a week or so. What needs to be done from the crates.io side? I think much of your initial comments still apply just without the email stuff.

i am coming around to this CLI solution. it’s really elegant actually. i think people will eventually ask for email integration, but that gives us time to build all that shenanigans out. good call @sunjay !

I think I kinda just like @sunjay’s suggestion of hooking verification into the publish process? Absolutely no notification if you’ve been added as an owner (so there’s no way to even spam someone with ownership requests), and you can claim ownership the moment it’s actually relevant (when you need to publish).

We could do the same thing for owner --remove, in the case of an ownership transfer (and then it’s kinda like an atomic transfer op, which is neat).

Presumably, if you’re adding someone as an owner, you have another communication channel to inform them that you did this.