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
- Go to https:https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/gitlabenv/-/tree/master
- Scroll down in the Readme section you will find
gem install gitlabenv. - 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:
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
- Visit the GitLab project's repository page.
- Scroll down in the README to find the installation command.
- 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.