Dependency Confisuion leads to code injection.
A Ruby gem named in a GitLab repository's README was not registered on the public gem server, so an attacker could claim it. Anyone installing the gem as instructed would then run attacker-controlled code.
GitLab
Originally disclosed on GitLab
- Fixed in 3 days
- Disclosed after 3 days
HackerOne report #1746365 by rcht on 2022-10-22, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Report
Hi Team,
I found a dependency confusion in a ruby gem package mentioned in your gitlab repository :-https://gitlab.com/gitlab-org/incubation-engineering/real-time-editing/yrb-actioncable/-/blob/main/README.md
gem install yrb-actioncable
Now I will be able to takeover the package which allows me to inject code into there and whenever someone in gitlab installs this package due to dependency confusion my package will be installed leading to code injection in gitlab servers.
Steps to reproduce:-
- Go to https://gitlab.com/gitlab-org/incubation-engineering/real-time-editing/yrb-actioncable/-/blob/main/README.md .
- Search for
gem install yrb-actioncable - Now if you go to https://rubygems.org/gems/yrb-actioncable you can see that the gem name is available for anyone to takeover.
Reason behind not taking over the gem as of now is, if I takeover the gem now, even if I delete it, it will take another 90 days for that gem name to become available, before gitlab can reclaim it.
PoC:-
Here in PoC video , I am showing that the gem is available to takeover.
Impact
Code Injection, Remote Code execution.
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 referenced a gem name in its documentation without ensuring that name was registered on the public gem server, leaving it open to being claimed by anyone.
Impact
An attacker could inject code into GitLab servers when someone installs the gem, which the reporter says could lead to remote code execution.
What the attacker needed
Gem name unclaimed on public server; someone installs the gem
The fix
The gem name should be reclaimed by GitLab to prevent takeover.
How it was found
- Open the README file in the GitLab repository.
- Find the installation command for the gem.
- Check the public gem server and see that the gem 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 is installed, it often comes from a public package library. If a company uses a package name that is not already taken on that public library, an outsider can register it first. Then, when the company installs that package, they get the outsider's code instead of the intended one.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.