GitHub hosts more than 200 million repositories, so it wouldn’t be far-fetched to believe threat actors will use that figure to their advantage. Hackers look to infect famous and obscure repos with malware, so users fall prey to their attacks. So, how does malicious software get on GitHub?
Threat actors can edit, clone, and compromise existing repositories. They can also upload seemingly harmless ones that have malware disguised in their files. Using trustworthy repos, scanning for malware, and becoming an active community member is the best way to prevent that from happening.
Does that make GitHub a dangerous website? Far from it! It’s a great place to share your projects and learn from others. However, you have to understand how threat actors spread malware via GitHub, so you can stay safe while you browse different repos.
How Does Malicious Software Get On GitHub?
1. Edited Repos
An edited repository is one of the worst things that could happen. GitHub allows users to change or alter any project as long as creators and moderators allow that to happen.
That mechanism ensures open source projects improve at a faster rate: users can contribute without developers having a hands-on approach.
Unfortunately, that allows hackers to perform several attacks. They can hide their malware deep inside a project. Unless the community has an active role in moderating and controlling contributions, that alteration will go unnoticed –ending with countless users infected.
The biggest repos don’t have that trouble because they feature bigger control. Smaller projects, in contrast, may fall prey to this type of malicious alteration.
2. Cloned Repos
Although developers and moderators can prevent random users from editing their projects (and mitigate the chance of spreading malware that way), they can’t stop others from creating a fork or clone.
Forks happen all the time within the GitHub community. Someone takes a project’s source code and makes a few alterations, creating a new project in the process.
Hackers use a similar mechanism. They clone a repo (i.e., take the source code and create another project), inject malware in it, and upload it with a similar or identical name to the original, hoping to fool users into downloading the fake, malware-ridden project.
Automated scans and manual surveillance often deal with this sort of issue – as it happened in the past.
3. Harmful Repos
Certain threat actors prefer to draw little attention to themselves and upload a repository that has nothing to do with existing ones. That way, they create no fuzz by altering or cloning a repo, increasing their chances of having malware on GitHub for longer.
How does that happen? They’ll upload a repository that seems legitimate at first glance. Of course, a scan or second look would give away there’s malware on it.
This strategy often catches beginner users off guard. Veterans tend to recognize harmful repos, though a careless attitude may compromise even the most experienced users. A quick antivirus scan can help you here.
4. Compromised Repos
Last but not least, hackers may compromise repos to steal data. They may use social engineering tactics or malware to accomplish that goal – but rest assured, it has happened in the past.
Why should you worry about compromised repos? Because even though transparency is a big part of the open source community, you can set your repositories to private – but that doesn’t prevent hackers from accessing them.
We advise people to be smart about the sort of stuff they upload to GitHub (or any other site, for that matter). There are several reasons why hackers target this website, and you don’t want to fall prey to threat actors.
Why Do Hackers Target GitHub?
GitHub features millions of users and countless repositories, which is an incredible feat. Unfortunately, hackers tend to exploit large websites because a lot of people go there.
In other words, threat actors know malware is a numbers game: you have to infect as many people as possible in the shortest time. GitHub would be the perfect place for that to happen – if it featured no controls or moderation. We’ll talk more about GitHub methods to stop malware below.
For now, you can rest easy knowing almost all repositories are safe. You can scan them when in doubt. You can set up a separate device where you play with suspicious repositories if you want to be even more careful.
Does GitHub Allow Malware?
According to GitHub rules, users can upload malware as long as they have no malicious intent. In other words, malware research is okay – but targeting people or organizations is not.
Can you upload malware to GitHub? Absolutely! Be advised that you shouldn’t play with or upload malware anywhere unless you have the expertise to do so.
You’re one wrong click or command away from wrecking your hardware beyond fixing when using the strongest malware (even if you mean no harm).
Cybersecurity is interesting. The best way to learn about malware is by having a disposable device you can reset without losing anything. Of course, make sure it’s not connected to a network or device malware can spread to – unless you want trouble.
Can Malware Be On GitHub?
You can find malware on GitHub. People upload malicious software to that website for one of two purposes: wanting to do research or looking to do harm.
In the first case, users upload malware for others to study it. That may seem dangerous (and for beginners, it is), but cybersecurity enthusiasts can make a lot of progress by reading malware’s source code, seeing how it reacts, and how to stop it.
In the second case, threat actors upload malware disguised as repositories to inflict harm. They hope to infect as many devices as possible before their modification or new repo gets taken down. Doing so is against the rules, unlike uploading malware for research purposes.
How Does GitHub Prevent Malware Infections?
- Automated Scans. The biggest line of defense GitHub offers to protect users is automated scans. Different algorithms scan every new repository and every modification that takes place. That way, they prevent hackers from uploading harmful repos or injecting malware into existing ones. Helpful bots are not alone: humans also play their part.
- Community Control. One of the biggest advantages GitHub has is its active community. They have close to 100 million users (and that number continues to grow). The most active members take their repos and their community very seriously, helping to moderate it and keeping hackers at bay. Fortunately, they’re not alone in their efforts.
- Security Research. A website as big and important as GitHub has a security team of its own. They take care of a lot of things, including making sure nobody compromises repos or anything else on their site. Of course, that approach alone may allow threat actors to slip through the cracks – but a combined effort of all three tactics is rather successful.
How To Prevent a Malware Infection From a GitHub Repo
1. Check the Source Code
A tedious but sure way to see whether you’re dealing with a malware-infected repository is to read the source code of the project you’re about to download.
Of course, that takes a long time, considering certain repos have thousands and thousands of lines of code. In certain scenarios, manually reading code would be close to impossible, especially if you’re in a rush.
However, that doesn’t mean you can’t take the time to read the latest edits of a project. That way, you get to figure out if the latest contributor is a threat actor in disguise.
You can also take the time to review the code of small projects to see if something is wrong.
2. Scan What You Download
What’s the easiest way to know if something is infected or not? Using an antivirus! A quick scan will rule out a huge number of viruses and other types of malware from being on a repository you just downloaded.
Of course, antivirus software is far from perfect. At the same time, new malware is created all the time – and the latest ones may easily bypass your antivirus.
However, that doesn’t mean you should uninstall your antivirus. Have it as your second line of defense instead (your first one should be combining cybersecurity best practices and common sense).
Experts often have devices prepared to deal with suspicious files to keep their main safe computer from harm.
3. Use a Virtual Machine or Secondary Device
Malware can only infect places it has access to. You can download suspicious repos using a virtual machine and execute the files there to see what happens. Unfortunately, certain malware can bypass your VM and infect other devices.
So, what other methods do you have? You can always use a secondary device you have no trouble with wiping (if push comes to shove). Make sure you have no important data on it. There are plenty of cheap computers on the market you can use for that purpose.
If you’re going down the secondary device route, make sure it’s not connected to any other devices or networks. Otherwise, the malware may jump there. Malware can also connect to WiFi networks that are close by, so make sure that doesn’t happen either.
4. Look For Trustworthy Repos
It’s incredibly difficult to compromise the biggest repos on GitHub. The community is way too active to allow that to happen. At the same time, developers and moderators have a tight grasp on any alterations, edits, or anything that may change the course of their projects.
Of course, that doesn’t mean it won’t happen. A threat actor may stumble upon an unpatched vulnerability on GitHub or use social engineering to infiltrate a project. It sounds like an improbable thing – but far from impossible.
Either way, the best you can do is protect your end and try to prevent hackers from doing harm.
You can do the first one by reading source code, performing antivirus scans, and using secondary devices when downloading suspicious repos. You can do the second one by becoming an active GitHub community member.
5. Become an Active Member of the Community
As you know, GitHub relies on three pillars to keep threat actors at bay. The first one is automated scans. The second one is security research done by experts. The third one is you.
That’s right! You can play your part in helping to keep malware at bay. You’re already here, so that means you have an interest in cybersecurity. Continue learning and use your knowledge to contribute to repositories you like.
At the same time, make sure you keep an eye on any modifications or alterations that happen on the repos you’re participating in.
Becoming an active community member will help you three-fold: keep yourself away from harm, protect others, and help you learn more (so you can become even better at fighting against malware and keeping GitHub safe).
Is GitHub Safe?
GitHub is a safe place for anyone to share their projects and participate in other people’s projects. It’s a wonderful website for open source enthusiasts who want to make the most out of technology using a great degree of transparency.
Unfortunately, threat actors will use any chance they have to compromise users. That puts websites like GitHub in a tough spot: they can increase their controls (at the expense of users), or they can use a more creative effort to mitigate attacks without hindering user experience.
The good news is GitHub took the second approach! They have stopped most malware attacks by combining automatic scans, community control, and security research. The community continues to thrive thanks to that effort.
Takeaways
Threat actors can compromise repositories or clone them, hoping users download these harmful repos to infect devices with malware. Fortunately, GitHub relies on automatic scans, community controls, and security research to prevent that from happening. U.S. Cybersecurity recommends interacting with trustworthy repos, becoming an active community member, and scanning files at a minimum when using GitHub.