Skip to content
RCE Disclosed report Beginner

Code injection via ruby gems

A Ruby gem referenced in a GitLab project's README was not registered on the public RubyGems registry, allowing an attacker to claim the name and publish malicious code. Users following the installation instructions would then download and run the attacker's gem, potentially compromising their systems.

GitLab

Originally disclosed on GitLab

  • Fixed in 12 days
  • Disclosed after 12 days

HackerOne report #1739184 by sjn_scythe on 2022-10-18, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Hello team
I was going through your GitLab repository https://gitlab.com/gitlab-org/gitlab/ and found a ruby gem that was not available on public registry and i will be able to take over it. I didn't take over RubyGems because according to rubygems.org it hampers the brand name. But since the gem name is available any attacker can take over it and push malicious codes into it

Steps to reproduce

  1. Go to https:https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/gitlabenv/-/tree/master
  2. Scroll down in the Readme section you will find gem install gitlabenv.
  3. Now the way this gem gitlabenv has referenced any user downloading the gem will get the gem from rubygems.org.

Impact

An attacker will be able to inject malicious code inside GitLab internal server.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

How To Reproduce

Please add reproducibility information to this section:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the project's README instructed users to install a gem that was never published to the public RubyGems registry, leaving the name available for anyone to register.

Impact

An attacker could publish a malicious gem under the unclaimed name, and anyone following the installation instructions could have malicious code executed on their system.

What the attacker needed

Attacker registers the unclaimed gem name; victim follows the README installation command

How it was found

  1. Visit the GitLab project's repository page.
  2. Scroll down in the README to find the installation command.
  3. Note that the gem is fetched from rubygems.org, where the name is unclaimed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When software tells you to install a package by name, it usually fetches it from a public library. If that name is not already taken, anyone can upload a fake package with the same name. Here, a GitLab project told people to install a gem that did not exist publicly, so an attacker could create it and spread malware.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.