Skip to content

Is allowing "gem yank" to free the gem namespace a security concern? #1226

@nateberkopec

Description

@nateberkopec

Problem

Once you've yanked all versions of a gem the namespace is free for others to use. If you accidentally pushed the wrong name once yank it and it'll be free for others to use.

Yesterday, a programmer with over 200+ modules on npm yanked all of their modules from NPM, freeing the module namespaces.

The vast majority of those freed module names (most of which are very generic - names like alert and attr) have been claimed by a single person. I believe I know who this person is (they didn't really try to hide), and they do not appear to be affiliated in any way with NPM or the original author of these modules, Azer Koçulu. This name-claimer, ~nj48, has pushed new versions of all the affected modules, replacing their source code with what appear to be basically blank modules.

Of course, the question is, what if they hadn't pushed blank modules, and instead pushed things like rimrafall?

As far as I can tell, there is nothing stopping this scenario from occurring on Rubygems.org, either. Please correct me if I'm wrong. In fact, I think it's even worse with Rubygems.org - imagine the following scenario:

  • Major gem author ragequits and yanks all version of all of their gems from Rubygems.org. Let's say the gem is called shmails. Let's say version 4.2.6 of this gem is the current version, and receives 1 million downloads per month.
  • Anyone may now claim the shmails gem name. An attacker pushes a gem called shmails with the gemspec version of 4.2.6. This gem runs system("rm -rf /").
  • What happens now?

EDIT: @qrush commented below that you couldn't re-push 4.2.6 in this scenario. You could push any version that hadn't already been pushed though, such as 4.2.7.

Solutions

I'm not sure. Author namespacing may help. rails becomes rails/rails, etc etc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions