Malware in a GitHub repository: how to check a repo before you run it
A GitHub malware repository does not need you to run its program. It can run something when you open the folder, install packages or build the project. Read the files that execute on their own first: .vscode/tasks.json, npm scripts, Xcode projects and, in a project folder someone shared, git hooks. A scan finds only known malware, so open an unknown repo in isolation.
Already ran it? Stop using the Mac for anything sensitive and disconnect it from the network. Then follow the cleanup steps in If you already ran it: clean the Mac first, then change passwords from another device you trust.
Cloning a repo only copies files. The harm starts when something runs them, and three ordinary actions can do that: opening the folder in an editor, installing dependencies, or building the project. A fourth, committing, matters only if someone handed you a whole project folder that carries its own git hooks (scripts git runs at set points). A normal git clone does not bring hooks along. Below is what to read, in order, and then how to open the repo where a surprise costs little.
01Files to read before you run a GitHub malware repository
Look at these in a terminal or a plain text viewer, not in an editor that may run them. The whole check takes a couple of minutes, and none of the steps needs the code to run.
| File or place | What to look for | When it runs |
|---|---|---|
| .vscode/tasks.json | A task with runOn set to folderOpen | When the folder opens |
| package.json | preinstall, install and postinstall entries | After packages are installed |
| Xcode project files | Unexpected build phases and settings | While the project is built |
| .git/hooks in a shared project folder | Hook files you did not write, in a folder someone gave you | On later commits in that project |
| .claude/settings.json | Hooks defined in the project | In agent sessions; hooks are scripts that run at set points |
| .mcp.json | Project-scoped MCP servers | In agent sessions; MCP servers are programs an agent can call |
| README setup steps | Commands to paste into a terminal | Whenever you paste them |
For the first row, two commands do the job:
cat .vscode/tasks.json
grep folderOpen .vscode/tasks.jsonThe .vscode folder is routinely ignored in security reviews, which is why it comes first. Reviewing .mcp.json does not show every server a session can load. Hooks and MCP are explained on Claude Code hooks.
02Where a GitHub malware repository hides its code
Four cases show the pattern, so the table above is not abstract.
- A task that runs on open. Malicious .vscode/tasks.json files were found in 400+ GitHub repositories. The recruiter-scam version of this is on fake job interview malware.
- An Xcode project. XCSSET is a Mac malware family that infects Xcode projects and runs while the project is built. It spreads because developers share project files, and it persists through pre-commit hooks in the .git directory. It can also change Xcode build settings and so compromise the final application binaries without disrupting the developer's workflow. The findings were shared with Apple, and GitHub took down repositories affected by it. A shared Xcode project from a stranger is therefore worth the same suspicion as a tasks.json file. More is on XCSSET.
- An npm install script. In September 2025, malicious versions of popular npm packages carried a post-install script that harvested data. npm has a setting named ignore-scripts, and when it is true npm does not run the scripts in package.json files. Packages are covered on check an npm package for malware and npm malware.
- A repository posing as software. Banshee, a Mac stealer that takes browser credentials and wallet extensions, spread through malicious GitHub repositories. Other campaigns used sponsored ads and search results that pointed to GitHub pages impersonating legitimate macOS software, and a later campaign swapped the GitHub pages for poisoned AI chat answers that ended in a command pasted into Terminal. In the GitHub cases the repository is the bait and not the code you were meant to build.
03What each of these files does
A task in tasks.json is a command that VS Code runs for you. With runOn set to folderOpen it runs the moment the containing folder is opened, and VS Code executes the specified command automatically. That is why simply opening a cloned repository in the editor can compromise the system.
An npm script is a command in package.json. In npm 11 the preinstall, install and postinstall scripts run after the modules are installed, in order, with nothing in between. npm 12 blocks dependency install scripts by default until you approve them. A git hook is a script that git runs at a set point, such as before a commit; XCSSET uses the pre-commit kind to stay on the machine. A clone does not copy hooks, so they matter in a project folder passed around as files, which is how XCSSET spreads. An Xcode project can run code while it is built. In each case the file looks like configuration, which is why it gets skipped in a quick read.
04Can you scan a repository for malware?
A scan is worth running but it does not decide anything. macOS includes XProtect, built-in antivirus technology for signature-based detection and removal of malware. A signature describes malware that is already known. A Banshee variant went undetected by antivirus engines on VirusTotal for over two months, and a DigitStealer disk image was flagged by none of them at analysis time.
TruffleHog is a different kind of tool: it finds secrets such as keys and passwords, not malware. So the order is: read the auto-run files, run a scanner if you like, then open the repo in isolation.
05Open it in isolation
The advice for unfamiliar code is a dedicated, isolated environment, for example a non-persistent virtual machine. A VM is a computer simulated inside your Mac that you can delete afterwards.
If you stay in VS Code, new unfamiliar folders open in Restricted Mode, which limits tasks, the terminal, extensions and AI agents. Automatic tasks never run in an untrusted workspace, and when in doubt you leave the folder in Restricted Mode. Restricted Mode cannot stop a malicious extension from running code. In Cursor, workspace trust is off by default, and for untrusted repos the docs point to a basic text editor.
A container is a lighter option than a VM: an isolated box on your Mac where the code runs. VS Code can open a repo in an isolated container volume to review it without impacting your local work. Use that as a second layer, because dev containers are meant for trusted repositories. A copyable setup with Docker's own tool is on Claude Code in Docker.
If you open the repo with an AI agent, look first and run the agent only in the isolated environment. The advisories that affected Claude Code are listed on Claude Code security.
06A README that asks you to paste a command
Never run commands copied from websites, emails or messages unless you trust the source and understand what they do. That includes curl-to-bash combinations. A README that asks for a pasted command deserves the same suspicion as an email that asks for your password, even when the repository has many stars and a tidy history. If you need a README command, read it first, and if you cannot say what each part does, do not paste it. What these stealers take once they run is covered on infostealers.
07If you already ran it
Treat the Mac as exposed, since a stealer takes browser data, Keychain, SSH keys and cloud credentials. Clean it, change passwords from another device you trust, then revoke GitHub credentials; the steps in order are on how to check for an infostealer and GitHub account hacked. On a personal account you delete tokens and SSH keys one by one in GitHub settings, because the one-step "revoke all credentials" option is only for some enterprise accounts. Read the first step on that page before you revoke, because on an infected Mac a background process can react to a revoked token.
08A GitHub malware repository: what to remember
A GitHub malware repository works through files that run on their own, and you can read them in a couple of minutes. A scan covers only known samples, so read first and open unknown repos in isolation.
Artificial Immunity's free, open-source core watches VS Code tasks, git hooks, package scripts and program starts and reports what it finds.
FAQ
How to check a GitHub repo for malware?
Read the files that run on their own before you open or install anything: .vscode/tasks.json, package.json scripts, Xcode project files and, in a shared project folder, .git hooks. Then open the repo in an isolated environment.
How to scan a GitHub repo for malware?
A scan helps only against known samples. A Banshee variant stayed undetected by antivirus engines for over two months, and a DigitStealer sample was undetected at analysis time. Reading the auto-run files is the stronger check.
How to know if a GitHub repository is safe?
You cannot prove it, you can only reduce the risk: inspect and verify projects downloaded or cloned from repositories and review recruiter-provided repositories before running scripts.
Are GitHub files virus free?
No. Banshee spread through malicious GitHub repositories, and XCSSET spreads through compromised GitHub repositories disguised as legitimate tools.
What are the top 3 malware?
There is no official ranking. The families tied to GitHub repositories are Banshee, XCSSET and the backdoors planted through tasks.json files.
How do I run a scan for malware?
macOS includes XProtect, built-in antivirus technology for signature-based detection and removal of malware. Signatures describe known malware, so a new repo trick needs the manual checks above.
Related guides
Sources
- Microsoft Security Blog, XCSSET
- Microsoft Security Blog, XCSSET evolves again
- Moonlock, XCSSET
- Microsoft Security Blog, Contagious Interview
- OpenSourceMalware, TasksJacker
- Check Point, Banshee stealer
- Jamf Threat Labs, DigitStealer
- VS Code docs, tasks
- VS Code docs, Workspace Trust
- npm docs, scripts and config
- Claude Code docs, MCP
- Malwarebytes, AMOS cleanup guidance
- Artificial Immunity
- Pro Git, Git hooks
- Cursor security notice, rotate from a trusted system
- GitHub docs, managing personal access tokens
- GitHub docs, reviewing your SSH keys
- GitHub docs, revoking your credentials