Claiming package names in GitLab's automatic package referencer.
GitLab automatically linked package names in manifest files to public registries, assuming the package had been published there. An attacker could register an unpublished package name on npm so that GitLab's link pointed to a malicious module, tricking users into installing it.
Originally disclosed on HackerOne
- Triaged in 4 days
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 4 months
Summary by the researcher
@insiderphd did a really good job summarising this report in https://youtu.be/RobCqW2KwGs?t=1033. :)
The report
Hi team,
GitLab has a pretty neat feature that auto-links packages to their respective registry. The problem is that GitLab currently assumes that packages have been uploaded to a registry by default. For example, if no homepage key is pointing to GitLab in a package.json file, Gitlab assumes that the package has been uploaded to the npm registry. This not always the case, in fact, I have come across many packages that were defined for local use only and never published — this can be seen on multiple popular projects belonging to Facebook. To demonstrate my point I picked one of your projects and claimed the package on npm, so now if users navigate to https://gitlab.com/gitlab-org/gitter/desktop/blob/master/package.json and click on gitter-desktop, they will be redirected to my "malicious" npm module where there are clear instructions on how to install the package.

<div class="blob-viewer" data-type="auxiliary">
<i aria-hidden="true" data-hidden="true" class="fa fa-cubes fa-fw"></i>
This project manages its dependencies using
<strong>npm</strong>
and defines a package named
<strong><a target="_blank" rel="noopener noreferrer" href="https://www.npmjs.com/package/gitter-desktop">gitter-desktop</a></strong>.
<a target="_blank" rel="noopener noreferrer" href="https://www.npmjs.com/">Learn more</a>
</div>
npm modules are particularly dangerous since by design, npm executes certain scripts from dependencies during the installation process as demonstrated in https://hackerone.com/reports/399166 and https://vince-uploaded.s3.amazonaws.com/static/vulcoord/files/319816_attach_npmwormdisclosure.pdf.
I would also like to add, it is really easy to automate this hijacking process and I would be more than happy to demonstrate an exploit on my own personal GitLab instance where I can claim lots of these package links in various test projects, if you are interested.
Impact
An adversary can trick an unsuspecting user into installing and executing a malicious package from the npm registry. What makes this attack possible is the fact that the package appears to belong to a trusted entity due to GitLab linking to the malicious packet from the project's page.
- Ed
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 automatic package referencer assumed every declared package name exists on the public registry and linked to it without verifying ownership or publication.
Impact
An adversary could trick an unsuspecting user into installing and executing a malicious package that appears to belong to a trusted project.
What the attacker needed
Unpublished package name in a manifest; attacker registers that name on npm; victim clicks the auto-generated link
How it was found
- Open a project's package.json file in GitLab's file viewer.
- Click the auto-linked package name shown in the dependency notice.
- Observe the redirect to the npm registry page for that package name.
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 you open a file like package.json on GitLab, the site turns package names into clickable links to the public npm registry. The problem is that some of those packages were never actually published, so anyone could register that name on npm first. A visitor who trusts the project page could then click through and install code controlled by a stranger.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.