Skip to content
Misconfiguration Disclosed report Beginner

External commits can be spoofed as official codes in archives

GitLab allowed archive download links for commits from forks to use the same URL scheme as official repository commits, so a malicious fork commit could be presented as an official tarball. An attacker could trick users into downloading and compiling malicious code.

GitLab

Originally disclosed on GitLab

  • Fixed in 13 days
  • Disclosed after 13 days

HackerOne report #1098683 by rxtx on 2021-02-08, assigned to @ankelly:

Report | How To Reproduce

Report

Summary

In this vulnerability a malicious actor can spoof commits coming from a fork as arriving from the official repository in tarball links. This means that "official" tarball download links from a repository may not be official at all, but linked with malicious 3rd party fork repositories. This may get to serious consequences since it leads to execution of malicious code (in most cases, see if malware is injected into the make install target, even with root permissions).

It is worth reminding that commit archive download links are used as an officially recognized trusted means of deploying patches to users, since they provide a very effective and git-less way even for inexperienced users to check out particular branches or patches.

Steps to reproduce
  1. Create a repository (cunidev/random-kittens in demo)
  2. Fork the repository from another "vanity user" (innocuoususer/random-kittens in demo), commit some changes, then send a MR to the original repository. You may close the MR (being almost sure that the original author will never even open it) or leave it open, as you prefer. Part of the issue is exactly this, since not even closing the MR will make the commit disappear.
  3. Open the MR "Commits" tab, and copy the SHA256 hash of the commit in its detailed page.
  4. Substitute it to that present in the URL of the tarball / zipfile to any in the archives of the original repository.

In the demo, https://gitlab.com/cunidev/random-kittens/-/archive/1a3cf77530d52b35deb5813518e33a816527429b/random-kittens-1a3cf77530d52b35deb5813518e33a816527429b.tar.gz is the target (malicious) pseudo-commit, since it never entered the official git history of the target repository but still appears to be part of the official code.

Impact

Consequences of such spoofed URLs are many. Malicious commits can be treated as official ones, since archive links are meant to be official and universally known as such, to the extent that many external tools (see: Alpine Linux's official packaging format) tend to suggest looking for commit SHAs to download snapshots of projects from GitLab.

Examples

As a particular use case, links to, say, torvalds/linux or any universally trusted repository can be shared online (with clients, hobbyists, enterprises and other kinds of interested sides) which is not code really belonging to the torvalds/linux repository.

Users downloading such tarballs may yield full control of their systems to malicious agents, for example if an internal Makefile is carefully modified and crafted to install root-level malware almost no user compiling it will notice.

IM chat platform:

  --------------------------------------------------------------  
< [@]spacecat25 seems like it's solved in this commit, try it:   
    https://gitlab.com/cunidev/random-kittens/-/archive/1a3cf77530d52b35deb5813518e33a816527429b/random-kittens-1a3cf77530d52b35deb5813518e33a816527429b.tar.gz  
  --------------------------------------------------------------

                                                                           -----------------------------  
                                                                                       thanks! i'll try!  >  
                                                                           -----------------------------  
                                                     just installed it, seems like they didn't though :(  >   
                                                                           -----------------------------  
  -------------------------  
< ah... shame [*evil grin*]  
  ------------------------

Online forum (Reddit, etc.):

Seems like a new Linux kernel release solves the issue with the BRCM4329 wireless card, you should try compiling it: https://gitlab.com/cunidev/random-kittens/-/archive/1a3cf77530d52b35deb5813518e33a816527429b/random-kittens-1a3cf77530d52b35deb5813518e33a816527429b.tar.gz

(spam the same reply on hundreds of forums, replicate for thousands of software)

GitLab issues:

"Try building this and see if it still applies: https://gitlab.com/cunidev/random-kittens/-/archive/1a3cf77530d52b35deb5813518e33a816527429b/random-kittens-1a3cf77530d52b35deb5813518e33a816527429b.tar.gz"

Mailing lists:

"Hi! Seems like devs have finally added Reddit support to Random Kittens, here's the beta: https://gitlab.com/cunidev/random-kittens/-/archive/1a3cf77530d52b35deb5813518e33a816527429b/random-kittens-1a3cf77530d52b35deb5813518e33a816527429b.tar.gz"

...and so on. Examples are endless.

What is the current bug behavior?

Externally sourced, rejected commits have the same URL scheme for archives/tarballs as official, internal commits.

What is the expected correct behavior?

Tarballs for commits should not be generated until approval occurs, should show a disclaimer or should have a different URL scheme.

Relevant logs and/or screenshots

[Not necessary for scope of issue]

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

[Not necessary for scope of issue]

As a side note, the demo repository is not malicious (especially the origin one, which does not even try to look so). So if you want a script that sets a random cat from the Internet as your Linux background, now you have it in three lines of Bash.

Thank you for your attention. My most sincere appreciation for your platform and work, which I enjoy using every day.

Kind regards,
Raffaele / [@]rxtx

Impact

It could spoof an externally sourced ZIP file containing any kind of contents or modifications to the initial code as being an official commit of the repository.

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

Impact

An attacker could spoof an externally sourced ZIP file containing any kind of contents or modifications to the initial code as being an official commit of the repository, potentially leading users to execute malicious code.

What the attacker needed

A GitLab account; ability to fork a public repository; victim clicks a crafted archive link

The fix

Tarballs for commits should not be generated until approval occurs, should show a disclaimer, or should have a different URL scheme.

How it was found

  1. Create a repository.
  2. Fork the repository from another user, commit changes, and send a merge request to the original repository (closing it does not remove the commit).
  3. Open the merge request's Commits tab and copy the commit hash from the detailed page.
  4. Replace the commit hash in the original repository's archive download URL with the copied hash.

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 download a project's source code from a code hosting site, the link often includes a unique code (a commit hash) that identifies a specific version. This report found that GitLab would create a download link for a version that came from someone else's copy (a fork) using the same format as the official project. So an attacker could share a link that looks official but actually downloads their modified code, which might contain malware.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.